From nobody Sun May 10 15:56:29 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 4gD6sp2BDRz6d2dg for ; Sun, 10 May 2026 15:56:30 +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" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gD6sp0JJQz44NH for ; Sun, 10 May 2026 15:56:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1778428590; 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=5JpvIQ8op4qrqR8dOs2qFCCOyxOmmq3JToiz9mYnvUI=; b=ngYCXNxbo5Q/ILoaOAzTM3pRnjoql/DQMXpNZ21WFE6Dv63x4P5ugWmdhR4W/CT5GfmyjZ vct9Nxmuus6b1BTMZTE/Yz2mM5OZixN6jdpoXrWid/6vBMZNjzGuRhGfGdCbDCZ5Wb6j05 vNQOiadjv1U5xBKhOBJGRU/YKINyz922sghAUw2VKlLAxY/x4S6FfF9WkNXoo8g3pSGRcT jAasvJL2ytHamp5HVWmzQPaxLyWWoQj7g26X9KUpYOGBIm7YMnQ6syaV4PmuOFCdNRj+NM W4mWaRDmWCBMwNiMd+gijJqO9OgSMLp/gc6UUqhnVhLItGtvkucg+RJGzSmfLA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1778428590; a=rsa-sha256; cv=none; b=ID5+XLo0Uh5XWN9ndKjg7J6/o9AoMoe7lxcZV4tXhkw++frDUdxyI2Ap5LkU6OxPE40MxC 778Y5JqR6nSOvexpr1JTq+/QKywpIlSoUDdEL5Ix7FoRIyqtTUdVGxHEQwVyM2FGlCx3OB TF6dOB1QpPy1ujwC4K+fGarBmZFoP8XE9cAXtFoPCMldBfe/Kwkr4cQ1JZ+fSDUWXSDmMW e7/3H8UEVW/tckK9ev+zwL8IA1nPVnjwwfnze5TRFumfLPmwCgXRu8ttg8k/WYU0L9zPZs 2xB3FQ7bS/foZfA7MdY6UxtgEGzKmjwOwhTggjrnzPYovUnFreIYreFsol72OA== 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=1778428590; 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=5JpvIQ8op4qrqR8dOs2qFCCOyxOmmq3JToiz9mYnvUI=; b=cxC4GTwLpo+ctwEHr0hCLuk4rGg6VH3MTc4CSS5n0A1D2+jI6nOs0K7cs6RVX7q0TIAcoH brs62CNEIkVV/UOExHaItETS52i38xGTGSsb35dfqHTc77gXpoefaKYDfY/GqVg7XZ3FuZ ID3Xy1P3FsLmQKwifQLqV/XYxPiXz0HF7YPlNgj71ON0XdQM/Cf3N985kVrDTX1YIGvHK4 U9Ejk2DNPu3vMt2rZZImLy6QuTGg1SprjQ2L/S+V4Zl0Tl72B8kpB5vWTQzP6RK+cqVBb3 actrTKKuS6oFNcUrLzCuPrIj+N9J2uPO8xijSjdUFdC9mZVg96Cei/WIUhE9Pw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gD6sn6w7NzchS for ; Sun, 10 May 2026 15:56:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 36389 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 10 May 2026 15:56:29 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Baptiste Daroussin Subject: git: 8b03193289e8 - main - nuageinit: add update_sshd_config 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/main X-Git-Reftype: branch X-Git-Commit: 8b03193289e87fd243acc50c5128c80459792667 Auto-Submitted: auto-generated Date: Sun, 10 May 2026 15:56:29 +0000 Message-Id: <6a00aaad.36389.7cda12d1@gitrepo.freebsd.org> The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=8b03193289e87fd243acc50c5128c80459792667 commit 8b03193289e87fd243acc50c5128c80459792667 Author: Baptiste Daroussin AuthorDate: 2026-05-10 15:54:48 +0000 Commit: Baptiste Daroussin CommitDate: 2026-05-10 15:54:48 +0000 nuageinit: add update_sshd_config tests --- libexec/nuageinit/tests/Makefile | 1 + libexec/nuageinit/tests/nuage.sh | 8 +++ libexec/nuageinit/tests/update_sshd_config.lua | 73 ++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) diff --git a/libexec/nuageinit/tests/Makefile b/libexec/nuageinit/tests/Makefile index 4c99f8e31ce3..fc7765268660 100644 --- a/libexec/nuageinit/tests/Makefile +++ b/libexec/nuageinit/tests/Makefile @@ -21,5 +21,6 @@ ${PACKAGE}FILES+= addfile.lua ${PACKAGE}FILES+= decode_base64.lua ${PACKAGE}FILES+= addsudo.lua ${PACKAGE}FILES+= adddoas.lua +${PACKAGE}FILES+= update_sshd_config.lua .include diff --git a/libexec/nuageinit/tests/nuage.sh b/libexec/nuageinit/tests/nuage.sh index 01c4612eb8ec..348a8d93ba09 100644 --- a/libexec/nuageinit/tests/nuage.sh +++ b/libexec/nuageinit/tests/nuage.sh @@ -17,6 +17,7 @@ atf_test_case addfile atf_test_case decode_base64 atf_test_case addsudo atf_test_case adddoas +atf_test_case update_sshd_config settimezone_body() { @@ -109,6 +110,12 @@ adddoas_body() atf_check /usr/libexec/flua $(atf_get_srcdir)/adddoas.lua } +update_sshd_config_body() +{ + mkdir -p etc/ssh + atf_check /usr/libexec/flua $(atf_get_srcdir)/update_sshd_config.lua +} + atf_init_test_cases() { atf_add_test_case sethostname @@ -120,4 +127,5 @@ atf_init_test_cases() atf_add_test_case decode_base64 atf_add_test_case addsudo atf_add_test_case adddoas + atf_add_test_case update_sshd_config } diff --git a/libexec/nuageinit/tests/update_sshd_config.lua b/libexec/nuageinit/tests/update_sshd_config.lua new file mode 100644 index 000000000000..ac56c29986ac --- /dev/null +++ b/libexec/nuageinit/tests/update_sshd_config.lua @@ -0,0 +1,73 @@ +#!/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 sshd_config = root .. "/etc/ssh/sshd_config" + +local function setup(content) + local dir = root .. "/etc/ssh" + n.mkdir_p(dir) + local f = assert(io.open(sshd_config, "w")) + f:write(content) + f:close() +end + +local function read_config() + local f = assert(io.open(sshd_config, "r")) + local content = f:read("*a") + f:close() + return content +end + +-- Key not found: appended +setup("SomeOtherKey yes\n") +n.update_sshd_config("PasswordAuthentication", "yes") +if read_config() ~= "SomeOtherKey yes\nPasswordAuthentication yes\n" then + n.err("Key not found: should be appended") +end + +-- Key with same value: no change +setup("PasswordAuthentication yes\n") +n.update_sshd_config("PasswordAuthentication", "yes") +if read_config() ~= "PasswordAuthentication yes\n" then + n.err("Same value: should not change") +end + +-- Key with different value: changed +setup("PasswordAuthentication no\n") +n.update_sshd_config("PasswordAuthentication", "yes") +if read_config() ~= "PasswordAuthentication yes\n" then + n.err("Different value: should change") +end + +-- Key with comment +setup("PasswordAuthentication no # keep this\n") +n.update_sshd_config("PasswordAuthentication", "yes") +if read_config() ~= "PasswordAuthentication yes\n" then + n.err("Comment stripped: '" .. read_config() .. "'") +end + +-- Case insensitive key matching +setup("passwordauthentication no\n") +n.update_sshd_config("PasswordAuthentication", "yes") +if read_config() ~= "PasswordAuthentication yes\n" then + n.err("Case insensitive matching failed") +end + +-- Extra spaces +setup(" PasswordAuthentication no \n") +n.update_sshd_config("PasswordAuthentication", "yes") +if read_config() ~= "PasswordAuthentication yes\n" then + n.err("Extra spaces handling failed: '" .. read_config() .. "'") +end + +os.exit(0)