diff options
Diffstat (limited to 'libexec')
| -rw-r--r-- | libexec/nuageinit/nuage.lua | 6 | ||||
| -rwxr-xr-x | libexec/nuageinit/nuageinit | 32 | ||||
| -rw-r--r-- | libexec/nuageinit/tests/addfile.lua | 2 | ||||
| -rw-r--r-- | libexec/nuageinit/tests/nuageinit.sh | 2 | ||||
| -rw-r--r-- | libexec/rtld-elf/aarch64/rtld_machdep.h | 2 | ||||
| -rw-r--r-- | libexec/rtld-elf/amd64/rtld_machdep.h | 2 | ||||
| -rw-r--r-- | libexec/rtld-elf/arm/rtld_machdep.h | 2 | ||||
| -rw-r--r-- | libexec/rtld-elf/i386/rtld_machdep.h | 2 | ||||
| -rw-r--r-- | libexec/rtld-elf/powerpc/reloc.c | 24 | ||||
| -rw-r--r-- | libexec/rtld-elf/powerpc/rtld_machdep.h | 2 | ||||
| -rw-r--r-- | libexec/rtld-elf/powerpc64/reloc.c | 24 | ||||
| -rw-r--r-- | libexec/rtld-elf/powerpc64/rtld_machdep.h | 2 | ||||
| -rw-r--r-- | libexec/rtld-elf/riscv/rtld_machdep.h | 2 | ||||
| -rw-r--r-- | libexec/rtld-elf/rtld.c | 25 |
14 files changed, 86 insertions, 43 deletions
diff --git a/libexec/nuageinit/nuage.lua b/libexec/nuageinit/nuage.lua index 3eeb2ea0b44c..2d962b540b23 100644 --- a/libexec/nuageinit/nuage.lua +++ b/libexec/nuageinit/nuage.lua @@ -69,7 +69,7 @@ local function errmsg(str, prepend) end local function chmod(path, mode) - local mode = tonumber(mode, 8) + mode = tonumber(mode, 8) local _, err, msg = sys_stat.chmod(path, mode) if err then errmsg("chmod(" .. path .. ", " .. mode .. ") failed: " .. msg) @@ -150,8 +150,6 @@ local function splitlines(s) end local function getgroups() - local ret = {} - local root = os.getenv("NUAGE_FAKE_ROOTDIR") local cmd = "pw " if root then @@ -579,7 +577,7 @@ local function settimezone(timezone) root = "/" end - f, _, rc = os.execute("tzsetup -s -C " .. root .. " " .. timezone) + local f, _, rc = os.execute("tzsetup -s -C " .. root .. " " .. timezone) if not f then warnmsg("Impossible to configure time zone ( rc = " .. rc .. " )") diff --git a/libexec/nuageinit/nuageinit b/libexec/nuageinit/nuageinit index dc33f20464dc..a5411c60b410 100755 --- a/libexec/nuageinit/nuageinit +++ b/libexec/nuageinit/nuageinit @@ -229,10 +229,10 @@ local function nameservers(interface, obj) local resolv_conf = root .. "/etc/resolv.conf" - resolv_conf_attr = lfs.attributes(resolv_conf) + local resolv_conf_attr = lfs.attributes(resolv_conf) if resolv_conf_attr == nil then - resolv_conf_handler = open_resolv_conf() + local resolv_conf_handler = open_resolv_conf() resolv_conf_handler:close() end @@ -295,10 +295,11 @@ local function match_rules(rules) -- with the matching interfaces must be returned. This changes the way we initially -- thought about our implementation, since at first we only needed one interface, -- but cloud-init performs actions on a group of matching interfaces. + local interface local interfaces = {} if rules.macaddress then local ifaces = get_ifaces_by_mac() - local interface = ifaces[rules.macaddress] + interface = ifaces[rules.macaddress] if not interface then nuage.warn("not interface matching by MAC address: " .. rules.macaddress) return @@ -348,11 +349,11 @@ local function write_files(files, defer) end end -local function write_files_not_defered(obj) +local function write_files_not_deferred(obj) write_files(obj.write_files, false) end -local function write_files_defered(obj) +local function write_files_deferred(obj) write_files(obj.write_files, true) end -- Set network configuration from user_data @@ -381,6 +382,7 @@ local function network_config(obj) extra_opts = extra_opts .. " wol" end if v.mtu then + local mtu if type(v.mtu) == "number" then mtu = tostring(v.mtu) else @@ -661,8 +663,16 @@ if not f then os.exit(0) end local line = f:read("*l") +if not line or #string.gsub(line, "^%s*(.-)%s*$", "%1") == 0 then + f:close() + os.exit(0) +end if citype ~= "postnet" then local content = f:read("*a") + if not content or #string.gsub(content, "^%s*(.-)%s*$", "%1") == 0 then + f:close() + os.exit(0) + end nuage.mkdir_p(root .. "/var/cache/nuageinit") local tof = assert(io.open(root .. "/var/cache/nuageinit/user_data", "w")) tof:write(line .. "\n" .. content) @@ -680,14 +690,14 @@ if line == "#cloud-config" then network_config, ssh_pwauth, runcmd, - write_files_not_defered, + write_files_not_deferred, } local post_network_calls = { packages, users, chpasswd, - write_files_defered, + write_files_deferred, } f = io.open(ni_path .. "/" .. ud) @@ -704,12 +714,8 @@ if line == "#cloud-config" then for i = 1, #calls_table do if citype == "nocloud" and calls_table[i] == network_config then - netobj = parse_network_config() - if netobj == nil then - network_config(obj) - else - network_config(netobj) - end + local netobj = parse_network_config() or obj + network_config(netobj) else calls_table[i](obj) end diff --git a/libexec/nuageinit/tests/addfile.lua b/libexec/nuageinit/tests/addfile.lua index 98d020e557c0..ea98369f1909 100644 --- a/libexec/nuageinit/tests/addfile.lua +++ b/libexec/nuageinit/tests/addfile.lua @@ -35,7 +35,7 @@ if str ~= f.content then n.err("Invalid file content") end --- the file is overwriten +-- the file is overwritten f.content = "test" str = addfile_and_getres(f) diff --git a/libexec/nuageinit/tests/nuageinit.sh b/libexec/nuageinit/tests/nuageinit.sh index 2b7c5226c97a..851f7110378a 100644 --- a/libexec/nuageinit/tests/nuageinit.sh +++ b/libexec/nuageinit/tests/nuageinit.sh @@ -890,7 +890,7 @@ EOF atf_check -o inline:"plop" cat file1 atf_check -o inline:"" cat emptyfile atf_check -o inline:"bla\n" cat file_base64 - test -f foo && atf_fail "foo creation should have been defered" + test -f foo && atf_fail "foo creation should have been deferred" atf_check -o match:"^-rwxr-xr-x.*nobody" ls -l file_base64 rm file1 emptyfile file_base64 atf_check -o empty /usr/libexec/nuageinit "${PWD}"/media/nuageinit postnet diff --git a/libexec/rtld-elf/aarch64/rtld_machdep.h b/libexec/rtld-elf/aarch64/rtld_machdep.h index 3cc1339fcad4..d689ae354c49 100644 --- a/libexec/rtld-elf/aarch64/rtld_machdep.h +++ b/libexec/rtld-elf/aarch64/rtld_machdep.h @@ -52,6 +52,8 @@ bool arch_digest_dynamic(struct Struct_Obj_Entry *obj, const Elf_Dyn *dynp); bool arch_digest_note(struct Struct_Obj_Entry *obj, const Elf_Note *note); +#define arch_fix_auxv(a, ai) do {} while (0) + Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj, const Elf_Rel *rel); diff --git a/libexec/rtld-elf/amd64/rtld_machdep.h b/libexec/rtld-elf/amd64/rtld_machdep.h index 1797d13c847d..2ee63d566bed 100644 --- a/libexec/rtld-elf/amd64/rtld_machdep.h +++ b/libexec/rtld-elf/amd64/rtld_machdep.h @@ -47,6 +47,8 @@ Elf_Dyn *rtld_dynamic_addr(void); /* No architecture specific notes */ #define arch_digest_note(obj, note) false +#define arch_fix_auxv(a, ai) do {} while (0) + Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const struct Struct_Obj_Entry *obj, const struct Struct_Obj_Entry *refobj, const Elf_Rel *rel); diff --git a/libexec/rtld-elf/arm/rtld_machdep.h b/libexec/rtld-elf/arm/rtld_machdep.h index f59b30028a3b..88fa18a0c07a 100644 --- a/libexec/rtld-elf/arm/rtld_machdep.h +++ b/libexec/rtld-elf/arm/rtld_machdep.h @@ -47,6 +47,8 @@ struct Struct_Obj_Entry; /* No architecture specific notes */ #define arch_digest_note(obj, note) false +#define arch_fix_auxv(a, ai) do {} while (0) + Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj, const Elf_Rel *rel); diff --git a/libexec/rtld-elf/i386/rtld_machdep.h b/libexec/rtld-elf/i386/rtld_machdep.h index 581f1dfb002d..079991f913d6 100644 --- a/libexec/rtld-elf/i386/rtld_machdep.h +++ b/libexec/rtld-elf/i386/rtld_machdep.h @@ -60,6 +60,8 @@ Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, #define call_init_pointer(obj, target) \ (((InitArrFunc)(target))(main_argc, main_argv, environ)) +#define arch_fix_auxv(a, ai) do {} while (0) + extern uint32_t cpu_feature; extern uint32_t cpu_feature2; extern uint32_t cpu_stdext_feature; diff --git a/libexec/rtld-elf/powerpc/reloc.c b/libexec/rtld-elf/powerpc/reloc.c index 8932c2c21278..c160028cea6d 100644 --- a/libexec/rtld-elf/powerpc/reloc.c +++ b/libexec/rtld-elf/powerpc/reloc.c @@ -840,3 +840,27 @@ __tls_get_addr(tls_index* ti) return (tls_get_addr_common(_tcb_get(), ti->ti_module, ti->ti_offset + TLS_DTV_OFFSET)); } + +void +arch_fix_auxv(Elf_Auxinfo *aux, Elf_Auxinfo *aux_info[]) +{ + Elf_Auxinfo *auxp; + + for (auxp = aux; auxp->a_type != AT_NULL; auxp++) { + if (auxp->a_type == 23) /* AT_STACKPROT */ + return; + } + + /* Remap from old-style auxv numbers. */ + aux_info[23] = aux_info[21]; /* AT_STACKPROT */ + aux_info[21] = aux_info[19]; /* AT_PAGESIZESLEN */ + aux_info[19] = aux_info[17]; /* AT_NCPUS */ + aux_info[17] = aux_info[15]; /* AT_CANARYLEN */ + aux_info[15] = aux_info[13]; /* AT_EXECPATH */ + aux_info[13] = NULL; /* AT_GID */ + + aux_info[20] = aux_info[18]; /* AT_PAGESIZES */ + aux_info[18] = aux_info[16]; /* AT_OSRELDATE */ + aux_info[16] = aux_info[14]; /* AT_CANARY */ + aux_info[14] = NULL; /* AT_EGID */ +} diff --git a/libexec/rtld-elf/powerpc/rtld_machdep.h b/libexec/rtld-elf/powerpc/rtld_machdep.h index ec470f238991..de6a894ac1f5 100644 --- a/libexec/rtld-elf/powerpc/rtld_machdep.h +++ b/libexec/rtld-elf/powerpc/rtld_machdep.h @@ -46,6 +46,8 @@ bool arch_digest_dynamic(struct Struct_Obj_Entry *, const Elf_Dyn *); /* No architecture specific notes */ #define arch_digest_note(obj, note) false +void arch_fix_auxv(Elf_Auxinfo *aux, Elf_Auxinfo *aux_info[]); + Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj, const Elf_Rel *rel); diff --git a/libexec/rtld-elf/powerpc64/reloc.c b/libexec/rtld-elf/powerpc64/reloc.c index 9ea14f63b5c7..4a4107aef861 100644 --- a/libexec/rtld-elf/powerpc64/reloc.c +++ b/libexec/rtld-elf/powerpc64/reloc.c @@ -737,3 +737,27 @@ __tls_get_addr(tls_index* ti) return (tls_get_addr_common(_tcb_get(), ti->ti_module, ti->ti_offset + TLS_DTV_OFFSET)); } + +void +arch_fix_auxv(Elf_Auxinfo *aux, Elf_Auxinfo *aux_info[]) +{ + Elf_Auxinfo *auxp; + + for (auxp = aux; auxp->a_type != AT_NULL; auxp++) { + if (auxp->a_type == 23) /* AT_STACKPROT */ + return; + } + + /* Remap from old-style auxv numbers. */ + aux_info[23] = aux_info[21]; /* AT_STACKPROT */ + aux_info[21] = aux_info[19]; /* AT_PAGESIZESLEN */ + aux_info[19] = aux_info[17]; /* AT_NCPUS */ + aux_info[17] = aux_info[15]; /* AT_CANARYLEN */ + aux_info[15] = aux_info[13]; /* AT_EXECPATH */ + aux_info[13] = NULL; /* AT_GID */ + + aux_info[20] = aux_info[18]; /* AT_PAGESIZES */ + aux_info[18] = aux_info[16]; /* AT_OSRELDATE */ + aux_info[16] = aux_info[14]; /* AT_CANARY */ + aux_info[14] = NULL; /* AT_EGID */ +} diff --git a/libexec/rtld-elf/powerpc64/rtld_machdep.h b/libexec/rtld-elf/powerpc64/rtld_machdep.h index d628e776bae9..06eb6d884101 100644 --- a/libexec/rtld-elf/powerpc64/rtld_machdep.h +++ b/libexec/rtld-elf/powerpc64/rtld_machdep.h @@ -46,6 +46,8 @@ bool arch_digest_dynamic(struct Struct_Obj_Entry *, const Elf_Dyn *); /* No architecture specific notes */ #define arch_digest_note(obj, note) false +void arch_fix_auxv(Elf_Auxinfo *aux, Elf_Auxinfo *aux_info[]); + Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj, const Elf_Rel *rel); diff --git a/libexec/rtld-elf/riscv/rtld_machdep.h b/libexec/rtld-elf/riscv/rtld_machdep.h index c6600b583612..1f4fe2e928fe 100644 --- a/libexec/rtld-elf/riscv/rtld_machdep.h +++ b/libexec/rtld-elf/riscv/rtld_machdep.h @@ -60,6 +60,8 @@ uint64_t set_gp(struct Struct_Obj_Entry *obj); /* No architecture specific notes */ #define arch_digest_note(obj, note) false +#define arch_fix_auxv(a, ai) do {} while (0) + Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj, const Elf_Rel *rel); diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index d27af520c21d..bdfff7361e96 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -521,9 +521,6 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) char buf[MAXPATHLEN]; int argc, fd, i, mib[4], old_osrel, osrel, phnum, rtld_argc; size_t sz; -#ifdef __powerpc__ - int old_auxv_format = 1; -#endif bool dir_enable, dir_ignore, direct_exec, explicit_fd, search_in_path; /* @@ -549,28 +546,8 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) for (auxp = aux; auxp->a_type != AT_NULL; auxp++) { if (auxp->a_type < AT_COUNT) aux_info[auxp->a_type] = auxp; -#ifdef __powerpc__ - if (auxp->a_type == 23) /* AT_STACKPROT */ - old_auxv_format = 0; -#endif - } - -#ifdef __powerpc__ - if (old_auxv_format) { - /* Remap from old-style auxv numbers. */ - aux_info[23] = aux_info[21]; /* AT_STACKPROT */ - aux_info[21] = aux_info[19]; /* AT_PAGESIZESLEN */ - aux_info[19] = aux_info[17]; /* AT_NCPUS */ - aux_info[17] = aux_info[15]; /* AT_CANARYLEN */ - aux_info[15] = aux_info[13]; /* AT_EXECPATH */ - aux_info[13] = NULL; /* AT_GID */ - - aux_info[20] = aux_info[18]; /* AT_PAGESIZES */ - aux_info[18] = aux_info[16]; /* AT_OSRELDATE */ - aux_info[16] = aux_info[14]; /* AT_CANARY */ - aux_info[14] = NULL; /* AT_EGID */ } -#endif + arch_fix_auxv(aux, aux_info); /* Initialize and relocate ourselves. */ assert(aux_info[AT_BASE] != NULL); |
