From nobody Sun Jun 28 18:40:15 2026 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 4gpJB75xzmz6jkJ0 for ; Sun, 28 Jun 2026 18:40:15 +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 4gpJB73j9Rz3XPn for ; Sun, 28 Jun 2026 18:40:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782672015; 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=86IMBOxPu/FNW+TMciaREwmSKIxQ24YjnIR/7kiSTEk=; b=PJy4htDtk/4d9xzV0Xb5A7OM63cl+r/kxF6AaAFlcSpVUH0WDOISxPPVH9EmrmN2VxaUsB AELLFzvWpMMbjO2wFOUZwt3EZad31NirjdUbOezIDpP5kFk/IVQkBXtQsmnIQi1FNgf1Sf VJwoBkMVyIsj3AazwpdKJsFUarm9KhJb3zKOwnOl10B/VwQivVlZjgAQzHl54APspOpadZ Xye+09dFQvmGZ5vudayePfFgKugPY4hflm0teLHBm3XxAXQ8u2JIg0n0BqDQf6dd/Tu9UC /JkD8DmAhwUmnVeVBnAbJPOEP42w/s1NxcXPaD1fDPCuyS8vEORu90z96Yhojg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782672015; a=rsa-sha256; cv=none; b=c5guwOBZ1k6a7J/lyG3QX/Tet5k06qqWY5DCEA6pl3qhVr9pmEBSs8my0axsd6KVPKuwzB wwU0j4ML0/19b/PikwkaI9LIjRCiLmF73CGWyta/DUzXHxUkcue/4o/IZC81tdcJ9KB0XX szLT2YW0Bn0U01delhg3c4KvWC7Io/1DNnnkQeY8kBw9LLkdudTRCLUP8Diol0gU5oqqcd EdowPei7CmKwTrMnjfzNaIhLriS8rN4tpAxaG/LYw85DmfSHT/WAdTWJo20JNP57DFBhMc Cxp9EBKnxpKaoAYqb+5dLng/bfuaxPVRb4+FtQpr62JKHwiFelWvYzGt9m3TPA== 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=1782672015; 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=86IMBOxPu/FNW+TMciaREwmSKIxQ24YjnIR/7kiSTEk=; b=KPpQ/Z6AlBv6DBXbcDi0s1NIBxQz71nyYeldlmXpg1QieLNEoi8k60Ve0h4+DRv0/+I4vY hbyn/NiOe5gDwsWpWhFhVc2aNoYWM6MVvHKDZzK2l6OUq27CNE7S0Fj6ceEaZop4JPHrQ7 ieTIPRjJGbDjcxe+fwtGlfpfb7fL5gNV+KfSTFV3Hmwwqeg5rHh79KoPZKoG1Fp/b36VeS qnjj923s/7gQN4BAfV2apjcuvfB3bKHfJajblV/V0F1SUjbl8TzwBubRIpjkbyeJjcj6Ya ZBDbKOklbu7TgC8Tvs3anrmwRNztldMzlUvB8Ny26oEsg2YHfBrVv89erhLazA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gpJB72f4Nz6nX for ; Sun, 28 Jun 2026 18:40:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1c73c by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 28 Jun 2026 18:40:15 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Baptiste Daroussin Subject: git: 3a0732153ebd - stable/15 - nuageinit: add addsudo tests 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 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: 3a0732153ebd636f82ff5ff999ecb73ebc7e5b1a Auto-Submitted: auto-generated Date: Sun, 28 Jun 2026 18:40:15 +0000 Message-Id: <6a416a8f.1c73c.1f97a9bd@gitrepo.freebsd.org> The branch stable/15 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=3a0732153ebd636f82ff5ff999ecb73ebc7e5b1a commit 3a0732153ebd636f82ff5ff999ecb73ebc7e5b1a Author: Baptiste Daroussin AuthorDate: 2026-05-10 15:54:47 +0000 Commit: Baptiste Daroussin CommitDate: 2026-06-28 18:32:23 +0000 nuageinit: add addsudo tests (cherry picked from commit a49b3b10aae2db1f4a4ecf310fdedc80eb6bb7e2) --- libexec/nuageinit/tests/Makefile | 1 + libexec/nuageinit/tests/addsudo.lua | 61 +++++++++++++++++++++++++++++++++++++ libexec/nuageinit/tests/nuage.sh | 7 +++++ 3 files changed, 69 insertions(+) diff --git a/libexec/nuageinit/tests/Makefile b/libexec/nuageinit/tests/Makefile index feca49784c9e..d13ad14f1d8f 100644 --- a/libexec/nuageinit/tests/Makefile +++ b/libexec/nuageinit/tests/Makefile @@ -19,5 +19,6 @@ ${PACKAGE}FILES+= settimezone.lua ${PACKAGE}FILES+= warn.lua ${PACKAGE}FILES+= addfile.lua ${PACKAGE}FILES+= decode_base64.lua +${PACKAGE}FILES+= addsudo.lua .include diff --git a/libexec/nuageinit/tests/addsudo.lua b/libexec/nuageinit/tests/addsudo.lua new file mode 100644 index 000000000000..7fc5865d83f4 --- /dev/null +++ b/libexec/nuageinit/tests/addsudo.lua @@ -0,0 +1,61 @@ +#!/usr/libexec/flua +--- +-- SPDX-License-Identifier: BSD-2-Clause +-- +-- Copyright (c) 2026 Baptiste Daroussin + +local n = require("nuage") + +local root = os.getenv("NUAGE_FAKE_ROOTDIR") +if not root then + root = "" +end + +local function get_localbase() + local f = io.popen("sysctl -in user.localbase 2> /dev/null") + local lb = f:read("*l") + f:close() + if lb == nil or lb:len() == 0 then + lb = "/usr/local" + end + return lb +end + +local function read_sudoers() + local path = root .. get_localbase() .. "/etc/sudoers.d/90-nuageinit-users" + local f = io.open(path, "r") + if not f then + return nil + end + local content = f:read("*a") + f:close() + return content +end + +-- test with a single string rule +n.addsudo({ name = "testuser", sudo = "ALL=(ALL) NOPASSWD:ALL" }) +local content = read_sudoers() +if not content then + n.err("sudoers file not created") +end +if content ~= "testuser ALL=(ALL) NOPASSWD:ALL\n" then + n.err("unexpected sudoers content for string rule: '" .. content .. "'") +end + +-- remove file for next test +os.remove(root .. get_localbase() .. "/etc/sudoers.d/90-nuageinit-users") + +-- test with a table of rules +n.addsudo({ + name = "testuser", + sudo = { "ALL=(ALL) NOPASSWD:/usr/sbin/pw", "ALL=(ALL) ALL" } +}) +content = read_sudoers() +if not content then + n.err("sudoers file not created for table") +end +if content ~= "testuser ALL=(ALL) NOPASSWD:/usr/sbin/pw\ntestuser ALL=(ALL) ALL\n" then + n.err("unexpected sudoers content for table: '" .. content .. "'") +end + +os.exit(0) diff --git a/libexec/nuageinit/tests/nuage.sh b/libexec/nuageinit/tests/nuage.sh index 1c8d717a5b67..9e3442281c15 100644 --- a/libexec/nuageinit/tests/nuage.sh +++ b/libexec/nuageinit/tests/nuage.sh @@ -15,6 +15,7 @@ atf_test_case adduser_passwd atf_test_case addgroup atf_test_case addfile atf_test_case decode_base64 +atf_test_case addsudo settimezone_body() { @@ -97,6 +98,11 @@ decode_base64_body() atf_check /usr/libexec/flua $(atf_get_srcdir)/decode_base64.lua } +addsudo_body() +{ + atf_check /usr/libexec/flua $(atf_get_srcdir)/addsudo.lua +} + atf_init_test_cases() { atf_add_test_case sethostname @@ -106,4 +112,5 @@ atf_init_test_cases() atf_add_test_case addgroup atf_add_test_case addfile atf_add_test_case decode_base64 + atf_add_test_case addsudo }