From nobody Sat Aug 16 17:40:19 2025 X-Original-To: dev-commits-src-main@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 4c45pr2zHGz64hxV; Sat, 16 Aug 2025 17:40:20 +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 4c45pr11qWz3sQZ; Sat, 16 Aug 2025 17:40:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1755366020; 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=uvV2P9kCZ1N/RELBcy/g/Ija5s71oKILvuDAREG4cHs=; b=vy3O7OM6OqdDJhCfZJhurmZBYxwJ7x3gFkIoHjCvGIx1+9L7I2Q4D87ALWjM+Pb7+dd/Oq Kao02l25DCj/RflXZw9yGsu+s4A41nXe8RGaBUldQqypjykcmZ7mVQCy+QKw5cnofZ/+5i 6Wz/wAirsaegRMftrAlt0gg+lQOsHpkbOyd2EYqaUzrHtyxOOObG0u2kreKNecBcKvxX2o 0Vh6PirlI79IFbLx8lVv58JMcamv/t6D4WMN29Cab+5HsPqqaU316D+eFiD0CR/k+fwXNR Z0guRNdPDWhiU6jSCadJ5/qTJ2xFCUiyV9a4lm07UwCuAU3ZqgSK4Ood1hDoeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1755366020; 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=uvV2P9kCZ1N/RELBcy/g/Ija5s71oKILvuDAREG4cHs=; b=pSwgCAhtZG5FDKgx9OVc0C2EL/j/oD+4PYwCoeNqBzQ79ZUJA1op59+l9E6i0DMUzsrB8G yjcHZBvkPZ85HOrIQ+ny/Up7TB4I4KTWMF9CdUviKWK8U47w0B6qUBpGWzeGV/Gae6Y6Js jfqh00unwn6oj9pa0JGGP36sql8OQ2HPJGorwV1UxQU1A3s/BBKV5AO4vbZ320tMyFxnTK FhkwyBfxWhVI1NxM6/vmMZ5Yu8NAD5j756uH9FE/MDM5gt/j+e+h2Y3d5ZZTqHnvWVAr4l Z0WjxbZUjptEqeob68ToR+ACU1avcFFJ6SpChb5v64dw7j3BMuTFPNzNw9BYrg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1755366020; a=rsa-sha256; cv=none; b=wEA9pej3N7TeCWSVc7zSX05JeJvD8836h7j4ACsDX6fpTwsrZPSSwmWydrxMChPzNGMZbW /0OsMYpOlHAfJKi/DiiVs14sPJDt+qYlPyRPWyxuOzDSa0ooXcCM2W5zF1eJRFdCpgrO6S g/iWO3bqMTL9bslD5pZChuKohLV4EgGEs8V2KKks42C4q1em8b3jdjBFrmUTbGO6oGsohg bFVejQxZon105vRFGmP7BZ6tOcRMzSXjFDPjcKuu2VCEr/HnsBjKFG07gvFG52h34Rl8qu q0yYcebbjZZ11mEAjTY9iE/HhDx+ePH90fxCHoJ9iojKQQrYvH6YRRw6zRMtSg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4c45pr00C5zYnr; Sat, 16 Aug 2025 17:40:19 +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 57GHeJdP082378; Sat, 16 Aug 2025 17:40:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 57GHeJw8082375; Sat, 16 Aug 2025 17:40:19 GMT (envelope-from git) Date: Sat, 16 Aug 2025 17:40:19 GMT Message-Id: <202508161740.57GHeJw8082375@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: b81fd3fc8b20 - main - jail: fix backfilling the "name" for jid-named jails List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b81fd3fc8b20eaad64b5c41826432124fd92d6a7 Auto-Submitted: auto-generated The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=b81fd3fc8b20eaad64b5c41826432124fd92d6a7 commit b81fd3fc8b20eaad64b5c41826432124fd92d6a7 Author: Kyle Evans AuthorDate: 2025-08-16 17:39:47 +0000 Commit: Kyle Evans CommitDate: 2025-08-16 17:39:59 +0000 jail: fix backfilling the "name" for jid-named jails Using the cfparam variant of add_param() will actually copy the name and flags from the passed-in param, which I hadn't considered. We actually want the name/flags from the "name" param so that we can do variable expansion against it right after that -- otherwise it cannot be found, since variable expansion actually searches by name. While we're here, `jls -e` was the intermediate name for `jls -c` that never saw the light of the day. Fix our existence test. Reviewed by: jamie Fixes: 02944d8c49 ("jail: consistently populate the KP_JID [...]") Differential Revision: https://reviews.freebsd.org/D51831 --- usr.sbin/jail/config.c | 2 +- usr.sbin/jail/tests/jail_basic_test.sh | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/usr.sbin/jail/config.c b/usr.sbin/jail/config.c index 70de82e662e7..1bad04ccde68 100644 --- a/usr.sbin/jail/config.c +++ b/usr.sbin/jail/config.c @@ -189,7 +189,7 @@ load_config(const char *cfname) * jail is created or found. */ if (j->intparams[KP_NAME] == NULL) - add_param(j, j->intparams[KP_JID], KP_NAME, NULL); + add_param(j, NULL, KP_NAME, j->name); /* Resolve any variable substitutions. */ pgen = 0; diff --git a/usr.sbin/jail/tests/jail_basic_test.sh b/usr.sbin/jail/tests/jail_basic_test.sh index 509900e8569c..6802da7b049a 100755 --- a/usr.sbin/jail/tests/jail_basic_test.sh +++ b/usr.sbin/jail/tests/jail_basic_test.sh @@ -198,7 +198,7 @@ clean_jails() fi while read jail; do - if jls -e -j "$jail"; then + if jls -c -j "$jail"; then jail -r "$jail" fi done < jails.lst @@ -211,10 +211,23 @@ jid_name_set_body() echo "basejail" >> jails.lst echo "$jid { name = basejail; persist; }" > jail.conf atf_check -o match:"$jid: created" jail -f jail.conf -c "$jid" + # Confirm that we didn't override the explicitly-set name with the jid + # as the name. + atf_check -o match:"basejail" jls -j "$jid" name + atf_check -o match:"$jid: removed" jail -f jail.conf -r "$jid" + + echo "$jid { host.hostname = \"\${name}\"; persist; }" > jail.conf + atf_check -o match:"$jid: created" jail -f jail.conf -c "$jid" + # Confirm that ${name} expanded and expanded correctly to the + # jid-implied name. + atf_check -o match:"$jid" jls -j "$jid" host.hostname atf_check -o match:"$jid: removed" jail -f jail.conf -r "$jid" echo "basejail { jid = $jid; persist; }" > jail.conf atf_check -o match:"basejail: created" jail -f jail.conf -c basejail + # Confirm that our jid assigment in the definition worked out and we + # did in-fact create the jail there. + atf_check -o match:"$jid" jls -j "basejail" jid atf_check -o match:"basejail: removed" jail -f jail.conf -r basejail }