diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-01-30 14:39:09 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-01-30 14:39:09 -0800 |
commit | 8406bb6bd1c288ad30f4e67cff106b34b2c4d578 (patch) | |
tree | c578ca06e8d6ddda96ca72bcb773e9ebd25562d1 /scripts/vyatta-qos.pl | |
parent | 82d29738bd169b47611aa0247516e2f7569f6471 (diff) | |
download | vyatta-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.
Diffstat (limited to 'scripts/vyatta-qos.pl')
-rwxr-xr-x | scripts/vyatta-qos.pl | 13 |
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; } |