summaryrefslogtreecommitdiff
path: root/etc/rc.d/rc.subr
diff options
context:
space:
mode:
Diffstat (limited to 'etc/rc.d/rc.subr')
-rw-r--r--etc/rc.d/rc.subr20
1 files changed, 14 insertions, 6 deletions
diff --git a/etc/rc.d/rc.subr b/etc/rc.d/rc.subr
index 3ad058c56cd..ef2b6d6f49b 100644
--- a/etc/rc.d/rc.subr
+++ b/etc/rc.d/rc.subr
@@ -1,6 +1,6 @@
-# $OpenBSD: rc.subr,v 1.153 2022/05/21 10:50:09 ajacoutot Exp $
+# $OpenBSD: rc.subr,v 1.154 2022/05/26 11:27:03 ajacoutot Exp $
#
-# Copyright (c) 2010, 2011, 2014-2021 Antoine Jacoutot <ajacoutot@openbsd.org>
+# Copyright (c) 2010, 2011, 2014-2022 Antoine Jacoutot <ajacoutot@openbsd.org>
# Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
# Copyright (c) 2010, 2011, 2014 Robert Nagy <robert@openbsd.org>
#
@@ -49,7 +49,7 @@ _rc_parse_conf() {
while IFS=' ' read -r _l; do
[[ $_l == [!#=]*=* ]] || continue
_key=${_l%%*([[:blank:]])=*}
- [[ $_key == *_@(flags|logger|rtable|timeout|user) ]] ||
+ [[ $_key == *_@(execdir|flags|logger|rtable|timeout|user) ]] ||
[[ " ${_allowed_keys[*]} " == *" $_key "* ]] ||
continue
[[ $_key == "" ]] && continue
@@ -114,14 +114,17 @@ _rc_write_runfile() {
[ -d ${_RC_RUNDIR} ] || mkdir -p ${_RC_RUNDIR} &&
cat >${_RC_RUNFILE} <<EOF
daemon_class=${daemon_class}
+daemon_execdir=${daemon_execdir}
daemon_flags=${daemon_flags}
daemon_logger=${daemon_logger}
daemon_rtable=${daemon_rtable}
daemon_timeout=${daemon_timeout}
daemon_user=${daemon_user}
pexp=${pexp}
+rc_reload=${rc_reload}
rc_reload_signal=${rc_reload_signal}
rc_stop_signal=${rc_stop_signal}
+rc_usercheck=${rc_usercheck}
EOF
}
@@ -164,8 +167,11 @@ rc_exec() {
[ "${daemon_rtable}" -eq "$(id -R)" ] ||
_rcexec="route -T ${daemon_rtable} exec ${_rcexec}"
- ${_rcexec} "${daemon_logger:+set -o pipefail; }$@${daemon_logger:+ 2>&1 |
- logger -ip ${daemon_logger} -t ${_name}}"
+ ${_rcexec} "${daemon_logger:+set -o pipefail; } \
+ ${daemon_execdir:+cd ${daemon_execdir} && } \
+ $@ \
+ ${daemon_logger:+ 2>&1 |
+ logger -ip ${daemon_logger} -t ${_name}}"
}
rc_start() {
@@ -317,6 +323,7 @@ _rc_do _rc_parse_conf
rc_reload_signal=${rc_reload_signal:=HUP}
rc_stop_signal=${rc_stop_signal:=TERM}
+eval _rcexecdir=\${${_name}_execdir}
eval _rcflags=\${${_name}_flags}
eval _rclogger=\${${_name}_logger}
eval _rcrtable=\${${_name}_rtable}
@@ -334,6 +341,7 @@ getcap -f /etc/login.conf.d/${_name}:/etc/login.conf ${_name} 1>/dev/null 2>&1 &
[ -n "${_RC_FORCE}" -o "$1" != "start" ] && [ X"${_rcflags}" = X"NO" ] &&
unset _rcflags
+[ -n "${_rcexecdir}" ] && daemon_execdir=${_rcexecdir}
[ -n "${_rcflags}" ] && daemon_flags=${_rcflags}
[ -n "${_rclogger}" ] && daemon_logger=${_rclogger}
[ -n "${_rcrtable}" ] && daemon_rtable=${_rcrtable}
@@ -347,7 +355,7 @@ if [ -n "${_RC_DEBUG}" ]; then
fi
readonly daemon_class
-unset _rcflags _rclogger _rcrtable _rctimeout _rcuser
+unset _rcexecdir _rcflags _rclogger _rcrtable _rctimeout _rcuser
# the shell will strip the quotes from daemon_flags when starting a daemon;
# make sure pexp matches the process (i.e. doesn't include the quotes)
pexp="$(eval echo ${daemon}${daemon_flags:+ ${daemon_flags}})"