From nobody Tue Sep 15 20:53:12 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 4hkvPB0gWzz6rX5B for ; Tue, 15 Sep 2026 20:53:18 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hkvP97095z4HGm for ; Tue, 15 Sep 2026 20:53:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789505598; 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=BCDzxwWD1jbXcCzDX6nac/w3/LTwyUq99X5EVFIEoQI=; b=KISYQbzsNAXJsgvUDAuawNAePO0BlHXMl5SrDIpP5pbAINBa/06wZwJRpD9ofy674pK448 QIQ+B8BMiXooehKUYIRKCu21h6AY+5dci7N4hQju2u7FVw4PxATOMM80EPqOzPT/n6yvzp sIGfrCovE5Yl7+l2yEW0oqX1OSDS9LzowsH8IchgSRp0aFbB6VXSs9fdSvUS5o7AXTptQ/ TXBo0gDa1apmopvHPsJwkuHhmc/sqyjjdb1Gv5XDVWCStooVCt2U9Tc8JKuR+TbOuekfw5 nMY0OKaLvIdv3FU6PRWHBUI+ZpMtcGU0W8ve2L+3LYeh50stGkfvmCqwQaJ80Q== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1789505598; b=X/tCea5g8ZjCSNWMYx1cWl/wIt87T3ky00Kp9wdnS5bWIYkJGn5KxFSlYLi7Q5BRZSwJv3 iAmXdPFdQB7F71BVPnVv84ohAssgH5NfxAIm+L3bdIKO1ohKDwQQ+XGwyrMgJjv/cqnLrP W0nTFw69JtT048VW7xipic6pSnGxRfN7TJhFvFXMqNhXqi51MOWNaY+u67TyF1iLgEVWKK TalqkhXZJyGfm0K0OhFJoHb6fdAHhEoDHpHbXrR9BJ3cdUJwVTnrqE7YsPpPYoCvBNbzm1 8Ud+VbOMiBX1qEh615zZr6zpDiURYS2cdcSGLmtN1Was0x8//XqnZmdCSEllvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789505598; 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=BCDzxwWD1jbXcCzDX6nac/w3/LTwyUq99X5EVFIEoQI=; b=YgMw0WcH9nnVkzsKdfrt5+2taPCcG/LIuSn6K/l7Mi3Xu0+U3/QdCssfC9xmyr0LHvtPLf oeFPoQ3DPxZZXX/kbQRWp/3pOzt9R334VQ8EGmOHs4DpHwi0NpG/H02rTnJjLnmY//mmMa 1scX2moeNdcbr+M0uZy37BkWXeeFlYI+dXnC2kuB8KGLdJKuXxqQJWFdDWuy8C16N/9yYR Wg+LG0DfurswJUtkkKrZUWAv1xirIzGJq7+//jFNBg5U85DagjegxErsr+/X2kcw7UKEMM GtLPBlbFEq3uWfsmmkEnABUue2zoJjK+rM+M7aNhHNAp8BWma9guapvjfNFVrw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hkvP964BBzFl6 for ; Tue, 15 Sep 2026 20:53:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 338f3 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 15 Sep 2026 20:53:12 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Devin Teske Subject: git: 09711ccb09f4 - main - Remove source_rc_confs, inlined from defaults/rc.conf 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: dteske X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 09711ccb09f482fd345b2b640dbbeb66de535041 Auto-Submitted: auto-generated Date: Tue, 15 Sep 2026 20:53:12 +0000 Message-Id: <6aa9b038.338f3.46192136@gitrepo.freebsd.org> The branch main has been updated by dteske: URL: https://cgit.FreeBSD.org/src/commit/?id=09711ccb09f482fd345b2b640dbbeb66de535041 commit 09711ccb09f482fd345b2b640dbbeb66de535041 Author: Devin Teske AuthorDate: 2026-09-15 20:50:20 +0000 Commit: Devin Teske CommitDate: 2026-09-15 20:50:20 +0000 Remove source_rc_confs, inlined from defaults/rc.conf Inlining source_rc_confs broke sysrc_test:A_flag While here, switch to SPDX, bump version/copyrights, fixup comments. Prevent common function override when bsdconfig includes new sysrc.subr that contains inlined commons. Fix non-unique duplicate header variable incorrectly shared between bsdconfig's sysrc.subr include and new sysrc.subr include. Harden RC_DEFAULTS parameter expansion from DoS-via-glob (SC2223). Move pgm to the correct location to not override bsdconfig's pgm. Drop _SYSRC_JAILED=1 that is no-longer needed. Drop i18n from jail_depend now that messages are inlined to subr. Reported by: siva Fixes: eaeb5f29bc6f sysrc: make independant from bsdconfig(8) --- usr.sbin/bsdconfig/share/sysrc.subr | 13 ++--- usr.sbin/sysrc/sysrc | 62 ++++----------------- usr.sbin/sysrc/sysrc.subr | 108 ++++++++++-------------------------- 3 files changed, 45 insertions(+), 138 deletions(-) diff --git a/usr.sbin/bsdconfig/share/sysrc.subr b/usr.sbin/bsdconfig/share/sysrc.subr index eee489f4cc50..02bc96fd4fee 100644 --- a/usr.sbin/bsdconfig/share/sysrc.subr +++ b/usr.sbin/bsdconfig/share/sysrc.subr @@ -1,6 +1,6 @@ -if [ ! "$_SYSRC_SUBR" ]; then _SYSRC_SUBR=1 +if [ ! "$_BSDCONFIG_SYSRC_SUBR" ]; then _BSDCONFIG_SYSRC_SUBR=1 # -# Copyright (c) 2006-2015 Devin Teske +# Copyright (c) 2006-2026 Devin Teske # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -24,6 +24,7 @@ if [ ! "$_SYSRC_SUBR" ]; then _SYSRC_SUBR=1 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # +############################################################ INFORMATION # # Compatibility shim: sources the canonical sysrc.subr from /usr/share/sysrc/ # and loads bsdconfig-specific i18n messages afterward. @@ -36,13 +37,11 @@ BSDCFG_SHARE="/usr/share/bsdconfig" f_include /usr/share/sysrc/sysrc.subr BSDCFG_LIBE="/usr/libexec/bsdconfig" -if [ ! "$_SYSRC_JAILED" ]; then - f_dprintf "%s: loading includes..." sysrc.subr - f_include_lang $BSDCFG_LIBE/include/messages.subr -fi +f_dprintf "%s: loading includes..." sysrc.subr +f_include_lang $BSDCFG_LIBE/include/messages.subr ############################################################ MAIN f_dprintf "%s: Successfully loaded." sysrc.subr -fi # ! $_SYSRC_SUBR +fi # ! $_BSDCONFIG_SYSRC_SUBR diff --git a/usr.sbin/sysrc/sysrc b/usr.sbin/sysrc/sysrc index bd3faeac8ed3..21a17a7b761b 100644 --- a/usr.sbin/sysrc/sysrc +++ b/usr.sbin/sysrc/sysrc @@ -1,29 +1,8 @@ #!/bin/sh -#- -# Copyright (c) 2010-2018 Devin Teske -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. # +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2010-2026 Devin Teske # ############################################################ INCLUDES @@ -32,10 +11,12 @@ SYSRC_SHARE="/usr/share/sysrc" ############################################################ GLOBALS +pgm="${0##*/}" # Program basename + # # Version information # -SYSRC_VERSION="7.2 Jun-16,2018" +SYSRC_VERSION="7.3 Sep-15,2026" # # Options @@ -171,35 +152,14 @@ help() # jail_depend # -# Dump dependencies such as language-file variables and include files to stdout -# to be piped-into sh(1) running via jexec(8)/chroot(8). As a security measure, -# this prevents existing language files and library files from being loaded in -# the jail. This also relaxes the requirement to have these files in every jail -# before sysrc can be used on said jail. +# Dump dependencies such as include files to stdout to be piped-into sh(1) +# running via jexec(8)/chroot(8). As a security measure, this prevents existing +# library files from being loaded in the jail. This also relaxes the +# requirement to have these files in every jail before sysrc can be used on +# said jail. # jail_depend() { - # - # Indicate that we are jailed - # - echo export _SYSRC_JAILED=1 - - # - # Print i18n language variables (their current values are sanitized - # and re-printed for interpretation so that the i18n language files - # do not need to exist within the jail). - # - local var val - for var in \ - msg_cannot_create_permission_denied \ - msg_permission_denied \ - msg_previous_syntax_errors \ - ; do - val=$( eval echo \"\$$var\" | - awk '{ gsub(/'\''/, "'\''\\'\'\''"); print }' ) - echo $var="'$val'" - done - # # Print include dependencies # diff --git a/usr.sbin/sysrc/sysrc.subr b/usr.sbin/sysrc/sysrc.subr index 63c92843c672..0396628c929f 100644 --- a/usr.sbin/sysrc/sysrc.subr +++ b/usr.sbin/sysrc/sysrc.subr @@ -1,29 +1,10 @@ if [ ! "$_SYSRC_SUBR" ]; then _SYSRC_SUBR=1 # -# Copyright (c) 2006-2015 Devin Teske -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. +# SPDX-License-Identifier: BSD-2-Clause # +# Copyright (c) 2006-2026 Devin Teske +# +############################################################ INFORMATION # # This file was split-out of bsdconfig(8) and is now self-contained, and is # no longer dependent on bsdconfig(8) or any of its libraries. @@ -33,7 +14,7 @@ if [ ! "$_SYSRC_SUBR" ]; then _SYSRC_SUBR=1 # # Standard pathnames (inherit values from shell if available) # -: ${RC_DEFAULTS:="/etc/defaults/rc.conf"} +: "${RC_DEFAULTS:=/etc/defaults/rc.conf}" ############################################################ GLOBALS @@ -44,12 +25,7 @@ SUCCESS=0 FAILURE=1 # -# Program name (derived from the running script) -# -pgm="${0##*/}" - -# -# Error messages. +# Error messages # msg_cannot_create_permission_denied="%s: cannot create %s: Permission denied" msg_permission_denied="%s: %s: Permission denied" @@ -68,24 +44,28 @@ VALID_VARNAME_CHARS="0-9ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_" ############################################################ FUNCTIONS -# f_err $format [$arguments ...] -# -# Print a message to stderr (fd=2). -# -f_err() -{ - printf "$@" >&2 -} - # f_have $anything ... # # A wrapper to the `type' built-in. Returns true if argument is a valid shell # built-in, keyword, or externally-tracked binary, otherwise false. # +if ! type f_have > /dev/null 2>&1; then f_have() { type "$@" > /dev/null 2>&1 } +fi + +# f_err $format [$arguments ...] +# +# Print a message to stderr (fd=2). +# +if ! f_have f_err; then +f_err() +{ + printf "$@" >&2 +} +fi # setvar $var_to_set [$value] # @@ -125,8 +105,10 @@ fi # Returns error status if the requested variable ($var_to_get) is not set. # # If $var_to_set is missing or NULL, the value of $var_to_get is printed to -# standard output for capturing in a sub-shell. +# standard output for capturing in a sub-shell (which is less-recommended +# because of performance degredation; for example, when called in a loop). # +if ! f_have f_getvar; then f_getvar() { local __var_to_get="$1" __var_to_set="$2" @@ -137,21 +119,22 @@ f_getvar() [ "$__var_to_set" ] || { [ "$value" ] && echo "$value"; } return $__retval } +fi -# f_eval_catch [ -d ] [ -e ] [ -k $var_to_set ] $funcname $utility \ +# f_eval_catch [-de] [-k $var_to_set] $funcname $utility \ # $printf_format [$printf_args ...] # # Evaluate the printf-rendered command line and capture its output. The return # status of the command is preserved. If `-k' is given, output is stored in # $var_to_set. If `-e' is given, output is echoed to stderr on failure. # +if ! f_have f_eval_catch; then f_eval_catch() { local OPTIND OPTARG __flag __show_err= __var_to_set= while getopts "dek:" __flag > /dev/null; do case "$__flag" in - d) : # no-op: always non-interactive here - ;; + d) : ;; # no-op: always non-interactive here e) __show_err=1 ;; k) __var_to_set="$OPTARG" ;; esac @@ -170,44 +153,9 @@ f_eval_catch() [ "$__var_to_set" ] && setvar "$__var_to_set" "$__output" return $__retval } +fi -# source_rc_confs -# -# Source the rc.conf(5) override files (as defined in rc.conf(5)), preserving -# the semantics used by /etc/rc.* at boot-time. -# -source_rc_confs() -{ - local i sourced_files - for i in ${rc_conf_files}; do - case ${sourced_files} in - *:$i:*) - ;; - *) - sourced_files="${sourced_files}:$i:" - if [ -r $i ]; then - . $i - fi - ;; - esac - done - # Re-do process to pick up [possibly] redefined $rc_conf_files - for i in ${rc_conf_files}; do - case ${sourced_files} in - *:$i:*) - ;; - *) - sourced_files="${sourced_files}:$i:" - if [ -r $i ]; then - . $i - fi - ;; - esac - done -} - - -# f_clean_env [ --except $varname ... ] +# f_clean_env [--except $varname ...] # # Unset all environment variables in the current scope. An optional list of # arguments can be passed, indicating which variables to avoid unsetting; the