summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2011-03-08 09:47:13 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2011-03-16 12:25:49 -0700
commit445182202533b136c7c68485753ed984e558849c (patch)
tree28c17e3ca7bf7c32b765f6391e938f5a50c87d97
parent5efcff83be5b97ef99731f8da1eab5f1a51cca0d (diff)
downloadvyatta-cfg-system-445182202533b136c7c68485753ed984e558849c.tar.gz
vyatta-cfg-system-445182202533b136c7c68485753ed984e558849c.zip
Test for ipv6 blacklist when configuring SNMP
Bug 6432 Since IPv6 can be disabled several ways and the config may not match the system, use socket to test if IPv6 is disabled. (cherry picked from commit 5da52b67dc78ef08e7c8a0e1c5502a67be59cd27)
-rwxr-xr-xscripts/snmp/vyatta-snmp.pl15
1 files changed, 10 insertions, 5 deletions
diff --git a/scripts/snmp/vyatta-snmp.pl b/scripts/snmp/vyatta-snmp.pl
index a812eb32..fcf8277d 100755
--- a/scripts/snmp/vyatta-snmp.pl
+++ b/scripts/snmp/vyatta-snmp.pl
@@ -23,15 +23,17 @@
# **** End License ****
#
+use strict;
+use warnings;
+
use lib "/opt/vyatta/share/perl5/";
use Vyatta::Config;
use Vyatta::Misc;
use NetAddr::IP;
use Getopt::Long;
use File::Copy;
-
-use strict;
-use warnings;
+use Socket;
+use Socket6;
my $mibdir = '/opt/vyatta/share/snmp/mibs';
my $snmp_init = '/opt/vyatta/sbin/snmpd.init';
@@ -112,9 +114,12 @@ sub transport_syntax {
die "$addr: unknown IP version $version";
}
+# Test if IPv6 is possible by opening a socket
sub ipv6_disabled {
- my $config = new Vyatta::Config;
- return $config->exists("system ipv6 disable");
+ socket ( my $s, PF_INET6, SOCK_DGRAM, 0)
+ or return 1;
+ close($s);
+ return;
}
# Find SNMP agent listening addresses