From a12dc964f0dc8603b25e5022c4f204005681c8f8 Mon Sep 17 00:00:00 2001 From: Christopher Arceneaux Date: Fri, 29 Dec 2017 14:07:55 -0500 Subject: [PATCH 1/2] fixed logic error when validating snmp v3 args --- .vscode/settings.json | 22 ++++++++++++++++++++++ mib2zabbix.pl | 24 ++++++++++++++++++------ 2 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6a13b60 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,22 @@ +{ + "cSpell.enabledLanguageIds": [ + "c", + "cpp", + "csharp", + "go", + "handlebars", + "javascript", + "javascriptreact", + "json", + "latex", + "markdown", + "php", + "plaintext", + "python", + "restructuredtext", + "text", + "typescript", + "typescriptreact", + "yml" + ] +} \ No newline at end of file diff --git a/mib2zabbix.pl b/mib2zabbix.pl index c60ced5..46ac243 100755 --- a/mib2zabbix.pl +++ b/mib2zabbix.pl @@ -236,12 +236,24 @@ pod2usage({ -exitval => 0 }) if ($opts->{ help }); # Validate SNMPv3 settings if ($opts->{ snmpver } == 3) { $opts->{ snmpcomm } = ''; - $opts->{ v3auth_level } = $snmpv3_auth_level_map->{ lc($opts->{ v3auth_level }) } - or die("Unknown authentication level '$opts->{ v3auth_level }'"); - $opts->{ v3auth_protocol } = $snmpv3_auth_protocol_map->{ lc($opts->{ v3auth_protocol }) } - or die("Unknown authentication protocol '$opts->{ v3auth_protocol }'"); - $opts->{ v3sec_protocol } = $snmpv3_sec_protocol_map->{ lc($opts->{ v3sec_protocol }) } - or die("Unknown privacy protocol '$opts->{ v3sec_protocol }'"); + if (defined $snmpv3_auth_level_map->{ lc($opts->{ v3auth_level }) }) { + $opts->{ v3auth_level } = $snmpv3_auth_level_map->{ lc($opts->{ v3auth_level }) } + } + else { + die("Unknown authentication level '$opts->{ v3auth_level }'"); + } + if (defined $snmpv3_auth_protocol_map->{ lc($opts->{ v3auth_protocol }) }) { + $opts->{ v3auth_protocol } = $snmpv3_auth_protocol_map->{ lc($opts->{ v3auth_protocol }) } + } + else { + die("Unknown authentication protocol '$opts->{ v3auth_protocol }'"); + } + if (defined $snmpv3_sec_protocol_map->{ lc($opts->{ v3sec_protocol }) }) { + $opts->{ v3sec_protocol } = $snmpv3_sec_protocol_map->{ lc($opts->{ v3sec_protocol }) } + } + else { + die("Unknown privacy protocol '$opts->{ v3sec_protocol }'"); + } } # Base template for Template Items, Discovery Rules and Item Prototypes From 1e4d0196c26b37a7265ddd7c0855cb1e014608e4 Mon Sep 17 00:00:00 2001 From: Chris Arceneaux Date: Fri, 29 Dec 2017 14:16:49 -0500 Subject: [PATCH 2/2] Delete settings.json --- .vscode/settings.json | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 6a13b60..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "cSpell.enabledLanguageIds": [ - "c", - "cpp", - "csharp", - "go", - "handlebars", - "javascript", - "javascriptreact", - "json", - "latex", - "markdown", - "php", - "plaintext", - "python", - "restructuredtext", - "text", - "typescript", - "typescriptreact", - "yml" - ] -} \ No newline at end of file