Re: dhclient-script, hooks, and changing the environment
On Wed, Aug 06, 2008 at 11:41:39PM -0300, martin f krafft wrote:
> also sprach Brian May <email@example.com> [2008.08.06.2242 -0300]:
> > Packages that come to mind that want to alter the environment of it
> > parent are:
> > * ssh-agent
> You have to eval the output, no?
> > * <http://modules.sourceforge.net/>
> *horror* ! :)
> Neither of those affect /etc/dhcp3/dhclient-*-hooks.d though...
> > I guess you could also write a shell script to a temp file and
> > then source that. Not sure if this is any cleaner though.
> The problem is that netconf has no dhclient-script anymore as it
> parses dhclient REASONS directly and then proceeds to use e.g. IP
> address and router stuff as if it had been gathered from /e/n/i.
> Thus, hooks are execvp()'d from netconf directly. If I wanted to
> allow hooks to modify the environment, I'd have to execvp()
> sh -c '. the_hook; env | while read line; do echo "ENVIRONMENT:$line'
> and then parse that stuff out of stdout, which, to put it mildly, is
> ASS. I'd really rather not.
Why not open a new fd and then run
sh -c '. the_hook; env >&3' ?
(though the hook script could also be closing and reopening this fd...
using a higher number could be safer)