470,835 Members | 1,938 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,835 developers. It's quick & easy.

setuid() and getenv()?

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

Jul 19 '05 #1
1 15817
vertigo wrote:
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 ?


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.
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Ben Eisenberg | last post: by
reply views Thread by Dave Harrison | last post: by
3 posts views Thread by pasear | last post: by
5 posts views Thread by Chad Paquette | last post: by
5 posts views Thread by silrandir | last post: by
4 posts views Thread by Yogi Watcher | last post: by
3 posts views Thread by Tiago Simões Batista | last post: by
2 posts views Thread by Stu | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.