Hello,

I would guess the main reason is privilege separation. There will be
privileged (owner root) and unprivileged (dedicated user) processess and
both needs to be killed.

--
Kind regards,
Ville Valkonen

On Fri 26. Nov 2021 at 2.24, Vincent Lee <vinc...@vincent-lee.net> wrote:

> Hey all,
>
> I noticed that rc.subr(8)'s invocations of pgrep(1) and pkill(1) don't
> filter by the user (by passing -U or -u). I'm wondering if there's a
> reason for this?
>
> The reason is that I'm running thelounge (thelounge.chat). It's a NodeJS
> application, and by default its command line shows in top(1) as
> "node". I know that I can set `pexp` in my rc script, but setting it to
> just "node" without filtering by user seems overly broad, in case other
> node binaries are running as other users.
>
> I know I can also override rc_check and friends entirely in the rc
> script, but this seems like something that most rc scripts can benefit
> from.
>
> Here's a diff that makes the change, but let me know if this wasn't done
> for any reason or other ways I can get around this problem. Thanks!
>
> diff --git etc/rc.d/rc.subr etc/rc.d/rc.subr
> index 2af4887d1..addc6f95d 100644
> --- etc/rc.d/rc.subr
> +++ etc/rc.d/rc.subr
> @@ -144,7 +144,7 @@ _rc_alarm()
>  }
>
>  _rc_sendsig() {
> -       pkill -${1:-TERM} -T "${daemon_rtable}" -xf "${pexp}"
> +       pkill -${1:-TERM} -T "${daemon_rtable}" -U "${daemon_user}" -xf
> "${pexp}"
>  }
>
>  _rc_wait_for_start() {
> @@ -165,7 +165,7 @@ rc_start() {
>  }
>
>  rc_check() {
> -       pgrep -T "${daemon_rtable}" -q -xf "${pexp}"
> +       pgrep -T "${daemon_rtable}" -U "${daemon_user}" -q -xf "${pexp}"
>  }
>
>  rc_reload() {
>
>

Reply via email to