summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-01-30 14:39:09 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2008-01-30 14:39:09 -0800
commit8406bb6bd1c288ad30f4e67cff106b34b2c4d578 (patch)
treec578ca06e8d6ddda96ca72bcb773e9ebd25562d1
parent82d29738bd169b47611aa0247516e2f7569f6471 (diff)
downloadvyatta-cfg-qos-8406bb6bd1c288ad30f4e67cff106b34b2c4d578.tar.gz
vyatta-cfg-qos-8406bb6bd1c288ad30f4e67cff106b34b2c4d578.zip
change to how open is used to run tc
Use exec to ensure running sudo (no shell interpretation). Change how debug is enabled.
-rwxr-xr-xscripts/vyatta-qos.pl13
1 files changed, 7 insertions, 6 deletions
diff --git a/scripts/vyatta-qos.pl b/scripts/vyatta-qos.pl
index 86a0c62..9526793 100755
--- a/scripts/vyatta-qos.pl
+++ b/scripts/vyatta-qos.pl
@@ -3,18 +3,17 @@
use lib "/opt/vyatta/share/perl5/";
use VyattaConfig;
use VyattaQosPolicy;
+use strict;
use Getopt::Long;
my $qosNode = 'qos-policy';
-
+my $debug = $ENV{'QOS_DEBUG'};
my @update = ();
my @delete = ();
-my $debug = $ENV{"DEBUG"};
my $list = undef;
GetOptions(
- "debug" => \$debug,
"list" => \$list,
"update=s{3}" => \@update,
"delete=s{2}" => \@delete,
@@ -67,10 +66,12 @@ sub update_interface {
defined $policy or die "undefined policy";
# When doing debugging just echo the commands
+ my $out;
if (defined $debug) {
- open (my $out, ">&STDOUT");
+ open $out, '>-'
+ or die "can't open stdout: $!";
} else {
- open( my $out, "|sudo tc -batch -" )
+ open $out, "|-" or exec qw/sudo tc -batch -/
or die "Tc setup failed: $!\n";
}
@@ -94,7 +95,7 @@ if ( $#delete == 1 ) {
}
if ( $#update == 2 ) {
- update_interface(@update);
+ update_interface(@update, $debug);
exit 0;
}