From 8406bb6bd1c288ad30f4e67cff106b34b2c4d578 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 30 Jan 2008 14:39:09 -0800 Subject: change to how open is used to run tc Use exec to ensure running sudo (no shell interpretation). Change how debug is enabled. --- scripts/vyatta-qos.pl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'scripts/vyatta-qos.pl') 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; } -- cgit v1.2.3