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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SSH Root Login Through Admin Level Website

Status
Not open for further replies.

kennygadams

Programmer
Jan 2, 2005
94
US
Hi,

Is it possible to stop, start, restart root processes with a perl script that doesn't run as root?

I only want to run the sendmail program if a visitor uses our form to send an email. Otherwise I want it turned off because sendmail running with mailscanner puts a heavy load on our server.

The following code is what I used and it doesn't work.

Code:
$feedback = ("su - RootPasswordGoesHere \"service sendmail restart\"");

$feedback returns: su - RootPasswordGoesHere "service sendmail restart"

Thanks,

Kenny
 
Yes. You are effectively setting it to a string. Try
Code:
$feedback = [red]system[/red]("su - RootPasswordGoesHere \"service sendmail restart\"");

# or possibly

$feedback = [red]qx[[/red]su - RootPasswordGoesHere \"service sendmail restart\"[red]][/red];
are two ways of executing it and getting a (different) response.

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Thanks stevexff,

I tried it with system(...) and it didn't work. I also tried to login as admin first and root second and it still didn't work. I think my syntax is wrong and have spent many hours searching through Google for proper ways to use system calls but couldn't find anything that fit what I'm trying to do.

Code:
print "Starting sendmail process...<p>";

my $feedback = system("admin AdminPasswordGoesHere su - RootPasswordGoesHere \"service sendmail start\"");

print "\$feedback = $feedback<p>";

exit;

The $feedback returns "32512" which means "child exited with value 127." I'm not sure what this means. All I know is that the sendmail program didn't start, so I assume that my system call is incorrect.

Sincerely,

Kenny
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top