From 745b58a68bf2e60a6652475c56a1cff0aa6ebf9f Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Wed, 24 Oct 2007 15:08:34 +0000 Subject: Hide the SNMP community string (and v3 passwords) from error messages (Bernhard Fischer on nagiosplug-devel@) git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1809 f882894a-f735-0410-b71e-b25c423dba1c --- plugins/check_snmp.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index fd3028cf..845c1bb4 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c @@ -148,6 +148,7 @@ main (int argc, char **argv) int result = STATE_DEPENDENT; char input_buffer[MAX_INPUT_BUFFER]; char *command_line = NULL; + char *cl_hidden_auth = NULL; char *response = NULL; char *outbuff; char *output; @@ -186,11 +187,17 @@ main (int argc, char **argv) asprintf(&command_line, "%s -t %d -r %d -m %s -v %s %s %s:%s %s", PATH_TO_SNMPGETNEXT, timeout_interval, retries, miblist, proto, authpriv, server_address, port, oid); + asprintf(&cl_hidden_auth, "%s -t %d -r %d -m %s -v %s %s %s:%s %s", + PATH_TO_SNMPGETNEXT, timeout_interval, retries, miblist, proto, + "[authpriv]", server_address, port, oid); }else{ asprintf (&command_line, "%s -t %d -r %d -m %s -v %s %s %s:%s %s", PATH_TO_SNMPGET, timeout_interval, retries, miblist, proto, authpriv, server_address, port, oid); + asprintf(&cl_hidden_auth, "%s -t %d -r %d -m %s -v %s %s %s:%s %s", + PATH_TO_SNMPGET, timeout_interval, retries, miblist, proto, + "[authpriv]", server_address, port, oid); } if (verbose) @@ -200,14 +207,14 @@ main (int argc, char **argv) /* run the command */ child_process = spopen (command_line); if (child_process == NULL) { - printf (_("Could not open pipe: %s\n"), command_line); + printf (_("Could not open pipe: %s\n"), cl_hidden_auth); exit (STATE_UNKNOWN); } #if 0 /* Removed May 29, 2007 */ child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); if (child_stderr == NULL) { - printf (_("Could not open stderr for %s\n"), command_line); + printf (_("Could not open stderr for %s\n"), cl_hidden_auth); } #endif @@ -369,7 +376,7 @@ main (int argc, char **argv) die (STATE_UNKNOWN, _("%s problem - No data received from host\nCMD: %s\n"), label, - command_line); + cl_hidden_auth); #if 0 /* Removed May 29, 2007 */ /* WARNING if output found on stderr */ -- cgit v1.2.3-74-g34f1