setuid() and getenv()?

Discussion in 'Perl' started by vertigo, Jul 16, 2004.

  1. vertigo

    vertigo Guest

    Hello
    i need to read $PATH variable for all users.
    I wanted to use something like setuid() and getenv() in C.
    Are there similar functions here ?
    (if not how can i do it ?)

    Thanx
    Michal
     
    vertigo, Jul 16, 2004
    #1
    1. Advertisements

  2. vertigo

    Joe Smith Guest

    See the docs on perlvar for the setuid() equivalent.

    C: currentpath = getenv("PATH"); => Perl: $currentpath = $ENV{PATH};

    For an idea on how to get a list of all users, their home directories,
    and login shells:

    perl -le 'while(@pw=getpwent){print join " : ",@pw[0,7,8]}'

    Executing the user's login shell, as in
    chdir $home; ($>,$)) = ($uid,$gid); $path=`$shell -c 'echo $PATH'`;
    is an unacceptable security risk.

    -Joe

    P.S. Next time, post to comp.lang.perl.misc instead of comp.lang.perl.
     
    Joe Smith, Jul 17, 2004
    #2
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.