diff options
author | Anton Lofgren <alofgren@op5.com> | 2014-03-07 11:35:21 +0100 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2014-04-24 08:49:54 +0200 |
commit | 4e0da0216d3ca96c930eca053c9a229e86cc7402 (patch) | |
tree | 29317e50ffe1eebbb86843b8c86b87e82e4d2224 /plugins/check_snmp.c | |
parent | c887890e9f9698f01eb62451a04579c9c4be325f (diff) | |
download | monitoring-plugins-4e0da0216d3ca96c930eca053c9a229e86cc7402.tar.gz |
check_snmp: Handle SNMPv3 noAuthNoPriv properly
The SNMPv3 noAuthNoPriv security level, somewhat unintuitively, requires
a security name to be passed along together with the request. Check_snmp
previously did not do this, causing snmpget to throw an error:
"External command error: No log handling enabled - turning on stderr
logging
snmpget: No securityName specified"
This patch fixes the issue by always providing the security name when
noAuthNoPriv is specified.
See also:
https:://bugs.op5.com/view.php?id=8385.
Signed-off-by: Anton Lofgren <alofgren@op5.com>
Diffstat (limited to 'plugins/check_snmp.c')
-rw-r--r-- | plugins/check_snmp.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index d516fbc1..2c62a230 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c @@ -963,11 +963,16 @@ validate_arguments () if (seclevel == NULL) xasprintf(&seclevel, "noAuthNoPriv"); + if (secname == NULL) + die(STATE_UNKNOWN, _("Required parameter: %s\n"), "secname"); + if (strcmp(seclevel, "noAuthNoPriv") == 0) { - numauthpriv = 2; + numauthpriv = 4; authpriv = calloc (numauthpriv, sizeof (char *)); authpriv[0] = strdup ("-l"); authpriv[1] = strdup ("noAuthNoPriv"); + authpriv[2] = strdup ("-u"); + authpriv[3] = strdup (secname); } else { if (! ( (strcmp(seclevel, "authNoPriv")==0) || (strcmp(seclevel, "authPriv")==0) ) ) { usage2 (_("Invalid seclevel"), seclevel); @@ -976,9 +981,6 @@ validate_arguments () if (authproto == NULL ) xasprintf(&authproto, DEFAULT_AUTH_PROTOCOL); - if (secname == NULL) - die(STATE_UNKNOWN, _("Required parameter: %s\n"), "secname"); - if (authpasswd == NULL) die(STATE_UNKNOWN, _("Required parameter: %s\n"), "authpasswd"); |