From ecc62d95b95fd802dec09a3e0707eb536bf26960 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 5 Apr 2010 22:07:22 -0700 Subject: Use 3 arg open This fixes perlcritic warning because of using 2 arg open. The other form puts pipe as method. --- scripts/vyatta-interfaces.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index cbb6abf6..90a4e0f9 100755 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -544,7 +544,7 @@ sub show_config_path { sub get_ethtool { my $dev = shift; - open( my $ethtool, "sudo /usr/sbin/ethtool $dev 2>/dev/null |" ) + open( my $ethtool, "-|", "sudo /usr/sbin/ethtool $dev 2>/dev/null" ) or die "ethtool failed: $!\n"; # ethtool produces: -- cgit v1.2.3 From 8cd6dce2f7f6ed058ada32b875377fc3e4c61432 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 5 Apr 2010 22:09:37 -0700 Subject: Use 3 arg open to create pipe Safer from user doing nasty things with command args. --- scripts/vyatta-load-user-key.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/vyatta-load-user-key.pl b/scripts/vyatta-load-user-key.pl index 29163f6a..d64dba8a 100755 --- a/scripts/vyatta-load-user-key.pl +++ b/scripts/vyatta-load-user-key.pl @@ -71,7 +71,7 @@ sub geturl { } $cmd .= " $url"; - open (my $curl, "$cmd |" ) + open (my $curl, "-|", $cmd ) or die "$cmd command failed: $!"; return $curl; -- cgit v1.2.3 From 0f258c68899fa3f48315c92225db8762ac73c4a5 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 5 Apr 2010 22:10:13 -0700 Subject: Ignore errors from ethtool when setting speed/duplex Many virtual devices don't implement speed/duplex, so just ignore any errors. --- scripts/vyatta-interfaces.pl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index 90a4e0f9..8970790f 100755 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -586,13 +586,14 @@ sub set_speed_duplex { } } - my @cmd = ('sudo', 'ethtool', '-s', $intf ); + my $cmd = "sudo /usr/sbin/ethtool -s $intf"; if ($nspeed eq 'auto') { - push @cmd, qw(autoneg on); + $cmd .= " autoneg on"; } else { - push @cmd, 'speed', $nspeed, 'duplex', $nduplex, 'autoneg', 'off'; + $cmd .= " speed $nspeed duplex $nduplex autoneg off"; } - exec @cmd; - die "Command failed: ", join(' ', @cmd); + # ignore errors since many devices don't allow setting speed/duplex + $cmd .= " 2>/dev/null"; + system ($cmd); } -- cgit v1.2.3