From nobody Wed Jul 30 09:55:44 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 4bsSJd1Lpbz63RWK; Wed, 30 Jul 2025 09:55:45 +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 4bsSJc5dDTz49cN; Wed, 30 Jul 2025 09:55:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753869344; 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=jMp8ydcQZSIH5Qiqlc0dYP/uV4DsTSsVs6FsGMiZNXk=; b=DotsFnl88GVWQYyNhWPoYmyjxhcM/PuRLzaSkwaNKwv8fs7h0XQujaHXkIgYfxLrJe0Ov1 Qte5YlcvkqWyaj39b7Y2jYBu3ITMubZKY5/zLabOnT83Ks9DjvTBEXhnZAsOMsiKJsnWOI v+FKOrH15d3yYvelGBJEbu98hzS0n2fXmDTCCPqZWojVEBd+UO2yb4lSBf1h8Sp26i3C1T 5N5hlomvu3Mc4HiqtwpZ90VnCw5kMeMFlbBVsXHjk++O5NWce3vvx9xQbJzIoxu3eKvyLe huC38HtFlvVaBMZGI+mj0ulj1UqCXjLzq6cxN6IcyEX3ZQ7bVLzUDPVsnl2x1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753869344; 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=jMp8ydcQZSIH5Qiqlc0dYP/uV4DsTSsVs6FsGMiZNXk=; b=V3G/ygyEc/i7qlHxebFUZz/ZX/IHGRZXhnx3I3HhU0/kh2y24HjUvPrrzKWAqesZyd/HKS 8bpYNwylPc5QxcvZcxn9XkV9sU0HJQfoX8vjAdW9+R8hldHYltKfXxOZI5qY2A1bVCN8E7 N52FLGQaS5uID1HeIqwty6vF5YqzOE+KmoCdryUI9Y7XE0o3QU+iiCgwcX8kGQ5mC8wN80 K7hAoqQPJsH9cksZ8Mt+oMPNZM7bfufzIs1PXD6ncwvvb07ylYDsZ2SK55fjShTVaxjc8M 62s/E01WfSCNLKTc1/kGizb4u3/zQmphiBqTPpWCt8PBEfYTn7vu749pyVD1Ug== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1753869344; a=rsa-sha256; cv=none; b=oodc3TUlDe21UJujC/o8L5tfu3ECSfJX2rf3wScsvH/Mv9MUlwuI0kyXgEVj2f6EAaOx/i 1TcQVOac4BJ+T7GWKY7qxNLL8lx3J/fBCBrqO/SzpaJHU49BxEayAf698Ij/pKECWIvl0H F9R8NTo9ibzcFHDtqTvte4gOZt0piw6OBjtmpK/IsM4rJXGt1rRLPOlhwUv8AxEA+yRxuL KwGofPdT+yfU4Z8N2PFCI7NRTp87nRiuIu6gKJQzV9/LyNyz569o45ZMgkIcTemVCbM0W5 dNP4bvu0TJ7df6QKr0recyhueyFhV7UPj+b8ALLIAG0vFxP0hlvP4Ode8zRYtA== 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 4bsSJc51z7z19pt; Wed, 30 Jul 2025 09:55:44 +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 56U9ti6F024853; Wed, 30 Jul 2025 09:55:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 56U9tiox024850; Wed, 30 Jul 2025 09:55:44 GMT (envelope-from git) Date: Wed, 30 Jul 2025 09:55:44 GMT Message-Id: <202507300955.56U9tiox024850@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: 7ee04c7b17d1 - stable/13 - rc: Use check_jail to check values of security.jail MIBs 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: 0mp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7ee04c7b17d15e2296b796e1657b0b152eba9d4c Auto-Submitted: auto-generated The branch stable/13 has been updated by 0mp: URL: https://cgit.FreeBSD.org/src/commit/?id=7ee04c7b17d15e2296b796e1657b0b152eba9d4c commit 7ee04c7b17d15e2296b796e1657b0b152eba9d4c Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2025-07-12 16:20:32 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2025-07-30 09:55:30 +0000 rc: Use check_jail to check values of security.jail MIBs PR: 282404 Reviewed by: markj, netchild Approved by: markj (mentor) MFC after: 2 weeks Event: Berlin Hackathon 202507 Differential Revision: https://reviews.freebsd.org/D47329 (cherry picked from commit 46f18ecf8d3cdda1cd433841c44a4c1268ab9721) --- libexec/rc/rc | 4 ++-- libexec/rc/rc.d/hostname | 4 ++-- libexec/rc/rc.d/routing | 2 +- libexec/rc/rc.d/zfs | 8 ++++---- libexec/rc/rc.d/zfsbe | 2 +- libexec/rc/rc.shutdown | 4 ++-- libexec/rc/rc.subr | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libexec/rc/rc b/libexec/rc/rc index 7b750606022b..ab4a86c8e6b1 100644 --- a/libexec/rc/rc +++ b/libexec/rc/rc @@ -78,9 +78,9 @@ load_rc_config trap "_rc_conf_loaded=false; load_rc_config" ALRM skip="-s nostart" -if [ `/sbin/sysctl -n security.jail.jailed` -eq 1 ]; then +if check_jail jailed; then skip="$skip -s nojail" - if [ `/sbin/sysctl -n security.jail.vnet` -ne 1 ]; then + if ! check_jail vnet; then skip="$skip -s nojailvnet" fi fi diff --git a/libexec/rc/rc.d/hostname b/libexec/rc/rc.d/hostname index f6ac95c9c888..8c3fb23edd71 100755 --- a/libexec/rc/rc.d/hostname +++ b/libexec/rc/rc.d/hostname @@ -42,8 +42,8 @@ hostname_start() # If we are not inside a jail, set the host name. # If we are inside a jail, set the host name if it is permitted. # - if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then - if [ `$SYSCTL_N security.jail.set_hostname_allowed` -eq 0 ]; then + if check_jail jailed; then + if ! check_jail set_hostname_allowed; then return fi else diff --git a/libexec/rc/rc.d/routing b/libexec/rc/rc.d/routing index 9b906f69b354..a10b15958613 100755 --- a/libexec/rc/rc.d/routing +++ b/libexec/rc/rc.d/routing @@ -331,7 +331,7 @@ _check_dynamicrouting() # copied from /etc/rc skip="-s nostart" - if [ `/sbin/sysctl -n security.jail.jailed` -eq 1 ]; then + if check_jail jailed; then skip="$skip -s nojail" fi [ -n "$local_startup" ] && find_local_scripts_new diff --git a/libexec/rc/rc.d/zfs b/libexec/rc/rc.d/zfs index d7c5b20ee6d1..1e887c67f804 100755 --- a/libexec/rc/rc.d/zfs +++ b/libexec/rc/rc.d/zfs @@ -18,7 +18,7 @@ required_modules="zfs" zfs_start_jail() { - if [ `$SYSCTL_N security.jail.mount_allowed` -eq 1 ]; then + if check_jail mount_allowed; then zfs mount -a fi } @@ -34,7 +34,7 @@ zfs_start_main() zfs_start() { - if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then + if check_jail jailed; then zfs_start_jail else zfs_start_main @@ -54,7 +54,7 @@ zfs_poststart() zfs_stop_jail() { - if [ `$SYSCTL_N security.jail.mount_allowed` -eq 1 ]; then + if check_jail mount_allowed; then zfs unmount -a fi } @@ -67,7 +67,7 @@ zfs_stop_main() zfs_stop() { - if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then + if check_jail jailed; then zfs_stop_jail else zfs_stop_main diff --git a/libexec/rc/rc.d/zfsbe b/libexec/rc/rc.d/zfsbe index 216eb828e13c..1b4752f56c80 100755 --- a/libexec/rc/rc.d/zfsbe +++ b/libexec/rc/rc.d/zfsbe @@ -64,7 +64,7 @@ activate_bootonce() be_start() { - if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then + if check_jail jailed; then : else mount -p | while read _dev _mp _type _rest; do diff --git a/libexec/rc/rc.shutdown b/libexec/rc/rc.shutdown index 18f67f5ca124..3dfd7a7e0936 100644 --- a/libexec/rc/rc.shutdown +++ b/libexec/rc/rc.shutdown @@ -83,9 +83,9 @@ fi # and perform the operation # rcorder_opts="-k shutdown" -if [ `/sbin/sysctl -n security.jail.jailed` -eq 1 ]; then +if check_jail jailed; then rcorder_opts="$rcorder_opts -s nojail" - if [ `/sbin/sysctl -n security.jail.vnet` -ne 1 ]; then + if ! check_jail vnet; then rcorder_opts="$rcorder_opts -s nojailvnet" fi fi diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr index 6a10dcc8e01f..eaaa3c778bff 100644 --- a/libexec/rc/rc.subr +++ b/libexec/rc/rc.subr @@ -1294,7 +1294,7 @@ $command $rc_flags $command_args" start) # We cannot use protect(1) inside jails. if [ -n "$_oomprotect" ] && [ -f "${PROTECT}" ] && - [ "$(sysctl -n security.jail.jailed)" -eq 0 ]; then + ! check_jail jailed; then [ -z "${rc_pid}" ] && eval $_pidcmd case $_oomprotect in [Aa][Ll][Ll])