From nobody Sun Jun 28 18:40:55 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 4gpJBv5ZFbz6jkln for ; Sun, 28 Jun 2026 18:40:55 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gpJBv31DTz3YlQ for ; Sun, 28 Jun 2026 18:40:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782672055; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JETq3li/AqCoZF758ebEjeykPC0eOkW9AKlDA7Tv/UU=; b=CxwjkSJQ1V/d9pjLYaot5I5GDVRi0UAO+MPJ9yuYgkHXDQHgvINfNldKvXqRzwhNcW4987 vU7E2uzUwrqwuZtnckqmXcBErORziUDjC1rxWfc6Lb76ce8HGQnV4RiiXK1CoegW1XjbXP 3a6+lTd3c0iLWwn/BEnlRNkMbPmxKKmXveBmkeZwB8Yi1h5DncqZm3RTpGo+aAjW/1PoDv ywWdBiWufo53EZ7Y66hUSFbMJF61u7ehrfMU/tJiuE5ko3JEMbQqYNlo6SEU6172Unk8xu d3sORLoyZs98EcO0N+NpQlXsYkmYWZb8ikJsAalm5/w2e1sg9/RWybUbh+iMCw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782672055; a=rsa-sha256; cv=none; b=Px/0nEwW+qjDTNDQG6dA6sTIewEGQfIU0kWDWgB0eJi6RuqPng1412cM+a+uJe3tnni2hq iMSN/IJk7I+Mas+ybrygASnU8hNcEknYpNmctcR3vefC4s4Baw2FwLeibItvH/d7bDWEzs /V8U8V85lde393wAaTR1SUctv+uiwHiCRBL9XQjoqE0LBK5F+QwTdknYdHRXm70ge6aoLG YwqrVr1a3vrFZKaqLiQ6FpAXZtSNr/19V2hClwvhY2ZIzIvlUB4hKB4TGnTxTBUezS00Ub DBBvr8bXrfGq+81tRsmGpZ92wY5pAxXxF3IIRHUTKEZIZFzFjs4XAgUqzycnzg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782672055; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JETq3li/AqCoZF758ebEjeykPC0eOkW9AKlDA7Tv/UU=; b=cRW2jRZ9NpmWcOX8VQHiJvdur2PQc7k71t3dZXY4XXKQOIp5mkvX2OGYfgngaARXx6PNv3 5KfpWe1VbcdvjPkqET7hxRbAuu6PApg7oLvdrYTrmB6OrXForgsoHb3i4Fg1TUB0F/0Hu7 rKePorHVCqu/KbQwp3N01tmP/85I71sSkC+6qcmgAXUvXvM2R4pTDgPZvIZNsrZVqrFWap 78vMmWWXoont/UgVeporIEHR2h3lkihotq5ob32W7b/PplqUcjN6FX4i45e7WiQDdv6dEP SpSk7Mpnd9cVLbTyWs+bU/LkGKmuf3K3D5H+2TZye1SgTvcQX8fRvrgoZExThQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gpJBv22TKz7CS for ; Sun, 28 Jun 2026 18:40:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1c691 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 28 Jun 2026 18:40:55 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Baptiste Daroussin Subject: git: 3bb20f3c2837 - stable/15 - nuageinit: use single-quote shell escaping for hostname in rc.conf.d 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 List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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/15 X-Git-Reftype: branch X-Git-Commit: 3bb20f3c28373db0236ebfb9e2cccc63333c8f7a Auto-Submitted: auto-generated Date: Sun, 28 Jun 2026 18:40:55 +0000 Message-Id: <6a416ab7.1c691.4c7c2a0a@gitrepo.freebsd.org> The branch stable/15 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=3bb20f3c28373db0236ebfb9e2cccc63333c8f7a commit 3bb20f3c28373db0236ebfb9e2cccc63333c8f7a Author: Baptiste Daroussin AuthorDate: 2026-06-09 14:04:18 +0000 Commit: Baptiste Daroussin CommitDate: 2026-06-28 18:39:56 +0000 nuageinit: use single-quote shell escaping for hostname in rc.conf.d The hostname value was written inside double quotes in /etc/rc.conf.d/hostname. POSIX shell performs command substitution inside double quotes, so a hostname containing $() or backticks would be executed when the file is sourced (e.g., by rc(8)). Switch to using the existing shell_escape() helper, which wraps values in single quotes. In POSIX shell, single-quoted strings are completely literal — no expansion or substitution of any kind is performed. While the hostname is already validated to contain only [a-zA-Z0-9.-], this change provides defense-in-depth so the output format is safe regardless of future validation changes. Reported by: Yazdan Soltani (cherry picked from commit da3890fdccfa7d540ea746182248299b81f95345) --- libexec/nuageinit/nuage.lua | 2 +- libexec/nuageinit/tests/nuage.sh | 2 +- libexec/nuageinit/tests/nuageinit.sh | 12 ++++++------ libexec/nuageinit/tests/sethostname.lua | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libexec/nuageinit/nuage.lua b/libexec/nuageinit/nuage.lua index a554553b3e61..523bfc65a579 100644 --- a/libexec/nuageinit/nuage.lua +++ b/libexec/nuageinit/nuage.lua @@ -187,7 +187,7 @@ local function sethostname(hostname) warnmsg("Impossible to open " .. hostnamepath .. ":" .. err) return end - f:write('hostname="' .. hostname:gsub('"', '\\"') .. '"\n') + f:write("hostname=" .. shell_escape(hostname) .. "\n") f:close() end diff --git a/libexec/nuageinit/tests/nuage.sh b/libexec/nuageinit/tests/nuage.sh index 97c5224c7813..1e08c990eacd 100644 --- a/libexec/nuageinit/tests/nuage.sh +++ b/libexec/nuageinit/tests/nuage.sh @@ -33,7 +33,7 @@ sethostname_body() if [ ! -f etc/rc.conf.d/hostname ]; then atf_fail "hostname not written" fi - atf_check -o inline:"hostname=\"myhostname\"\n" cat etc/rc.conf.d/hostname + atf_check -o inline:"hostname='myhostname'\n" cat etc/rc.conf.d/hostname } addsshkey_body() diff --git a/libexec/nuageinit/tests/nuageinit.sh b/libexec/nuageinit/tests/nuageinit.sh index 798ac235e122..3f3e2843c35d 100644 --- a/libexec/nuageinit/tests/nuageinit.sh +++ b/libexec/nuageinit/tests/nuageinit.sh @@ -80,13 +80,13 @@ nocloud_body() atf_check -s exit:1 -e match:"nuageinit: error parsing nocloud.*" /usr/libexec/nuageinit "${PWD}"/media/nuageinit/ nocloud printf "instance-id: iid-local01\nlocal-hostname: cloudimg\n" > "${PWD}"/media/nuageinit/meta-data atf_check -s exit:0 /usr/libexec/nuageinit "${PWD}"/media/nuageinit nocloud - atf_check -o inline:"hostname=\"cloudimg\"\n" cat etc/rc.conf.d/hostname + atf_check -o inline:"hostname='cloudimg'\n" cat etc/rc.conf.d/hostname cat > media/nuageinit/meta-data << EOF instance-id: iid-local01 hostname: myhost EOF atf_check -s exit:0 /usr/libexec/nuageinit "${PWD}"/media/nuageinit nocloud - atf_check -o inline:"hostname=\"myhost\"\n" cat etc/rc.conf.d/hostname + atf_check -o inline:"hostname='myhost'\n" cat etc/rc.conf.d/hostname } nocloud_userdata_script_body() @@ -250,7 +250,7 @@ config2_body() } EOF atf_check /usr/libexec/nuageinit "${PWD}"/media/nuageinit config-2 - atf_check -o inline:"hostname=\"cloudimg\"\n" cat etc/rc.conf.d/hostname + atf_check -o inline:"hostname='cloudimg'\n" cat etc/rc.conf.d/hostname } config2_pubkeys_head() @@ -1307,7 +1307,7 @@ echo "multipart script executed" --==BOUNDARY==-- EOF atf_check -o empty /usr/libexec/nuageinit "${PWD}"/media/nuageinit config-2 - atf_check -o inline:"hostname=\"multipart-host\"\n" cat etc/rc.conf.d/hostname + atf_check -o inline:"hostname='multipart-host'\n" cat etc/rc.conf.d/hostname atf_check -o inline:"#!/bin/sh\necho \"multipart script executed\"\n" cat var/cache/nuageinit/multipart_script test -x var/cache/nuageinit/multipart_script || atf_fail "multipart_script not executable" true @@ -1376,13 +1376,13 @@ fqdn: host.domain.tld hostname: host EOF atf_check -o empty /usr/libexec/nuageinit "${PWD}"/media/nuageinit config-2 - atf_check -o inline:"hostname=\"host.domain.tld\"\n" cat ${PWD}/etc/rc.conf.d/hostname + atf_check -o inline:"hostname='host.domain.tld'\n" cat ${PWD}/etc/rc.conf.d/hostname cat > media/nuageinit/user_data <