From nobody Thu Jun 26 12:34:56 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 4bSdS15g7Cz60W10; Thu, 26 Jun 2025 12:34:57 +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 4bSdS110xzz42yY; Thu, 26 Jun 2025 12:34:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750941297; 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=ZDL7SjBX1FaOtNcW28vG2xkV6GzP3Yd36kinU7fbUOU=; b=Kioq0LIAe5kx6NJRpJXszBLmUv9ObmNsTVclTcQcwFNh2arkLsYh/1GDuebXb2MVimsSTY JGwke9yXBZLHuSG6lHc7RZwzF7v9KnNWMzyFa8YM0TojaYmr4VRTkX1sPIAuObgwL8euzZ 1kiSRFtKaZ8wOYZQe4IJ795KlhfraZfZeWpO2AYZPWNDQEswDWY55advpAkv/PLW0rAoBx UaWojq+iez63O6xOw6PwvWoxCF7VVf29cIxu31SCpc4nai8fyNdDjEigceeTeamAS96o+Z oBH/wPvAJ3G9tWvjSf42TD2huleuBupp9aT0SCaZanZmq3JF2Lb3xieFJ5OYrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750941297; 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=ZDL7SjBX1FaOtNcW28vG2xkV6GzP3Yd36kinU7fbUOU=; b=PjDaBZD2hIlYtbTnSHA6XBdVjHan8xPdDFoeILEwVa+T65Pwb8G0aCF9rqzNRtKI5v1TJ4 fQWBpe2FCwSgTaq3Rl85UwSgv0QBtn4yhlSzIfqGekyY2KQ81YENWnO2nOoY48SoGWk3Mx rDoHEpkmqNihmKyktSZKYjMUCCYzJ8DZYOceoer9heY0ZnD+AMbbMc1B5REbnLkJ/nnFj5 SXVSAXu4POga20eCgARA1CwmoaWH4277BzZYUUsykjd1vRmwN2G3zVYhAlFN+jDfBZe9zP WJL9CiFW4TLQaYuMIrZfaHTISm+b6UdZRC0Kvrov6SANy602FNGaS84NdN7lHA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1750941297; a=rsa-sha256; cv=none; b=Xmu7ZjsEZZtacdaj708M+63NtdI1BPY8/MfWnZPc1Ziubq2U1oHwiNT9kCoPfObWK6HNLe kyTNKTzIDMJtBga3R3cifxIVETl18Oxx6ibbzwcezIrSfAUlkODi2LVINTpaooIDAwlSq+ f6BYPELieIvX1APt2djj3fe2EvCx74hou8n0xK2EjeC7+EXQq2VW+c1+ox+b60bOm2R4BF y4F3agsjHyRaqkywaaO5HQLsPbknogqMpOIRr6nUB7LdWJJhxCKYgq1zsCltDprK/2AaZu DXx7Wkdh7jdp6ErW5FkYv1Ijm4ShXzl/+ccC8xhnUXiP29EKSdebZnq9Gb6Mig== 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 4bSdS05q2nz13Wk; Thu, 26 Jun 2025 12:34:56 +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 55QCYuhE052974; Thu, 26 Jun 2025 12:34:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 55QCYuKP052971; Thu, 26 Jun 2025 12:34:56 GMT (envelope-from git) Date: Thu, 26 Jun 2025 12:34:56 GMT Message-Id: <202506261234.55QCYuKP052971@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Baptiste Daroussin Subject: git: b56d2195f124 - main - 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/main X-Git-Reftype: branch X-Git-Commit: b56d2195f124d48ce54369d179aa1d4663e5e64a Auto-Submitted: auto-generated The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=b56d2195f124d48ce54369d179aa1d4663e5e64a commit b56d2195f124d48ce54369d179aa1d4663e5e64a Author: Baptiste Daroussin AuthorDate: 2025-06-26 12:32:27 +0000 Commit: Baptiste Daroussin CommitDate: 2025-06-26 12:34:51 +0000 nuageinit: enhance sudo support from the cloudinit specification sudo rules can be a string or an array of string --- 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 8d75f86272a7..11958e8b5cc2 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()