Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F171395679
D43826.id134114.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D43826.id134114.diff
View Options
diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr
--- a/libexec/rc/rc.subr
+++ b/libexec/rc/rc.subr
@@ -156,6 +156,33 @@
return $rc
}
+# Exists [test] file ...
+# report the first "file" that passes "test" (default -s).
+Exists()
+{
+ local f _t=-s
+
+ while :; do
+ : 1=$1
+ case "$1" in
+ -?)
+ _t=$1
+ shift
+ ;;
+ *)
+ break
+ ;;
+ esac
+ done
+
+ for f in "$@"; do
+ [ $_t $f ] || continue
+ echo $f
+ return 0
+ done
+ return 1
+}
+
# do we have $1 (could be a function)
have()
{
@@ -179,8 +206,9 @@
[ -f $cf ] || return
if [ -s $cf ]; then
# don't try to set RC_LEVEL without sed
- if [ -x /usr/bin/sed ]; then
- RC_LEVEL=$(sed -n '/^RC_LEVEL=/ { s/.*=//p;q; }' $cf)
+ SED=${SED:-`Exists -x /usr/bin/sed /rescue/sed`}
+ if [ -n "$SED" ]; then
+ RC_LEVEL=$($SED -n '/^RC_LEVEL=/ { s/.*=//p;q; }' $cf)
RC_LEVEL=${RC_LEVEL:-0}
fi
else
@@ -2514,10 +2542,12 @@
{
return 0
}
-else
- # safe_eval.sh provides safe_dot - for untrusted files
- $_SAFE_EVAL_SH vdot /libexec/safe_eval.sh
+ SED=${SED:-`Exists -x /usr/bin/sed /rescue/sed`}
+ # we cannot use safe_dot without sed
+ [ -z "$SED" ] && _SAFE_EVAL_SH=:
fi
+# safe_eval.sh provides safe_dot - for untrusted files
+$_SAFE_EVAL_SH vdot /libexec/safe_eval.sh
$_DEBUG_SH vdot /libexec/debug.sh
# Ensure we can still operate if debug.sh and
diff --git a/libexec/rc/safe_eval.sh b/libexec/rc/safe_eval.sh
--- a/libexec/rc/safe_eval.sh
+++ b/libexec/rc/safe_eval.sh
@@ -24,7 +24,7 @@
# any non-alphanumeric chars are replaced with '_'
#
safe_set() {
- sed 's/[ ]*#.*//;/^[A-Za-z_][A-Za-z0-9_]*=/!d;s;[^A-Za-z0-9_. "$,/=-];_;g'
+ ${SED:-sed} 's/[ ]*#.*//;/^[A-Za-z_][A-Za-z0-9_]*=/!d;s;[^A-Za-z0-9_. "$,/=-];_;g'
}
##
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Sep 11, 9:53 PM (5 h, 49 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38735520
Default Alt Text
D43826.id134114.diff (1 KB)
Attached To
Mode
D43826: rc.subr add Exists so we can find sed
Attached
Detach File
Event Timeline
Log In to Comment