aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_radius.c
diff options
context:
space:
mode:
authorGravatar Thomas Guyot-Sionnest <dermoth@aei.ca> 2010-04-14 03:38:52 -0400
committerGravatar Thomas Guyot-Sionnest <dermoth@aei.ca> 2010-04-14 03:38:52 -0400
commita179737771ece982e1840d480b10cb6ed1792619 (patch)
tree62240812a399c61fe301240ac5ca165abc2bf393 /plugins/check_radius.c
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.
Diffstat (limited to 'plugins/check_radius.c')
-rw-r--r--plugins/check_radius.c14
1 files changed, 12 insertions, 2 deletions
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);
#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(a, b, c, d)
#define my_rc_read_dictionary(a) rc_read_dictionary(a)
#endif
+
+/* REJECT_RC is only defined in some version of radiusclient. It has
+ * been reported from radiusclient-ng 0.5.6 on FreeBSD 7.2-RELEASE */
+#ifndef REJECT_RC
+#define REJECT_RC BADRESP_RC
+#endif
+
int my_rc_read_config(char *);
char *server = NULL;
@@ -195,13 +202,16 @@ main (int argc, char **argv)
die (STATE_CRITICAL, _("Timeout"));
if (result == ERROR_RC)
die (STATE_CRITICAL, _("Auth Error"));
- if (result == BADRESP_RC)
+ if (result == REJECT_RC)
die (STATE_WARNING, _("Auth Failed"));
+ if (result == BADRESP_RC)
+ die (STATE_WARNING, _("Bad Response"));
if (expect && !strstr (msg, expect))
die (STATE_WARNING, "%s", msg);
if (result == OK_RC)
die (STATE_OK, _("Auth OK"));
- return (0);
+ (void)snprintf(msg, sizeof(msg), _("Unexpected result code %d"), result);
+ die (STATE_UNKNOWN, msg);
}