From nobody Wed Jan 14 12:34:10 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4drlst6yFwz6NMV8 for ; Wed, 14 Jan 2026 12:34:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4drlst497sz3x9Z for ; Wed, 14 Jan 2026 12:34:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1768394050; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Myi7LFizqan6ZQuzkFtz/ZguK4LqdtSRjWKpLQt956A=; b=m67EEUyxhzB8yHY4PPWIdWZYaT/GSjalJ5ML/HSKxvhiNpwGg5g9lqNVzBpLoWIIDx+pqN YmHalNNSczvmusvjxTXTzIZQdju8RymODAVK9UfseqO6RDLcw2a9Y8trzws+TF84AwXm6f SmevnKKFsjyTvUdMD2cRYhOFChPF7cVn1oYTT79Xajs09DmX/IOMLARn2z3rIQeCSlNRpH hhQt+WBUpRMR9z8+WUJcdVjM3mIx/6n9Ltcky7y+cE+5azwh3VJNqf4hFAjaZ67stPl5to XYxfHDRvq9ILMpPPKBDf2xdm8LKVQ/L5JPG8iNDW9Bl9cMP3GoOXPZZUBymXow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1768394050; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Myi7LFizqan6ZQuzkFtz/ZguK4LqdtSRjWKpLQt956A=; b=sLprQ/RduT3EDJXOpkXkLQ8hO9/czvnH+/PdoBqLln0NbTuD9tSvR78gh35i/EA3rjcFUe TwK043FNvxcAw3074KrMdIPOD3eZHeJqbjLXMfhEWeCyZDR1y5DvtL2Jq6S3DhBcFWT4dr vzlh88xd1yx+TRKCfdZ7UrI4hLU2pL9s51G1biS30QWKSzoDzDcH2TobOXdozF/RZNJCgk a/ZzKSMW4fkRqnsKIbEuMZSBIG0Jh+3tLwrMk10ZruSWgLLmHSPJUG+pIOWo27jtzJJXsY nVY4jlwVPREzya9UthjVMQMu2tQfcUy/P97sESdFSxEbauSZFXdI7IwmrvmTcQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1768394050; a=rsa-sha256; cv=none; b=bEBWTSjdwkkH8DG2HO1R5faK+jp5OCjVBvlRYTePagr/5N59njw0caZP20t+8soUECPFo+ gnp++fFgYguZobXnpPNRihOZoBmjgkMb2DtP/uoS8wgqMBuMugvoHh48YeOsh9uxb/7EY/ eTnAY7yAWMR7oH0AE2lETeVMklk4JeqWa5fZ7dFWsIvyFz/q2wpRG+pV7j8Sghg3AWPeIJ Y4nXaNjatUIxqv1G4b0RzaDftNAldu07uNeAGtf3AFEvPExZhDxxOUmoYZ0KgQ7lzKUbb9 lMDfCuKQ2UozNZV87W+pJoMUlh1Egt9PMZAvObRwnZMfBLBaqp148PpKbsXH9w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4drlst3gr2zyJ4 for ; Wed, 14 Jan 2026 12:34:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3fab7 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 14 Jan 2026 12:34:10 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: =?utf-8?Q?Gon=C3=A9ri?= Le Bouder From: Baptiste Daroussin Subject: git: 14f366b358ac - stable/14 - nuageinit: set the hostname when user-data is missing List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 14f366b358ac336f78910e53d8e753f57f999852 Auto-Submitted: auto-generated Date: Wed, 14 Jan 2026 12:34:10 +0000 Message-Id: <69678d42.3fab7.cf2acaa@gitrepo.freebsd.org> The branch stable/14 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=14f366b358ac336f78910e53d8e753f57f999852 commit 14f366b358ac336f78910e53d8e753f57f999852 Author: Gonéri Le Bouder AuthorDate: 2026-01-07 21:03:34 +0000 Commit: Baptiste Daroussin CommitDate: 2026-01-14 12:33:41 +0000 nuageinit: set the hostname when user-data is missing This address the situation reported here https://github.com/freebsd/freebsd-src/pull/1952#issuecomment-3720210259 The user-data file was missing and the `sethostname` function is never called. This commit adjusts slightly the logic to avoid the `exit()` call when the `user-data` file is missing. MFC After: 1 week Signed-off-by: Gonéri Le Bouder Differential Revision: https://github.com/freebsd/freebsd-src/pull/1953 (cherry picked from commit cae280931c9e1f072d8bf300c377ae120300b898) --- libexec/nuageinit/nuageinit | 113 ++++++++++++++++++++++++++------------------ 1 file changed, 67 insertions(+), 46 deletions(-) diff --git a/libexec/nuageinit/nuageinit b/libexec/nuageinit/nuageinit index c36467d2110f..c8a53316f682 100755 --- a/libexec/nuageinit/nuageinit +++ b/libexec/nuageinit/nuageinit @@ -22,7 +22,7 @@ local function default_user(obj, metadata) table.insert(ssh_authorized_keys, k) end end - if type(obj.ssh_authorized_keys) == "table" then + if obj and type(obj.ssh_authorized_keys) == "table" then for _, k in ipairs(obj.ssh_authorized_keys) do table.insert(ssh_authorized_keys, k) end @@ -93,13 +93,13 @@ end local function sethostname(obj, metadata) -- always prefer fqdn if specified over hostname - if obj.fqdn then + if obj and obj.fqdn then nuage.sethostname(obj.fqdn) - elseif obj.hostname then + elseif obj and obj.hostname then nuage.sethostname(obj.hostname) - elseif metadata["local-hostname"] then + elseif metadata["local-hostname"] then nuage.sethostname(metadata["local-hostname"]) - elseif metadata["local"] then + elseif metadata["hostname"] then nuage.sethostname(metadata["hostname"]) end end @@ -129,6 +129,10 @@ end local function create_default_user(obj, metadata) local function need_default_user() + -- no user data + if not obj then + return true + end if not obj.users then -- default user if "users" is undefined return true @@ -268,7 +272,7 @@ local function nameservers(interface, obj) -- Only call resolvconf with interface if interface is provided if interface then resolvconf_command = "resolvconf -a " .. interface .. " < " .. resolv_conf - else + else resolvconf_command = "resolvconf -u" end if not os.execute(resolvconf_command) then @@ -661,7 +665,7 @@ local function parse_network_config() return netobj end -local function load_metadata() +local function load_metadata(citype) if citype == "config-2" then local parser = ucl.parser() local res, err = parser:parse_file(ni_path .. "/meta_data.json") @@ -689,46 +693,70 @@ local function load_metadata() return {} end +local function load_userdata() + local ud = nil + local f = nil + local userdatas = {"user-data", "user_data"} + for _, v in pairs(userdatas) do + f = io.open(ni_path .. "/" .. v, "r") + if f then + ud = v + break + end + end + if not f then + return nil, nil + end + local line = f:read("*l") + if not line or #string.gsub(line, "^%s*(.-)%s*$", "%1") == 0 then + f:close() + return + end + if citype ~= "postnet" then + local content = f:read("*a") + if not content or #string.gsub(content, "^%s*(.-)%s*$", "%1") == 0 then + f:close() + return + 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) + tof:close() + end + f:close() + + local obj = nil + if ud then + f = io.open(ni_path .. "/" .. ud) + obj = yaml.load(f:read("*a")) + f:close() + if not obj then + nuage.err("error parsing cloud-config file: " .. ud) + end + end + return line, obj +end if citype == "config-2" then -- network config2_network(ni_path) end -local metadata = load_metadata() +local metadata = load_metadata(citype) +local line, obj = load_userdata() --- deal with user-data -local ud = nil -local f = nil -local userdatas = {"user-data", "user_data"} -for _, v in pairs(userdatas) do - f = io.open(ni_path .. "/" .. v, "r") - if f then - ud = v - break - end -end -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) +-- No user-data +if line == nil then + local calls_table = { + sethostname, + create_default_user, + } + + for i = 1, #calls_table do + calls_table[i](obj, metadata) 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) - tof:close() -end -f:close() -if line == "#cloud-config" then +-- YAML user-data +elseif line == "#cloud-config" then local pre_network_calls = { sethostname, settimezone, @@ -748,13 +776,6 @@ if line == "#cloud-config" then write_files_deferred, } - f = io.open(ni_path .. "/" .. ud) - local obj = yaml.load(f:read("*a")) - f:close() - if not obj then - nuage.err("error parsing cloud-config file: " .. ud) - end - local calls_table = pre_network_calls if citype == "postnet" then calls_table = post_network_calls