On Sun, Oct 28, 2018 at 05:21:38PM +0100, Antoine Jacoutot wrote:
> 
> Thinking about it I wonder if this shouldn't just be "fixed" in the rc.d
> script itself.

it could, but I am expecting some others rc.d files to need the same
"fix".

> Manually running pg_ctl as root (from /root for example) would fail the same
> way. So I think it's more an issue with the way pg_ctl works.

no. pg_ctl failed because it is run as "_postgresql" under /root.

# id
uid=0(root) gid=0(wheel) groups=0(wheel), 2(kmem), 3(sys), 4(tty), 5(operator), 
20(staff), 31(guest)
# cd /root && pg_ctl reload
pg_ctl: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.

> Thoughts?

I am a bit shared.

I think it could be fixed in rc_subr in two ways:
- by adding something in rcexec variable to perform the chdir
- by forcing a `cd /' in /etc/rc.d/rc_subr (and makes the whole rc.d
  script executed in /)

for (1), it needs a program that will change the directory and exec
another program (or an option on su, sh, env). using rcexec="chroot / ${rcexec}"
is a possibility, but it seems wrong to me to use chroot for this
purpose.

for (2), it could be done by adding "cd /" after FUNCS_ONLY check. but I
am unsure if it could trigger some side-effects.

-- 
Sebastien Marie

Reply via email to