473,326 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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 15960
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ben Eisenberg | last post by:
I'm trying to run a php script setuid. I've tried POSIX_setuid but you have to be root to run this. The files are located on a public access unix system and have me as the owner and nobody as the...
0
by: Dave Harrison | last post by:
hi again, Im clearly a moron, and have solved the problem myself, due to a wish to avoid dire embarrasment I shall not reveal the stupid mistake I made ;-) Apologies for the inconvenience...
0
by: Xavier | last post by:
Greetings, While messing around with the "dl" module I ran into a segfault. *DO NOTE THAT THE FOLLOWING OCCURED ON 2 OF MY LINUX WORKSTATIONS* ------ # python -c 'import dl;...
3
by: pasear | last post by:
I find I can't run setuid perl script when I do this on a Unix-like platform: 1.Create a file "setuid.pl": #!/usr/bin/perl -T 2.chmod a+x setuid.pl 3.chmod u+s setuid.pl then i try
5
by: Chad Paquette | last post by:
Hi, We have a legacy cgi app that's written in C. We are encountering an error when we try to retrieve a cgi environment variable. The variable we are getting contains a Base64 encoded...
5
by: silrandir | last post by:
when attempting to call getenv() in global memory (c/c++), it constantly returns null, but when called in main, it properly reads the environment. is this expected behavior? sample code:...
4
by: Yogi Watcher | last post by:
Hi, Recently I have observed some odd behavior of getenv and putenv function. I am developing some code that integrates with several other libraries. This program is not using MFC. It is plain C...
3
by: Tiago Simões Batista | last post by:
Hello all I have a situation that requires that a python script, that is run from a webpage (via php exec()) must be run with root privileges. The sysadmin already set the setuid bit on the...
2
by: Stu | last post by:
Is there anyway to tell if a setuid() call has been made to some other user? If so, can somebody provide me with some sample code Thanks in advance to all that answer
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.