Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running system command in perl and setuid problem

Status
Not open for further replies.

geffry

Programmer
Jun 26, 2002
33
US
I have a perl file in cgi-bin dir, which needs to run a system command, which requires root priviledge. my apache server runs as user nobody, so i changed the setuid of the perl script (chmod 4711 xyz.pl ), when i run i get the below error

Insecure dependency in `` while running setuid at /dev/fd/5 line 31

the line 31 is

system(`/usr/apache/bin/htpasswd -b /asamsit/http/htpass/.htpasswd $user $passw
d`);
--------------------------------
my $user;
my $passwd;
print "User : $ENV{REMOTE_USER} \n";

$user = $ENV{REMOTE_USER};
$passwd = $form{pw};
print "<HR>";
print "new password : $form{pw} ";


system(`/usr/apache/bin/htpasswd -b /asamsit/http/htpass/.htpasswd $user $passw
d`);

print "</body></html>\n";
 
Getting setuid Perl scripts to work properly *will* give you ulcers. (did me anyway)

I eventually sidestepped the issue altogether and installed sudo which lets you run jobs as root/whoever with no fuss.

Mike

"Deliver me from the bane of civilised life; teddy bear envy."

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

 
I have a similar problem too.
I run the perl script through Web and the script shall call a system utility program which merges two binary files.

Here is part of my codes:
Code:
$src_file = "/var/[URL unfurl="true"]www/cgi-bin/abc"[/URL]
$tar_file = "/var/[URL unfurl="true"]www/cgi-bin/pqr"[/URL]
system("merge -w $tar_file $src_file");
Nothing happens although the Web is responed successfully. What I expect is the $tar_file should be created at the said location.
 
nmlsupport,

Always seems to be a permissions or path issue with this kind of problem.

Try saving all of the output from your merge command into a file and see if merge is trying to tell you anything useful - like this.
Code:
system("merge -w $tar_file $src_file > /tmp/file.out 2>&1");


Mike

"Deliver me from the bane of civilised life; teddy bear envy."

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

 
I used , "exec" instead of system; and changed the perl file permission to 4711 and it worked fine
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top