[Nix-dev] bash (no -l) resetting PATH?

Marc Weber marco-oweber at gmx.de
Tue Feb 8 08:48:34 CET 2011


Excerpts from Lluís Batlle i Rossell's message of Tue Feb 08 08:27:31 +0100 2011:
> Then, daemons without the proper PATH would fail to run system commands when
> using system() or alike, I imagine.
You're wrong. That already happened. I don't remember the name of the
daemon.
Eg try this to confirm:

  == test.c ==

  #include <stdio.h>

  int main(int argc, char * argv[])
  {
    system("echo $PATH");
  }


compile. Then try both:
  env -i ./test #
  strace ./test 2>&1 | grep /etc/bashrc || echo "did'nt read /etc/bashrc"

The first yields /no-such-path the other echoes the string.

The /no-such-path is patched somewhere. Should be easy to find.

So daemons inherit the PATH from upstart (wich is set to a sane default
eg coreutils if I recall correctly). If not its set to /no-such-path.

In neither case /etc/bashrc is sourced.

Appending is bad because each time you run bash PATH will get longer.

I've finished moving code into /etc/profile and I'm working on adding
full native zsh support now.

I'll send patches soon.

Marc Weber



More information about the nix-dev mailing list