diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-02-29 12:15:52 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-02-29 12:15:52 -0800 |
commit | 6d33fa3c2bf15916bdd59726cfcf0bab3f44a891 (patch) | |
tree | f6d0143b8c57a50c6150039ea0b473a06a262c32 /scripts/firewall | |
parent | 71ce1df708c2e235af68cedccc091cb27d356170 (diff) | |
download | vyatta-op-firewall-6d33fa3c2bf15916bdd59726cfcf0bab3f44a891.tar.gz vyatta-op-firewall-6d33fa3c2bf15916bdd59726cfcf0bab3f44a891.zip |
use exec rather than open with path
This avoids a number of future problems with bareword filehandles.
See Perl Best Practices (Chapter 10)
Diffstat (limited to 'scripts/firewall')
-rwxr-xr-x | scripts/firewall/vyatta-show-firewall.pl | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/scripts/firewall/vyatta-show-firewall.pl b/scripts/firewall/vyatta-show-firewall.pl index 4995a09..78e6b68 100755 --- a/scripts/firewall/vyatta-show-firewall.pl +++ b/scripts/firewall/vyatta-show-firewall.pl @@ -26,15 +26,17 @@ sub show_chain { my $chain = shift; my $fh = shift; - open(STATS, "/sbin/iptables -L $chain -vn |") or exit 1; + open my $iptables, "-|" + or exec "sudo", "/sbin/iptables", "-L", $chain, "-vn" + or exit 1; my @stats = (); - while (<STATS>) { + while (<$iptables>) { if (!/^\s*(\d+[KMG]?)\s+(\d+[KMG]?)\s/) { next; } push @stats, ($1, $2); } - close STATS; + close $iptables; print $fh "<opcommand name='firewallrules'><format type='row'>\n"; my $config = new VyattaConfig; |