diff options
Diffstat (limited to 'web/attachments/450269-nagios-plugins-1.4.15-snmp_conf.patch')
-rw-r--r-- | web/attachments/450269-nagios-plugins-1.4.15-snmp_conf.patch | 205 |
1 files changed, 205 insertions, 0 deletions
diff --git a/web/attachments/450269-nagios-plugins-1.4.15-snmp_conf.patch b/web/attachments/450269-nagios-plugins-1.4.15-snmp_conf.patch new file mode 100644 index 0000000..7d5689b --- /dev/null +++ b/web/attachments/450269-nagios-plugins-1.4.15-snmp_conf.patch | |||
@@ -0,0 +1,205 @@ | |||
1 | --- nagios-plugins-1.4.15/plugins/check_snmp.c.conf 2011-07-22 09:23:17.000000000 -0400 | ||
2 | +++ nagios-plugins-1.4.15/plugins/check_snmp.c 2011-07-26 15:41:43.000000000 -0400 | ||
3 | @@ -259,26 +259,29 @@ | ||
4 | asprintf (&command_line[4], "%d", retries); | ||
5 | command_line[5] = strdup ("-m"); | ||
6 | command_line[6] = strdup (miblist); | ||
7 | - command_line[7] = "-v"; | ||
8 | - command_line[8] = strdup (proto); | ||
9 | |||
10 | for (i = 0; i < numauthpriv; i++) { | ||
11 | - command_line[9 + i] = authpriv[i]; | ||
12 | + command_line[7 + i] = authpriv[i]; | ||
13 | } | ||
14 | |||
15 | - asprintf (&command_line[9 + numauthpriv], "%s:%s", server_address, port); | ||
16 | + asprintf (&command_line[7 + numauthpriv], "%s:%s", server_address, port); | ||
17 | |||
18 | /* This is just for display purposes, so it can remain a string */ | ||
19 | - asprintf(&cl_hidden_auth, "%s -t %d -r %d -m %s -v %s %s %s:%s", | ||
20 | - snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", proto, "[authpriv]", | ||
21 | - server_address, port); | ||
22 | + if (proto != NULL) | ||
23 | + asprintf(&cl_hidden_auth, "%s -t %d -r %d -m %s -v %s %s %s:%s", | ||
24 | + snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", proto, "[authpriv]", | ||
25 | + server_address, port); | ||
26 | + else | ||
27 | + asprintf(&cl_hidden_auth, "%s -t %d -r %d -m %s %s %s:%s", | ||
28 | + snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", "[authpriv]", | ||
29 | + server_address, port); | ||
30 | |||
31 | for (i = 0; i < numoids; i++) { | ||
32 | - command_line[9 + numauthpriv + 1 + i] = oids[i]; | ||
33 | + command_line[7 + numauthpriv + 1 + i] = oids[i]; | ||
34 | asprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]); | ||
35 | } | ||
36 | |||
37 | - command_line[9 + numauthpriv + 1 + numoids] = NULL; | ||
38 | + command_line[7 + numauthpriv + 1 + numoids] = NULL; | ||
39 | |||
40 | if (verbose) | ||
41 | printf ("%s\n", cl_hidden_auth); | ||
42 | @@ -835,9 +838,36 @@ | ||
43 | |||
44 | |||
45 | |||
46 | +void addParam(char *flag, char*val) { | ||
47 | + // We are lazy. Verify if the value is null and, if not, add it | ||
48 | + if (flag != NULL && val != NULL) { | ||
49 | + // Raise the amount of space required for our array | ||
50 | + numauthpriv+=2; | ||
51 | + | ||
52 | + if (authpriv == NULL) | ||
53 | + authpriv = calloc(numauthpriv, sizeof(char *)); | ||
54 | + else | ||
55 | + authpriv = realloc(authpriv, numauthpriv * sizeof(char *)); | ||
56 | + | ||
57 | + authpriv[numauthpriv-2] = strdup(flag); | ||
58 | + authpriv[numauthpriv-1] = strdup(val); | ||
59 | + } | ||
60 | +} | ||
61 | + | ||
62 | +/* | ||
63 | +Protocol Security Params Reason | ||
64 | +NULL NULL -c,-a,-u,-A,-x,-X We don't know what the user wants. We overwrite anything provided. | ||
65 | +1 * -v,-c SNMP v1 supports only community | ||
66 | +2c * -v,-c SNMP v2c supports only community | ||
67 | +3 NULL -v,-u,-a,-A,-x,-X We don't know the security required in snmp.conf. We provide anything | ||
68 | +3 authPriv -v,-l,-u,-a,-A,-x,-X We overwrite any Authentication of privacy setting of snmp.conf by command line | ||
69 | +3 noAuthNoPriv -v,-l,-u We provide version, security level and security name | ||
70 | +3 authNoPriv -v,-l,-u,-a,-A We provide version, security level, security name and password | ||
71 | +*/ | ||
72 | int | ||
73 | validate_arguments () | ||
74 | { | ||
75 | + numauthpriv=0; | ||
76 | /* check whether to load locally installed MIBS (CPU/disk intensive) */ | ||
77 | if (miblist == NULL) { | ||
78 | if ( needmibs == TRUE ) { | ||
79 | @@ -855,75 +885,38 @@ | ||
80 | if (numoids == 0) | ||
81 | die(STATE_UNKNOWN, _("No OIDs specified\n")); | ||
82 | |||
83 | - if (proto == NULL) | ||
84 | - asprintf(&proto, DEFAULT_PROTOCOL); | ||
85 | |||
86 | - if ((strcmp(proto,"1") == 0) || (strcmp(proto, "2c")==0)) { /* snmpv1 or snmpv2c */ | ||
87 | - numauthpriv = 2; | ||
88 | - authpriv = calloc (numauthpriv, sizeof (char *)); | ||
89 | - authpriv[0] = strdup ("-c"); | ||
90 | - authpriv[1] = strdup (community); | ||
91 | - } | ||
92 | - else if ( strcmp (proto, "3") == 0 ) { /* snmpv3 args */ | ||
93 | - if (seclevel == NULL) | ||
94 | - asprintf(&seclevel, "noAuthNoPriv"); | ||
95 | - | ||
96 | - if (strcmp(seclevel, "noAuthNoPriv") == 0) { | ||
97 | - numauthpriv = 2; | ||
98 | - authpriv = calloc (numauthpriv, sizeof (char *)); | ||
99 | - authpriv[0] = strdup ("-l"); | ||
100 | - authpriv[1] = strdup ("noAuthNoPriv"); | ||
101 | + if (proto == NULL || strcmp (proto, "3") == 0) { | ||
102 | + // No protocol will pass any valid parameter. See note before function for more explanation | ||
103 | + if (proto == NULL) { | ||
104 | + addParam("-c",community); | ||
105 | } else { | ||
106 | - if (! ( (strcmp(seclevel, "authNoPriv")==0) || (strcmp(seclevel, "authPriv")==0) ) ) { | ||
107 | - usage2 (_("Invalid seclevel"), seclevel); | ||
108 | - } | ||
109 | - | ||
110 | - if (authproto == NULL ) | ||
111 | - asprintf(&authproto, DEFAULT_AUTH_PROTOCOL); | ||
112 | - | ||
113 | - if (secname == NULL) | ||
114 | - die(STATE_UNKNOWN, _("Required parameter: %s\n"), "secname"); | ||
115 | - | ||
116 | - if (authpasswd == NULL) | ||
117 | - die(STATE_UNKNOWN, _("Required parameter: %s\n"), "authpasswd"); | ||
118 | - | ||
119 | - if ( strcmp(seclevel, "authNoPriv") == 0 ) { | ||
120 | - numauthpriv = 8; | ||
121 | - authpriv = calloc (numauthpriv, sizeof (char *)); | ||
122 | - authpriv[0] = strdup ("-l"); | ||
123 | - authpriv[1] = strdup ("authNoPriv"); | ||
124 | - authpriv[2] = strdup ("-a"); | ||
125 | - authpriv[3] = strdup (authproto); | ||
126 | - authpriv[4] = strdup ("-u"); | ||
127 | - authpriv[5] = strdup (secname); | ||
128 | - authpriv[6] = strdup ("-A"); | ||
129 | - authpriv[7] = strdup (authpasswd); | ||
130 | - } else if ( strcmp(seclevel, "authPriv") == 0 ) { | ||
131 | - if (privproto == NULL ) | ||
132 | - asprintf(&privproto, DEFAULT_PRIV_PROTOCOL); | ||
133 | - | ||
134 | - if (privpasswd == NULL) | ||
135 | - die(STATE_UNKNOWN, _("Required parameter: %s\n"), "privpasswd"); | ||
136 | - | ||
137 | - numauthpriv = 12; | ||
138 | - authpriv = calloc (numauthpriv, sizeof (char *)); | ||
139 | - authpriv[0] = strdup ("-l"); | ||
140 | - authpriv[1] = strdup ("authPriv"); | ||
141 | - authpriv[2] = strdup ("-a"); | ||
142 | - authpriv[3] = strdup (authproto); | ||
143 | - authpriv[4] = strdup ("-u"); | ||
144 | - authpriv[5] = strdup (secname); | ||
145 | - authpriv[6] = strdup ("-A"); | ||
146 | - authpriv[7] = strdup (authpasswd); | ||
147 | - authpriv[8] = strdup ("-x"); | ||
148 | - authpriv[9] = strdup (privproto); | ||
149 | - authpriv[10] = strdup ("-X"); | ||
150 | - authpriv[11] = strdup (privpasswd); | ||
151 | - } | ||
152 | + addParam("-v",proto); | ||
153 | } | ||
154 | + addParam("-u",secname); | ||
155 | |||
156 | - } | ||
157 | - else { | ||
158 | + if (seclevel == NULL || strcmp(seclevel, "authPriv")==0) { | ||
159 | + addParam("-l",seclevel); | ||
160 | + addParam("-a",authproto); | ||
161 | + addParam("-A",authpasswd); | ||
162 | + addParam("-x",privproto); | ||
163 | + addParam("-X",privpasswd); | ||
164 | + } else if (strcmp(seclevel, "noAuthNoPriv") == 0) { | ||
165 | + addParam("-v",proto); | ||
166 | + addParam("-l",seclevel); | ||
167 | + } else if (strcmp(seclevel, "authNoPriv")==0) { | ||
168 | + addParam("-v",proto); | ||
169 | + addParam("-l",seclevel); | ||
170 | + addParam("-a",authproto); | ||
171 | + addParam("-A",authpasswd); | ||
172 | + } else { | ||
173 | + usage2 (_("Invalid seclevel"), seclevel); | ||
174 | + } | ||
175 | + } else if ((strcmp(proto,"1") == 0) || (strcmp(proto, "2c")==0)) { /* snmpv1 or snmpv2c */ | ||
176 | + // If we specified protocol v2, the only param that is usefull is community string (if specified). | ||
177 | + addParam("-v",proto); | ||
178 | + addParam("-c",community); | ||
179 | + } else { | ||
180 | usage2 (_("Invalid SNMP version"), proto); | ||
181 | } | ||
182 | |||
183 | @@ -1011,12 +1004,11 @@ | ||
184 | printf (" %s\n", "-a, --authproto=[MD5|SHA]"); | ||
185 | printf (" %s\n", _("SNMPv3 auth proto")); | ||
186 | printf (" %s\n", "-x, --privproto=[DES|AES]"); | ||
187 | - printf (" %s\n", _("SNMPv3 priv proto (default DES)")); | ||
188 | + printf (" %s\n", _("SNMPv3 priv proto")); | ||
189 | |||
190 | /* Authentication Tokens*/ | ||
191 | printf (" %s\n", "-C, --community=STRING"); | ||
192 | printf (" %s ", _("Optional community string for SNMP communication")); | ||
193 | - printf ("(%s \"%s\")\n", _("default is") ,DEFAULT_COMMUNITY); | ||
194 | printf (" %s\n", "-U, --secname=USERNAME"); | ||
195 | printf (" %s\n", _("SNMPv3 username")); | ||
196 | printf (" %s\n", "-A, --authpassword=PASSWORD"); | ||
197 | @@ -1076,6 +1068,8 @@ | ||
198 | |||
199 | printf ("\n"); | ||
200 | printf ("%s\n", _("Notes:")); | ||
201 | + printf (" %s\n", _("- Default configurations are retrieved from /etc/snmp/snmp.conf. See man page of")); | ||
202 | + printf (" %s\n", _("snmp.conf for more information.")); | ||
203 | printf (" %s\n", _("- Multiple OIDs may be indicated by a comma or space-delimited list (lists with")); | ||
204 | printf (" %s %i %s\n", _("internal spaces must be quoted). Maximum:"), MAX_OIDS, _("OIDs.")); | ||
205 | |||