summaryrefslogtreecommitdiffstats
path: root/web/attachments/121779-nagiosplug-cvs-check_snmp.diff
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/121779-nagiosplug-cvs-check_snmp.diff')
-rw-r--r--web/attachments/121779-nagiosplug-cvs-check_snmp.diff116
1 files changed, 116 insertions, 0 deletions
diff --git a/web/attachments/121779-nagiosplug-cvs-check_snmp.diff b/web/attachments/121779-nagiosplug-cvs-check_snmp.diff
new file mode 100644
index 0000000..d2c1cde
--- /dev/null
+++ b/web/attachments/121779-nagiosplug-cvs-check_snmp.diff
@@ -0,0 +1,116 @@
1diff -urN ./plugins/check_snmp.c ../plugins/plugins/check_snmp.c
2--- ./plugins/check_snmp.c 2005-01-24 08:29:54.000000000 +0100
3+++ ../plugins/plugins/check_snmp.c 2005-02-17 16:53:58.000000000 +0100
4@@ -36,6 +36,7 @@
5 #define DEFAULT_AUTH_PROTOCOL "MD5"
6 #define DEFAULT_DELIMITER "="
7 #define DEFAULT_OUTPUT_DELIMITER " "
8+#define DEFAULT_SEC_LEVEL "noAuthNoPriv"
9
10 #define mark(a) ((a)!=0?"*":"")
11
12@@ -88,12 +89,12 @@
13 #endif
14
15 char *server_address = NULL;
16-char *community = NULL;
17+char *community = DEFAULT_COMMUNITY;
18 char *authpriv = NULL;
19-char *proto = NULL;
20-char *seclevel = NULL;
21+char *proto = DEFAULT_PROTOCOL;
22+char *seclevel = DEFAULT_SEC_LEVEL;
23 char *secname = NULL;
24-char *authproto = NULL;
25+char *authproto = DEFAULT_AUTH_PROTOCOL;
26 char *authpasswd = NULL;
27 char *privpasswd = NULL;
28 char *oid;
29@@ -147,15 +148,15 @@
30 eval_method[i] = CHECK_UNDEF;
31 i = 0;
32
33- oid = strdup ("");
34- label = strdup ("SNMP");
35- units = strdup ("");
36- port = strdup (DEFAULT_PORT);
37- outbuff = strdup ("");
38- output = strdup ("");
39- delimiter = strdup (DEFAULT_DELIMITER);
40- output_delim = strdup (DEFAULT_OUTPUT_DELIMITER);
41- miblist = strdup (DEFAULT_MIBLIST);
42+ oid = "";
43+ label = "SNMP";
44+ units = "";
45+ port = DEFAULT_PORT;
46+ outbuff = "";
47+ output = "";
48+ delimiter = DEFAULT_DELIMITER;
49+ output_delim = DEFAULT_OUTPUT_DELIMITER;
50+ miblist = DEFAULT_MIBLIST;
51 timeout_interval = DEFAULT_TIMEOUT;
52 retries = DEFAULT_RETRIES;
53
54@@ -598,9 +599,6 @@
55 if (server_address == NULL)
56 server_address = argv[optind];
57
58- if (community == NULL)
59- community = strdup (DEFAULT_COMMUNITY);
60-
61 return validate_arguments ();
62 }
63
64@@ -631,30 +629,28 @@
65 validate_arguments ()
66 {
67
68- /* Need better checks to verify seclevel and authproto choices */
69-
70- if (seclevel == NULL)
71- asprintf (&seclevel, "noAuthNoPriv");
72+ /* Need checks to verify seclevel and authproto choices */
73
74+ /* default protocol is set in variable declaraion, so this can't
75+ * possibly be NULL any-more. It can, however, be a zero length string
76+ * (if a check_command is specified that can use either v1 or v2c, the
77+ * $ARGx$ macro is quote-escaped and not given in service-description)
78+ * in which case we don't fuss much about it but just set it to default */
79+ if (!strlen(proto))
80+ proto = DEFAULT_PROTOCOL;
81
82- if (authproto == NULL )
83- asprintf(&authproto, DEFAULT_AUTH_PROTOCOL);
84-
85-
86-
87- if (proto == NULL || (strcmp(proto,DEFAULT_PROTOCOL) == 0) ) { /* default protocol version */
88- asprintf(&proto, DEFAULT_PROTOCOL);
89+ if (proto[0] == '1' || proto[0] == '2') { /* community based access */
90 asprintf(&authpriv, "%s%s", "-c ", community);
91 }
92 else if ( strcmp (proto, "3") == 0 ) { /* snmpv3 args */
93- asprintf(&proto, "%s", "3");
94-
95+ proto = "3";
96+
97 if ( (strcmp(seclevel, "noAuthNoPriv") == 0) || seclevel == NULL ) {
98- asprintf(&authpriv, "%s", "-l noAuthNoPriv" );
99+ asprintf(&authpriv, "%s %s", "-l", DEFAULT_SEC_LEVEL);
100 }
101 else if ( strcmp(seclevel, "authNoPriv") == 0 ) {
102 if ( secname == NULL || authpasswd == NULL) {
103- printf (_("Missing secname (%s) or authpassword (%s) ! \n"),secname, authpasswd );
104+ printf (_("Missing secname or authpassword!\n"));
105 print_usage ();
106 exit (STATE_UNKNOWN);
107 }
108@@ -662,7 +658,7 @@
109 }
110 else if ( strcmp(seclevel, "authPriv") == 0 ) {
111 if ( secname == NULL || authpasswd == NULL || privpasswd == NULL ) {
112- printf (_("Missing secname (%s), authpassword (%s), or privpasswd (%s)! \n"),secname, authpasswd,privpasswd );
113+ printf (_("Missing secname, authpassword or privpasswd!\n"));
114 print_usage ();
115 exit (STATE_UNKNOWN);
116 }