From nobody Tue Jul 8 14:32:28 2025 X-Original-To: dev-commits-src-all@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 4bc3V45J9Fz614tr; Tue, 08 Jul 2025 14:32:28 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bc3V42zKjz49Nh; Tue, 08 Jul 2025 14:32:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751985148; 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=U+sZ04YDH6lh9znMxopxsTuLXPdkGU1U4xsQWBiwFSg=; b=e4pLkGetuGK72McB9hYlXH3eOnwRsxAsgGQ0fET30MF0s8Ci+LNBIRf0TqJUHkgLPpiweg XVox47lGc73MgVkMbTxIy1sxizpoA1nOMsC4VsB2txMYNSnmMjBbniap+SrZLtHPenUZ1w aqhTCrTfyHZbwocjJSTG/PXWofSg9EhfuIlIpL9NpSWDnIKAEZG1bX+ynJ7eA0Xr3U45Pk wqllsLTwos45ycsHugJY+gzxFZyXGGOS7E7PIE/yh59U6I7TvIn/unN81j08mSOmjyRIxN W5q34jxIz6s8yKNQLkyfJdbOWbLUmj4yWgm80aqA+lwiAA7xrHvLc/EZl2Qj9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751985148; 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=U+sZ04YDH6lh9znMxopxsTuLXPdkGU1U4xsQWBiwFSg=; b=J15UevlQqg2mu+BYmXKSeOFnOZcAdlG0lW7VwsOnDKJYst3CxMs+frz+MjbuEU6GgbNoex Xbx9NUmLKMWPWU2Sm2cbpfDtSlK17ldVkWE+Mlvo+3q5UAKwCuGOpC4E1YCx9X9RUYSJVa lU1Z5PzX1QKSjoj2PNa/3QxdMkAZ1XPjxr1AZ4Bab5ocM3mqF2Yhfhlkb6UZeG8L7v3hXV D0yXtatGnrpsgDMvVUbKeM8R4YGsraBJalaDyGO5UBD2Lx2lQ1DpDejQVoQAZjA6I/TCxi fNq9MkElYbv4X/OeNVPY7FBSeJVAihQCuo1kYCI7Yimnyqh6agLiKo14OjuzAA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1751985148; a=rsa-sha256; cv=none; b=kQJPFviMvhdfSxtVcuYqZ/C/PlD4mSJ3Y7f6qB7XodJ60gp6RtD6NTIzDsWLBiSpdOUlMw pDjiGlxh5GmXMYmCZbMO1pmwCzQvV58gfXJYNIE36Ih6avFP6SKiZyh3yeQSrplfanht5N SUrzjnXCAecTfAaUZj7lVlk3sBNxXPsHvJAnkeNg3wPE7KRTxBfVwP8b/SQMkMKJgbm1Tm s4efoRsqQxCIThQnQdSa9xR7UTtOTSx8VkJx3VCfKn/ZycVKlkquGtCfRW+XYgoYcoFujb UQDAtGbfoXzt5hx/0wz3B/CAD9yIq0CCwE/+AipZa2CR9ZIXtKV/Z171ej8Cqg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4bc3V42Z9szh3F; Tue, 08 Jul 2025 14:32:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 568EWSTJ073605; Tue, 8 Jul 2025 14:32:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 568EWSY8073600; Tue, 8 Jul 2025 14:32:28 GMT (envelope-from git) Date: Tue, 8 Jul 2025 14:32:28 GMT Message-Id: <202507081432.568EWSY8073600@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Baptiste Daroussin Subject: git: 7508443b1604 - stable/14 - nuageinit: enhance sudo support List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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: 7508443b1604bf1adae99f866770deac1bcdce29 Auto-Submitted: auto-generated The branch stable/14 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=7508443b1604bf1adae99f866770deac1bcdce29 commit 7508443b1604bf1adae99f866770deac1bcdce29 Author: Baptiste Daroussin AuthorDate: 2025-06-26 12:32:27 +0000 Commit: Baptiste Daroussin CommitDate: 2025-07-08 14:31:47 +0000 nuageinit: enhance sudo support from the cloudinit specification sudo rules can be a string or an array of string (cherry picked from commit b56d2195f124d48ce54369d179aa1d4663e5e64a) --- libexec/nuageinit/nuage.lua | 8 +++++++- libexec/nuageinit/nuageinit.7 | 2 +- libexec/nuageinit/tests/nuageinit.sh | 8 +++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/libexec/nuageinit/nuage.lua b/libexec/nuageinit/nuage.lua index cdc0fc6cf2a7..161b95c60d56 100644 --- a/libexec/nuageinit/nuage.lua +++ b/libexec/nuageinit/nuage.lua @@ -287,7 +287,13 @@ local function addsudo(pwd) warnmsg("impossible to open " .. sudoers) return end - f:write(pwd.name .. " " .. pwd.sudo .. "\n") + if type(pwd.sudo) == "string" then + f:write(pwd.name .. " " .. pwd.sudo .. "\n") + elseif type(pwd.sudo) == "table" then + for _, str in ipairs(pwd.sudo) do + f:write(pwd.name .. " " .. str .. "\n") + end + end f:close() if chmodsudoers then sys_stat.chmod(sudoers, 416) diff --git a/libexec/nuageinit/nuageinit.7 b/libexec/nuageinit/nuageinit.7 index 3bb440ebac95..327ce160e151 100644 --- a/libexec/nuageinit/nuageinit.7 +++ b/libexec/nuageinit/nuageinit.7 @@ -211,7 +211,7 @@ The list of other groups the user should belong to. .It Ic locked Boolean to determine if the user account should be locked. .It Ic sudo -An entry which should be appended to +A string or an array of strings which which should be appended to .Pa /usr/local/etc/sudoers.d/90-nuageinit-users .El .Pp diff --git a/libexec/nuageinit/tests/nuageinit.sh b/libexec/nuageinit/tests/nuageinit.sh index 639c87181f95..849f1c258b62 100644 --- a/libexec/nuageinit/tests/nuageinit.sh +++ b/libexec/nuageinit/tests/nuageinit.sh @@ -121,6 +121,10 @@ users: sudo: ALL=(ALL) NOPASSWD:ALL groups: users passwd: $6$j212wezy$7H/1LT4f9/N3wpgNunhsIqtMj62OKiS3nyNwuizouQc3u7MbYCarYeAHWYPYb2FT.lbioDm2RrkJPb9BZMN1O/ + - name: bla + sudo: + - "ALL=(ALL) NOPASSWD:/usr/sbin/pw" + - "ALL=(ALL) ALL" EOF atf_check /usr/libexec/nuageinit "${PWD}"/media/nuageinit nocloud atf_check /usr/libexec/nuageinit "${PWD}"/media/nuageinit postnet @@ -131,17 +135,19 @@ admingroup:*:1001:root,sys cloud-users:*:1002: freebsd:*:1003: foobar:*:1004: +bla:*:1005: EOF cat > expectedpasswd << 'EOF' root:*:0:0::0:0:Charlie &:/root:/bin/sh sys:*:1:0::0:0:Sys:/home/sys:/bin/sh freebsd:freebsd:1001:1003::0:0:FreeBSD User:/home/freebsd:/bin/sh foobar:$6$j212wezy$7H/1LT4f9/N3wpgNunhsIqtMj62OKiS3nyNwuizouQc3u7MbYCarYeAHWYPYb2FT.lbioDm2RrkJPb9BZMN1O/:1002:1004::0:0:Foo B. Bar:/home/foobar:/bin/sh +bla::1003:1005::0:0:bla User:/home/bla:/bin/sh EOF sed -i "" "s/freebsd:.*:1001/freebsd:freebsd:1001/" "${PWD}"/etc/master.passwd atf_check -o file:expectedpasswd cat "${PWD}"/etc/master.passwd atf_check -o file:expectedgroup cat "${PWD}"/etc/group - atf_check -o inline:"foobar ALL=(ALL) NOPASSWD:ALL\n" cat ${PWD}/usr/local/etc/sudoers.d/90-nuageinit-users + atf_check -o inline:"foobar ALL=(ALL) NOPASSWD:ALL\nbla ALL=(ALL) NOPASSWD:/usr/sbin/pw\nbla ALL=(ALL) ALL\n" cat ${PWD}/usr/local/etc/sudoers.d/90-nuageinit-users } nocloud_network_head()