sudo for www user to run root shell script via browser

marek krolk at excite.com
Sat Jul 23 13:22:52 GMT 2005


hi

I have freebsd 5.4 and need sudo for www (apache) user
to run a startup root script ntop.sh from cgi-bin directory via browser using a per script:
-----------------------------------------------------------------------------------
#!/usr/bin/perl -w
use CGI;
my $query = new CGI;

print $query->header;
print "<html>\n";
print "<head>\n";
print "<title>ntop startup script</title>\n";
print "<STYLE TYPE='text/css'>\n";
print "h3 { color: red }\n";
print "a { text-decoration: none; font: bold 14pt/16pt Ariel, serif }";
print "a:hover { color: red } /* when mouse is over link */";
print "</style>\n";
print "</head>\n";
print "<body bgcolor='#c0c0d0'>\n";
print "<center>";
print "<p><br></p>";
print "<p><br></p>";

'sudo sh /usr/local/www/cgi-bin/ntop/ntop.sh stop' or die "cannot stop ntop: $!";
sleep(8);
$cc = 'sudo sh /usr/local/www/cgi-bin/ntop/ntop.sh start' or die "cannot start ntop: $!";
print "Status: ",$cc,"\n";

print "</body>";
print "</html>";
exit($cc);
-----------------------------------------------------------------------------------

I did:

# cp /usr/local/etc/rc.d /usr/local/www/cgi-bin/ntop
# cd /usr/local/www/cgi-bin/ntop
# chmod 755 ntop.sh
# chown www ntop.sh

I've created in in /usr/local/etc/sudoers following entry:

www ALL=(ALL) NOPASSWD: ALL

but it doesn't work.

if I try from command line as root user:

# sudo -u www sh /usr/local/www/cgi-bin/ntop/ntop.sh start
ntopbsd#

ntop won't start.

what's wrong and how can I execute this script via browser ?

greetings
marek


 


 










_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!


_______________________________________________
freebsd-questions at freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"


More information about the freebsd-questions mailing list