On 2/14/06, nishanth ev <[EMAIL PROTECTED]> wrote:

> I have set a setuid for the cgi script

You webserver may not be running this program set-id, even if you use
the setuid bit, for security reasons. You can find out the user id
it's running under with the $< and $> variables. See perlvar.

> Have anyone tried stopping a service say httpd usng a
> cgi script ?

You mean, stopping a second web server, not the one that's running
your CGI program, right? If your program stops running the program
that's running your program, that's the end of execution, ready or
not. (But if that's the issue, you could set up a delayed shutdown, to
shut down the server several seconds after the CGI program finishes.)

Stopping another server should be possible, although you may need to
have a non-privileged CGI program start a second set-id program to do
the work.

> `/etc/rc.d/init.d/httpd stop`;

Any error messages that this command produces may cause the webserver
to stop the CGI program early. Also, since the backquotes are in a
void context, any normal output is discarded. You could make that
explicit:

    system('/etc/rc.d/init.d/httpd stop >/dev/null 2>/dev/null');

But capturing the output (and maybe saving it or displaying it for the
benefit of the user) is probably a better way:

    my $results = `/etc/rc.d/init.d/httpd stop 2>&1`;

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to