From d106d4cf22ee0f25298420f3b2e60cf078e26801 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Thu, 21 Mar 2019 15:03:07 +0000 Subject: [PATCH] tread more carefully when loading device_auth and snmp_auth --- lib/App/Netdisco/Util/DeviceAuth.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/App/Netdisco/Util/DeviceAuth.pm b/lib/App/Netdisco/Util/DeviceAuth.pm index 8c68f714..5e87fdd7 100644 --- a/lib/App/Netdisco/Util/DeviceAuth.pm +++ b/lib/App/Netdisco/Util/DeviceAuth.pm @@ -34,7 +34,13 @@ config changes over time. Returns a list which can replace C. =cut sub fixup_device_auth { - my $config = (setting('device_auth') || setting('snmp_auth')); + my $da = dclone setting('device_auth'); + my $sa = dclone setting('snmp_auth'); + + die "error: both snmp_auth and device_auth are defined! use only device_auth.\n" + if scalar @$da and scalar @$sa; + + my $config = ((scalar @$da) ? $da : $sa); my @new_stanzas = (); # new style snmp config