Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177741332
D61740.1795175452.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
7 KB
Referenced Files
None
Subscribers
None
D61740.1795175452.diff
View Options
diff --git a/usr.sbin/sysrc/sysrc b/usr.sbin/sysrc/sysrc
--- a/usr.sbin/sysrc/sysrc
+++ b/usr.sbin/sysrc/sysrc
@@ -16,7 +16,7 @@
#
# Version information
#
-SYSRC_VERSION="8.9 Nov-18,2026"
+SYSRC_VERSION="9.0 Nov-18,2026"
#
# Options
@@ -326,6 +326,7 @@
#
files=
[ $# -eq 0 ] && files=$( f_sysrc_get rc_conf_files )
+ set -f # noglob
for file in $files; do
if [ "$EXISTING_ONLY" ]; then
[ -e "$file" -a ! -d "$file" ] || continue
@@ -335,6 +336,7 @@
esac
list="$list $file"
done
+ set +f # glob
list="${list# }"
if [ $# -eq 0 ]; then
if [ "$VERBOSE" ]; then
@@ -355,6 +357,7 @@
for service in ${*:-$( service -l )}; do
slist=
f_sysrc_service_configs $service files || retval=$? continue
+ set -f # noglob
for file in $files; do
if [ "$EXISTING_ONLY" ]; then
[ -e "$file" -a ! -d "$file" ] || continue
@@ -367,6 +370,7 @@
fi
slist="$slist $file"
done
+ set +f # glob
slist="${slist# }"
if [ $# -gt 0 ]; then
[ "$slist" ] || retval=$?
@@ -376,9 +380,11 @@
elif [ "$SHOW_EQUALS" ]; then
[ "$slist" ] && shell_fmt "$service=%s\n" "$slist"
else
+ set -f # noglob
for item in $slist; do
echo "$item"
done
+ set +f # glob
fi
done
@@ -446,9 +452,11 @@
else
list=$( f_sysrc_get rc_conf_files )
fi
+ set -f # noglob
for item in $list; do
echo "$item"
done
+ set +f # glob
exit $SUCCESS
fi
@@ -462,7 +470,8 @@
#
errmsg="Exiting due to previous syntax errors"
if [ "${RC_CONFS+set}" ]; then
- ( for i in $RC_CONFS; do
+ ( set -f # noglob
+ for i in $RC_CONFS; do
[ -e "$i" ] || continue
/bin/sh -n "$i" || exit $FAILURE
done
@@ -471,6 +480,7 @@
else
/bin/sh -n "$RC_DEFAULTS" || die "$errmsg"
( . "$RC_DEFAULTS"
+ set -f # noglob
for i in $rc_conf_files; do
[ -e "$i" ] || continue
/bin/sh -n "$i" || exit $FAILURE
@@ -684,7 +694,9 @@
rc_conf_files="${rc_conf_files% }"
fi
+ set -f # noglob
source_rc_confs
+ set +f # glob
#
# If passed `-a' (rather than `-A'), remove
diff --git a/usr.sbin/sysrc/sysrc.subr b/usr.sbin/sysrc/sysrc.subr
--- a/usr.sbin/sysrc/sysrc.subr
+++ b/usr.sbin/sysrc/sysrc.subr
@@ -832,6 +832,7 @@
{
local OPTIND=1 OPTARG __flag __append= __prepend=
local __local_startup __dir __spath __stype __names=
+ local __noglob=
while getopts ap __flag; do
case "$__flag" in
@@ -844,12 +845,18 @@
[ $# -gt 0 ] || return $FAILURE
local __sname="$1" __var_to_set="$2"
+ case "$-" in
+ *f*) __noglob=1 ;;
+ esac
+
__local_startup=$( f_sysrc_get local_startup )
+ set -f # noglob
for __dir in /etc/rc.d $__local_startup; do
__spath="$__dir/$__sname"
[ -f "$__spath" -a -x "$__spath" ] || __spath= continue
break
done
+ [ "$noglob" ] || set +f # glob
[ "$__spath" ] || return $FAILURE
__stype=$( file -b "$__spath" 2> /dev/null )
@@ -876,6 +883,7 @@
esac
local __name __test_path __configs=
+ set -f # noglob
for __name in $__names; do
for __dir in /etc/rc.d $__local_startup; do
__test_path="${__dir%/rc.d}/rc.conf.d/$__name"
@@ -887,6 +895,7 @@
done
done
done
+ [ "$__noglob" ] || set +f # glob
__configs="${__configs# }"
if [ "$__var_to_set" ]; then
@@ -961,6 +970,7 @@
local rc_conf_files="$( f_sysrc_get rc_conf_files )"
local conf_files=
local file
+ local noglob=
# Check parameters
case "$varname" in
@@ -973,6 +983,15 @@
#
[ "${RC_CONFS+set}" ] && rc_conf_files="$RC_CONFS"
+ #
+ # Determine if caller has set noglob before we disable filename
+ # globbing, so we can later return to the inherited state.
+ #
+ case "$-" in
+ *f*) __noglob=1 ;;
+ esac
+ set -f # noglob
+
#
# Reverse the order of files in rc_conf_files (the boot process sources
# these in order, so we will search them in reverse-order to find the
@@ -996,10 +1015,12 @@
[ -f "$file" -a -r "$file" ] || continue
if grep -Eq "$regex" $file; then
echo $file
+ [ "$noglob" ] || set +f # glob
return $SUCCESS
fi
done
+ [ "$noglob" ] || set +f # glob
return $FAILURE # Not found
}
@@ -1163,8 +1184,15 @@
#
if [ "$not_found" ]; then
# Add a newline if missing before appending to the file
- [ ! -e "$file" ] || awk 'BEGIN { wc = 0 } NR == 1 {
- (cmd = "wc -l " FILENAME) | getline
+ [ ! -e "$file" ] || awk '
+ BEGIN {
+ wc = 0
+ sq = "\047"
+ }
+ NR == 1 {
+ file = FILENAME
+ gsub(sq, sq "\\" sq sq, file)
+ (cmd = "wc -l " sq file sq) | getline
close(cmd)
wc = $1
} END { exit wc != NR }' "$file" ||
@@ -1198,8 +1226,9 @@
# temporary file over the destination, the destination will inherit the
# permissions from the temporary file).
#
- local mode
- f_eval_catch -dk mode $funcname stat 'stat -f "%%#Lp" "%s"' "$file" ||
+ local _file mode
+ f_shell_escape "$file" _file
+ f_eval_catch -dk mode $funcname stat "stat -f '%%#Lp' '%s'" "$_file" ||
mode=0644
f_eval_catch -d $funcname chmod 'chmod "%s" "%s"' "$mode" "$tmpfile"
@@ -1210,7 +1239,7 @@
#
local owner
f_eval_catch -dk owner $funcname stat \
- 'stat -f "%%u:%%g" "%s"' "$file" || owner="root:wheel"
+ "stat -f '%%u:%%g' '%s'" "$_file" || owner="root:wheel"
f_eval_catch -d $funcname chown 'chown "%s" "%s"' "$owner" "$tmpfile"
#
@@ -1245,7 +1274,7 @@
#
# Finally, move the temporary file into place.
#
- f_eval_catch -de $funcname mv 'mv "%s" "%s"' "$tmpfile" "$file"
+ f_eval_catch -de $funcname mv "mv '%s' '%s'" "$tmpfile" "$_file"
}
# f_sysrc_delete $varname
@@ -1278,7 +1307,8 @@
{
local funcname=f_sysrc_delete
local varname="$1"
- local file
+ local file _file
+ local noglob=
# Check arguments
[ "$varname" ] || return $FAILURE
@@ -1287,8 +1317,13 @@
# Operate on each of the specified files
#
local tmpfile
+ case "$-" in
+ *f*) noglob=1 ;;
+ esac
+ set -f # noglob
for file in ${RC_CONFS-$( f_sysrc_get rc_conf_files )}; do
[ -e "$file" ] || continue
+ f_shell_escape "$file" _file
#
# Create a new temporary file to write to.
@@ -1297,6 +1332,7 @@
'mktemp -t "%s"' "$pgm"
then
echo "$tmpfile" >&2
+ [ "$noglob" ] || set +f # glob
return $FAILURE
fi
@@ -1306,9 +1342,9 @@
#
local mode owner
f_eval_catch -dk mode $funcname stat \
- 'stat -f "%%#Lp" "%s"' "$file" || mode=0644
+ "stat -f '%%#Lp' '%s'" "$_file" || mode=0644
f_eval_catch -dk owner $funcname stat \
- 'stat -f "%%u:%%g" "%s"' "$file" || owner="root:wheel"
+ "stat -f '%%u:%%g' '%s'" "$_file" || owner="root:wheel"
f_eval_catch -d $funcname chmod \
'chmod "%s" "%s"' "$mode" "$tmpfile"
f_eval_catch -d $funcname chown \
@@ -1334,6 +1370,7 @@
f_err "$msg_previous_syntax_errors\n" \
"$pgm" "$file"
rm -f "$tmpfile"
+ [ "$noglob" ] || set +f # glob
return $FAILURE
fi
@@ -1343,14 +1380,19 @@
if [ ! -w "$file" ]; then
f_err "$msg_permission_denied\n" "$pgm" "$file"
rm -f "$tmpfile"
+ [ "$noglob" ] || set +f # glob
return $FAILURE
fi
#
# Finally, move the temporary file into place.
#
- f_eval_catch -de $funcname mv \
- 'mv "%s" "%s"' "$tmpfile" "$file" || return $FAILURE
+ if ! f_eval_catch -de $funcname mv \
+ "mv '%s' '%s'" "$tmpfile" "$_file"
+ then
+ [ "$noglob" ] || set +f
+ return $FAILURE
+ fi
done
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 20, 11:50 AM (9 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41864138
Default Alt Text
D61740.1795175452.diff (7 KB)
Attached To
Mode
D61740: sysrc: Support special characters in file names
Attached
Detach File
Event Timeline