summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-02-29 12:15:52 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2008-02-29 12:15:52 -0800
commit6d33fa3c2bf15916bdd59726cfcf0bab3f44a891 (patch)
treef6d0143b8c57a50c6150039ea0b473a06a262c32 /scripts
parent71ce1df708c2e235af68cedccc091cb27d356170 (diff)
downloadvyatta-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')
-rwxr-xr-xscripts/firewall/vyatta-show-firewall.pl8
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;