On Tue, May 17, 2022 at 09:12:08AM +0200, Antoine Jacoutot wrote:
> Hi folks.
>
> I would like to move away from the rc_exec variable to an rcexec() function
> for
> rc.d scripts.
> That will allow daemon_logger to work out of the box even for manually
> crafted rc_start() functions.
> I will also simplify the addition of new features like daemon_startdir.
>
> I have tested this with a few daemons only.
> So I am calling for testing this diff on your own setup to detect any possible
> regression (especially for daemons with a complex starting sequence).
> To test, just apply the diff to rc.subr and replace ${rcexec} with rc_exec in
> your rc.d scripts.
>
> As I don't want to spam the list, please report OK tests directly to me and
> KO ones to the list.
>
> Thanks a lot!
FYI I intend to commit this over the week-end.
Best way to get test reports I guess.
> Index: rc.subr
> ===================================================================
> RCS file: /cvs/src/etc/rc.d/rc.subr,v
> retrieving revision 1.152
> diff -u -p -r1.152 rc.subr
> --- rc.subr 10 Feb 2022 16:57:33 -0000 1.152
> +++ rc.subr 17 May 2022 07:05:57 -0000
> @@ -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,3 @@ unset _rcflags _rclogger _rcrtable _rcti
> # 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}"
>
>
> --
> Antoine
>
--
Antoine