diff options
| author | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2010-04-14 03:38:52 -0400 |
|---|---|---|
| committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2010-04-14 03:38:52 -0400 |
| commit | a179737771ece982e1840d480b10cb6ed1792619 (patch) | |
| tree | 62240812a399c61fe301240ac5ca165abc2bf393 /plugins | |
| parent | e7cefa7be491050b6dc895f6cfab82c5ead340a7 (diff) | |
| download | monitoring-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')
| -rw-r--r-- | plugins/check_radius.c | 14 |
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); | |||
| 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 | |||
| 66 | int my_rc_read_config(char *); | 73 | int my_rc_read_config(char *); |
| 67 | 74 | ||
| 68 | char *server = NULL; | 75 | char *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 | ||
