The branch main has been updated by sjg:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=15483f96207de354714fc61f20cdbf971706e6cb

commit 15483f96207de354714fc61f20cdbf971706e6cb
Author:     Simon J. Gerraty <[email protected]>
AuthorDate: 2024-02-10 18:14:23 +0000
Commit:     Simon J. Gerraty <[email protected]>
CommitDate: 2024-02-10 18:14:23 +0000

    rc.subr avoid noise if /usr not mounted
    
    basename, sed and tty are all in /usr/bin and not available
    until /usr is mounted.
    
    basename and tty we can replace with a function, but sed is more
    important.  Fix o_verify to just use shell builtins, and
    rc_trace should avoid trying to set RC_LEVEL until sed is available.
---
 libexec/rc/rc.subr | 35 +++++++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr
index 19955fa83fbd..d76f0ba4f9a7 100644
--- a/libexec/rc/rc.subr
+++ b/libexec/rc/rc.subr
@@ -82,7 +82,10 @@ _VDOT_SH=:
 # current state of O_VERIFY
 o_verify()
 {
-       set -o | sed -n '/^verify/s,.*[[:space:]],,p'
+       case $(echo $(set -o)) in
+       *verify" "off*) echo off;;
+       *verify" "on*) echo on;;
+       esac
 }
 
 ##
@@ -174,9 +177,15 @@ rc_trace()
 
        if [ -z "$RC_LEVEL" ]; then
                [ -f $cf ] || return
-               [ -s $cf ] && \
-               RC_LEVEL=$(sed -n '/^RC_LEVEL=/ { s/.*=//p;q; }' $cf)
-               RC_LEVEL=${RC_LEVEL:-0}
+               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)
+                               RC_LEVEL=${RC_LEVEL:-0}
+                       fi
+               else
+                       RC_LEVEL=0
+               fi
        fi
        [ ${RC_LEVEL:-0} -ge ${level:-0} ] || return
        rc_log "$@"
@@ -2493,8 +2502,22 @@ fi
 # Use vdot to ensure the file has not been tampered with.
 vdot /etc/local.rc.subr
 
-# safe_eval.sh provides safe_dot - for untrusted files
-$_SAFE_EVAL_SH vdot /libexec/safe_eval.sh
+# Avoid noise - when we do not have /usr mounted,
+# and we cannot use safe_dot without sed.
+if ! have basename; then
+       basename()
+       {
+               local b=${1%$2}
+               echo ${b##*/}
+       }
+       tty()
+       {
+               return 0
+       }
+else
+       # safe_eval.sh provides safe_dot - for untrusted files
+       $_SAFE_EVAL_SH vdot /libexec/safe_eval.sh
+fi
 $_DEBUG_SH vdot /libexec/debug.sh
 
 # Ensure we can still operate if debug.sh and

Reply via email to