os.environ['PATH'] missing

Discussion in 'Python' started by peterbe@gmail.com, Jan 6, 2006.

  1. Guest

    This is a hard question to ask because I can't reproduce the problem
    other than restarting several times over until it happens again.

    I'm using Zope and Plone for a website on this debian linux vserver and
    when I restart it it runs some /etc/init.d/zope restart scripts and
    things fail in zope because somewhere deep in there the following
    raises an AttributeError that 'PATH' doesn't exist:

    foo = os.environ['PATH']

    How can it not be present?
    What might cause this seemingly random situation?

    Has anybody had similar experiences where 'PATH' is not present in
    os.environ?
     
    , Jan 6, 2006
    #1
    1. Advertising

  2. Jorgen Grahn Guest

    On 6 Jan 2006 06:03:05 -0800, <> wrote:
    ....
    > How can it not be present?
    > What might cause this seemingly random situation?


    Well, it's not uncommon to start a program with a reduced set of environment
    variables, including a limited, hardcoded $PATH, so something like
    os.system("ls") cannot be tricked to run an ls outside the
    system-controlled, "safe" directories.

    On my machine, "env -i sh" starts a shell without $PATH. Bash seems to
    default to a builtin search path in that situation (/bin and /usr/bin, I
    suppose).

    But reducing $PATH is one thing (and fairly common); removing it is another.
    And I'm not sure that programs are expected to cope with the absence of
    $PATH; just because it's /possible/ to remove it doesn't mean it's legal.

    I don't know anything about web servers and Zope. Sorry.

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
    \X/ snipabacken.dyndns.org> R'lyeh wgah'nagl fhtagn!
     
    Jorgen Grahn, Jan 8, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pablo
    Replies:
    4
    Views:
    446
  2. Yun Mao

    os.environ and os.path.chdir

    Yun Mao, Sep 20, 2003, in forum: Python
    Replies:
    4
    Views:
    454
    Thomas Bellman
    Sep 20, 2003
  3. Replies:
    9
    Views:
    735
    Peter Otten
    Feb 27, 2007
  4. gert
    Replies:
    0
    Views:
    489
  5. Îίκος

    Referrer key missing form os.environ dictionary?

    Îίκος, Sep 25, 2013, in forum: Python
    Replies:
    34
    Views:
    314
    Chris Angelico
    Sep 27, 2013
Loading...

Share This Page