summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@aei.ca>2010-04-14 03:38:52 -0400
committerThomas Guyot-Sionnest <dermoth@aei.ca>2010-04-14 03:38:52 -0400
commita179737771ece982e1840d480b10cb6ed1792619 (patch)
tree62240812a399c61fe301240ac5ca165abc2bf393
parente7cefa7be491050b6dc895f6cfab82c5ead340a7 (diff)
downloadmonitoring-plugins-a179737771ece982e1840d480b10cb6ed1792619.tar.gz
Fix check_radius returning OK on unexpected results
REJECT_RC is defined on some radiusclient versions and differenciates between auth errors and bad responses. This patch will affect only the behaviour of those clients exporting REJECT_RC. In addition, unexpected return codes are now handled properly and return UNKNOWN.
-rw-r--r--NEWS1
-rw-r--r--THANKS.in1
-rw-r--r--plugins/check_radius.c14
3 files changed, 14 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index b698768f..8a11b321 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,7 @@ This file documents the major additions and syntax changes between releases.
19 Fix check_disk_smb and check_ircd failures when run via ePN 19 Fix check_disk_smb and check_ircd failures when run via ePN
20 check_ldap now allows for specifying an empty LDAP base 20 check_ldap now allows for specifying an empty LDAP base
21 Fix compilation error of pst3 in Solaris 8 21 Fix compilation error of pst3 in Solaris 8
22 Fix check_radius returning OK on unexpected results (Craig Leres - #2911752)
22 WARNINGS 23 WARNINGS
23 Updated developer documentation to say that performance labels should not have an equals sign or 24 Updated developer documentation to say that performance labels should not have an equals sign or
24 single quote in the label 25 single quote in the label
diff --git a/THANKS.in b/THANKS.in
index f62a4d8e..0b1dab6c 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -263,3 +263,4 @@ Konstantin Khomoutov
263Josip Rodin 263Josip Rodin
264Dann Frazier 264Dann Frazier
265Stephane Chazelas 265Stephane Chazelas
266Craig Leres
diff --git a/plugins/check_radius.c b/plugins/check_radius.c
index 37176257..b2f5732c 100644
--- a/plugins/check_radius.c
+++ b/plugins/check_radius.c
@@ -63,6 +63,13 @@ void print_usage (void);
63#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(a, b, c, d) 63#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(a, b, c, d)
64#define my_rc_read_dictionary(a) rc_read_dictionary(a) 64#define my_rc_read_dictionary(a) rc_read_dictionary(a)
65#endif 65#endif
66
67/* REJECT_RC is only defined in some version of radiusclient. It has
68 * been reported from radiusclient-ng 0.5.6 on FreeBSD 7.2-RELEASE */
69#ifndef REJECT_RC
70#define REJECT_RC BADRESP_RC
71#endif
72
66int my_rc_read_config(char *); 73int my_rc_read_config(char *);
67 74
68char *server = NULL; 75char *server = NULL;
@@ -195,13 +202,16 @@ main (int argc, char **argv)
195 die (STATE_CRITICAL, _("Timeout")); 202 die (STATE_CRITICAL, _("Timeout"));
196 if (result == ERROR_RC) 203 if (result == ERROR_RC)
197 die (STATE_CRITICAL, _("Auth Error")); 204 die (STATE_CRITICAL, _("Auth Error"));
198 if (result == BADRESP_RC) 205 if (result == REJECT_RC)
199 die (STATE_WARNING, _("Auth Failed")); 206 die (STATE_WARNING, _("Auth Failed"));
207 if (result == BADRESP_RC)
208 die (STATE_WARNING, _("Bad Response"));
200 if (expect && !strstr (msg, expect)) 209 if (expect && !strstr (msg, expect))
201 die (STATE_WARNING, "%s", msg); 210 die (STATE_WARNING, "%s", msg);
202 if (result == OK_RC) 211 if (result == OK_RC)
203 die (STATE_OK, _("Auth OK")); 212 die (STATE_OK, _("Auth OK"));
204 return (0); 213 (void)snprintf(msg, sizeof(msg), _("Unexpected result code %d"), result);
214 die (STATE_UNKNOWN, msg);
205} 215}
206 216
207 217