Re: Possible problem with the ${name}_chdir variable behaviour in /etc/c.subr

From: Jilles Tjoelker <jilles_at_stack.nl>
Date: Sun, 20 Mar 2016 23:04:54 +0100
On Sun, Mar 20, 2016 at 05:51:30PM +0000, Tim Preston wrote:

> I was having a problem making the audio/teamspeak3-server port start
> fro the rc.d scripts on a  -current box that I’ve just built. I
> eventually traced this down to it not starting in the correct
> directory.

> Looking at the rc.d script I could see that it was attempting to chdir
> to  the correct directory by setting the teamspeak_chdir variable. So
> it looked like this feature was misbehaving in some way.

> To test this I put together an rc.d script for pwd that used
> ${name}_chdir based on how the teamspeak rc.d script was setup.
> Running this on a 10.3 box showed that it was changing to the
> specified directory as expected, but on -current it was not.

> I’ve taken a quick look at rc.subr on both boxes but I can’t
> immediately see what’s breaking this, and I can’t see anything in the
> setup or behaviour of the -current box that would point to it being
> something that I’ve broken somehow there.

> I was wondering if anyone else could reproduce this?

The NAME_chdir variable prepends 'cd $NAME_chdir && ' to the command at
a certain point. Prepending further commands like limits (as added by
SVN r288291) will not work properly. The older $NAME_prepend feature is
broken in the same way. The cd command is having the limits or similar
applied to it while the real command is running without proper limits
and current directory.

The NAME_user and NAME_nice variables use sh -c to avoid this problem
but it introduces double-quoting issues (i.e. using arguments containing
certain special characters requires an additional unexpected level of
quoting).

Prepending cd at a later time would avoid the problem with limits and
NAME_prepend and allow getting rid of sh -c, but would change the
directory as root so permission problems with NAME_user would be
detected later.

-- 
Jilles Tjoelker
Received on Sun Mar 20 2016 - 21:04:57 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:03 UTC