summaryrefslogtreecommitdiff
path: root/etc/rc.d
diff options
context:
space:
mode:
authorAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2022-05-21 10:50:10 +0000
committerAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2022-05-21 10:50:10 +0000
commita871cb8e92fc9986d42a34a9e9b5d101b2b2f392 (patch)
tree2624edbde9f857f92bd0c3b35b258315e125d75b /etc/rc.d
parentdf3bbd868eab3e189579c7dad0fd62eb6c822bfe (diff)
Replace the $rcexec variable by an rc_exec function.
It is much cleaner to the eyes and makes more sense from a functionnal point of view. This will allow to extend rc_exec with other functionnalities (like upcoming rc_startdir). Bonus point: daemon_logger will now work with manually crafted rc_start functions. This will require a mechanical change from ${rcexec} to rc_exec in rc.d scripts. ports will be fixed right after this commit but we will keep compatibility to give a chance to people to fix their custom scripts. positive tests from a few ok robert@
Diffstat (limited to 'etc/rc.d')
-rw-r--r--etc/rc.d/rc.subr19
1 files changed, 13 insertions, 6 deletions
diff --git a/etc/rc.d/rc.subr b/etc/rc.d/rc.subr
index ed2adb6515e..3ad058c56cd 100644
--- a/etc/rc.d/rc.subr
+++ b/etc/rc.d/rc.subr
@@ -1,4 +1,4 @@
-# $OpenBSD: rc.subr,v 1.152 2022/02/10 16:57:33 robert Exp $
+# $OpenBSD: rc.subr,v 1.153 2022/05/21 10:50:09 ajacoutot Exp $
#
# Copyright (c) 2010, 2011, 2014-2021 Antoine Jacoutot <ajacoutot@openbsd.org>
# Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -159,11 +159,19 @@ _rc_wait_for_start() {
return
}
-rc_start() {
- ${rcexec} "${daemon_logger:+set -o pipefail; }${daemon} ${daemon_flags}${daemon_logger:+ 2>&1 |
+rc_exec() {
+ local _rcexec="su -fl -c ${daemon_class} -s /bin/sh ${daemon_user} -c"
+ [ "${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}}"
}
+rc_start() {
+ rc_exec "${daemon} ${daemon_flags}"
+}
+
rc_check() {
pgrep -T "${daemon_rtable}" -q -xf "${pexp}"
}
@@ -343,6 +351,5 @@ unset _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}})"
-rcexec="su -fl -c ${daemon_class} -s /bin/sh ${daemon_user} -c"
-[ "${daemon_rtable}" -eq "$(id -R)" ] ||
- rcexec="route -T ${daemon_rtable} exec ${rcexec}"
+# XXX old construct compatibility; remove after OPENBSD_7_2_RELEASE
+rcexec=rc_exec