Commit 1a2c8433 authored by Leigh Stoller's avatar Leigh Stoller

A few tweaks for running as root; call portstats as elabman wap.

parent b0f453df
...@@ -124,6 +124,8 @@ sub fatal($); ...@@ -124,6 +124,8 @@ sub fatal($);
$| = 1; $| = 1;
my $portstats = "$TB/bin/portstats"; my $portstats = "$TB/bin/portstats";
my $wap = "$TB/sbin/withadminprivs";
my $sudo = "/usr/local/bin/sudo";
my @nodes = (); my @nodes = ();
my %switches = (); my %switches = ();
my %pcs = (); my %pcs = ();
...@@ -144,6 +146,7 @@ $ENV{'WITH_TB_ADMIN_PRIVS'} = 1; ...@@ -144,6 +146,7 @@ $ENV{'WITH_TB_ADMIN_PRIVS'} = 1;
# Load the Testbed support stuff. # Load the Testbed support stuff.
use lib "@prefix@/lib"; use lib "@prefix@/lib";
use EmulabConstants;
use libdb; use libdb;
use libtestbed; use libtestbed;
use Experiment; use Experiment;
...@@ -190,7 +193,7 @@ if (TBGetSiteVar($svar, \$tmp)) { ...@@ -190,7 +193,7 @@ if (TBGetSiteVar($svar, \$tmp)) {
exit(0); exit(0);
} }
} }
my $svar = "cnetwatch/check_interval"; $svar = "cnetwatch/check_interval";
if (TBGetSiteVar($svar, \$tmp)) { if (TBGetSiteVar($svar, \$tmp)) {
if ($tmp == 0 || $tmp >= 10) { if ($tmp == 0 || $tmp >= 10) {
$interval = $tmp; $interval = $tmp;
...@@ -326,16 +329,6 @@ if ($MAIL_IV == 0) { ...@@ -326,16 +329,6 @@ if ($MAIL_IV == 0) {
$MAIL_IV = $alertinterval; $MAIL_IV = $alertinterval;
} }
#
# Check user id.
#
if ($UID == 0) {
fatal("Do not run as root or portstats will fail!");
}
if (!TBAdmin()) {
fatal("Must run as an admin user or portstats will fail!");
}
# Go to ground. # Go to ground.
if (! ($debug || $runonce)) { if (! ($debug || $runonce)) {
if (CheckDaemonRunning("cnetwatch")) { if (CheckDaemonRunning("cnetwatch")) {
...@@ -824,7 +817,8 @@ sub gather($) ...@@ -824,7 +817,8 @@ sub gather($)
my $slist = join(' ', @{$switches{$switch}}); my $slist = join(' ', @{$switches{$switch}});
print STDERR "$switch: invoking '$portstats -i -H -r -l -c -p $slist':\n" print STDERR "$switch: invoking '$portstats -i -H -r -l -c -p $slist':\n"
if ($debug > 1); if ($debug > 1);
if (!open(PS, "$portstats -i -H -r -l -c -p $slist 2>&1 |")) { if (!open(PS, "$sudo -u ". PROTOUSER() . " $wap ".
"$portstats -i -H -r -l -c -p $slist 2>&1 |")) {
print STDERR "*** $switch: portstats failed on open, ignored\n"; print STDERR "*** $switch: portstats failed on open, ignored\n";
next; next;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment