From nobody Wed Jul 30 09:55:40 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 4bsSJX4yJGz63RSx; Wed, 30 Jul 2025 09:55:40 +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 4bsSJX2XbNz499F; Wed, 30 Jul 2025 09:55:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753869340; 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=inM0EbDDz7hXWkxhI13nO/jpZKU5FCfFXnBzeqcv+WQ=; b=ddXqnPolq8NJzB6E5XkLR5Gc+xkG9jeO63KGgNBzgWe53LacJ9sKaYbzwcmt9SYYqIx6rb NwK2Mvub+6zO6A1x3i4TDmO4xKhKDPcqhoUNEYYRmlzQsGo1IyNTB3hnTO1DKFrxJyxIQL R9MeENsvjcnhXOyUYulIZpNy4Nduw1FQ0T9dJu2tbeWMhWancTd3SWYqCLT4lrIBEIMnrG P4vxnxlhkLkrMMle7KyPAnparCUoJLvZlBpW0WFne71lehHisV30jRg9dqIsinVGYDFXw6 VosL/Yu6jDbJSeS08L1lLYs+lGHyjKLOSRAkGNvKOb2dnTguo632tgb7OLCSrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753869340; 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=inM0EbDDz7hXWkxhI13nO/jpZKU5FCfFXnBzeqcv+WQ=; b=Q+pIe3GexapRMCpZcM84BC1oGnGj6/nCD+zuvQuM5SneENWrA/3hTtXSqD2/nyJxRd7AC9 U+uXY5IwBVks6oRTIH6bdJbIqwawJ34SwjimJNHJHEjzQ4OtKdBk++f4fJVbsI7wDDy7AW 0nWowAWS8CLk20frQ+reF4t+gV+LhjEK6yOlE2qTLq1thf6wCbDp+q3tCMTjt8Llz/SPnF DIZjQvpfyA2YiaG97xAAKY1rc/oYjQVP4MylcSUfI48/i19sI+TMT1Acha/sQmajAq2sqO 9+QSVCsBcTVOC/6+0EFvVcnoUZurNi16h/O4K7vf7qVVhO1RAZ6mzywVSlikSQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1753869340; a=rsa-sha256; cv=none; b=erl+BSH+fFMqPdZx7B/2dLcYNc7IRucnVFrQW1ZIEOKIZgj8yKYG5GunCHCILpZgRis90r 1CFPWBPdESUpw1+FPU7pRd4dfpNoWeYEUF+v5fVSBvuqknYqVHt2qEMgFySDUonnWVqlRf 54YO3tQFP43J4OdiqQ6chZop1cbutv0bmuZgfntz+eI6Msa+q/kWaDt1GBxiTA4KRAiVx1 MbgPXXPvm3oPbqsqQEsoC98JaWCmise7oNzXUtZJeAKw58ajsaiz41Ic3+jFDVxc5yu2Qw pF3Io1jE2PTaOPabj8gFD88mtoWqZiytmtg1oVFnocwxTMkitinn6W6UyXEO+Q== 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 4bsSJX24ycz19sS; Wed, 30 Jul 2025 09:55:40 +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 56U9tebP024704; Wed, 30 Jul 2025 09:55:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 56U9teRe024701; Wed, 30 Jul 2025 09:55:40 GMT (envelope-from git) Date: Wed, 30 Jul 2025 09:55:40 GMT Message-Id: <202507300955.56U9teRe024701@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: 943ad2ce5988 - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: 943ad2ce59887a63182e5e26ea6962e978ac59bd Auto-Submitted: auto-generated The branch stable/14 has been updated by 0mp: URL: https://cgit.FreeBSD.org/src/commit/?id=943ad2ce59887a63182e5e26ea6962e978ac59bd commit 943ad2ce59887a63182e5e26ea6962e978ac59bd 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:24 +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 462967703d60..ae1b24a6f36d 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 d7113eb90722..89a5620fb5df 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 31b0a180800f..5154a35377d0 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 61c10370250e..75110a0313cd 100644 --- a/libexec/rc/rc.subr +++ b/libexec/rc/rc.subr @@ -1314,7 +1314,7 @@ $_cpusetcmd $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])