Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Jul 2005 09:12:58 -0400 (EDT)
From:      "marek" <krolk@excite.com>
To:        freebsd-questions@freebsd.org
Subject:   sudo for www user to run root shell script via browser
Message-ID:  <list.freebsd.questions#20050723131258.B99963E1A@xprdmailfe11.nwk.excite.com>

Next in thread | Raw E-Mail | Index | Archive | Help

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@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?list.freebsd.questions#20050723131258.B99963E1A>