*-{up,down} env vars

Guus Sliepen guus at tinc-vpn.org
Fri Dec 13 23:31:27 CET 2013


On Fri, Dec 13, 2013 at 10:42:52AM -0300, Nicolás Reynolds wrote:

> hi!  yesterday i was adding "hooks" to librevpn's tools[0] and while
> debugging[1] why tinc would say the scripts exited with non zero status,
> i noticed the PWD wasn't set to what i expected (PWD=/ instead of
> PWD=/etc/tinc/$NETNAME).  the hooks/scripts dir is in scripts/ so
> running scripts/$event-* would fail because it'd look for them in
> /scripts/$event-*...
> 
> at first i guessed PWD is set to the HOME of the user tinc is running as
> (since "nobody" has HOME=/) but while running a debug session as root i
> noticed PWD=current/dir.
> 
> is this correct?  shouldn't tinc run scripts with a path relative to
> its configuration? :)

Tinc does not explicitly change the working directory, however when it is run
normally (without -D), it calls daemon() to go into the background, which in
turn changes the working directory to /.

It might indeed be nice to run the scripts with the working directory set to
the configuration directory. I don't think there is any argument against that.
In the mean time, the workaround is to call the following at the top of your
scripts:

cd `basename $0`

-- 
Met vriendelijke groet / with kind regards,
     Guus Sliepen <guus at tinc-vpn.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://www.tinc-vpn.org/pipermail/tinc/attachments/20131213/7f00dddd/attachment.sig>


More information about the tinc mailing list