summaryrefslogtreecommitdiffstats
path: root/plugins/check_radius.c
diff options
context:
space:
mode:
authorMatthias Eble <psychotrahe@users.sourceforge.net>2007-09-23 09:48:37 +0000
committerMatthias Eble <psychotrahe@users.sourceforge.net>2007-09-23 09:48:37 +0000
commitd1c9a5cf6a8c5e7990e3efd167d84dc8f1d8a042 (patch)
treedd9b6cc027c1a84e7c7af35fa167ef84dfcb6dc5 /plugins/check_radius.c
parentbb32ecb79c6e4d7161f0bee54e4197fca64d23d6 (diff)
downloadmonitoring-plugins-d1c9a5cf6a8c5e7990e3efd167d84dc8f1d8a042.tar.gz
Added radiusclient-ng support for check_radius. Thanks to Sebastien Guay (#1218438)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1788 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_radius.c')
-rw-r--r--plugins/check_radius.c55
1 files changed, 45 insertions, 10 deletions
diff --git a/plugins/check_radius.c b/plugins/check_radius.c
index 4b340c3b..32af91fa 100644
--- a/plugins/check_radius.c
+++ b/plugins/check_radius.c
@@ -43,12 +43,35 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
43#include "utils.h" 43#include "utils.h"
44#include "netutils.h" 44#include "netutils.h"
45 45
46#ifdef HAVE_LIBRADIUSCLIENT_NG
47#include <radiusclient-ng.h>
48rc_handle *rch = NULL;
49#else
46#include <radiusclient.h> 50#include <radiusclient.h>
51#endif
47 52
48int process_arguments (int, char **); 53int process_arguments (int, char **);
49void print_help (void); 54void print_help (void);
50void print_usage (void); 55void print_usage (void);
51 56
57/* libradiusclient(-ng) wrapper functions */
58#ifdef HAVE_LIBRADIUSCLIENT_NG
59#define my_rc_conf_str(a) rc_conf_str(rch,a)
60#define my_rc_send_server(a,b) rc_send_server(rch,a,b)
61#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,e,f)
62#define my_rc_own_ipaddress() rc_own_ipaddress(rch)
63#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(rch,a,b,c,-1,d)
64#define my_rc_read_dictionary(a) rc_read_dictionary(rch, a)
65#else
66#define my_rc_conf_str(a) rc_conf_str(a)
67#define my_rc_send_server(a,b) rc_send_server(a, b)
68#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(a,b,c,d,e,f)
69#define my_rc_own_ipaddress() rc_own_ipaddress()
70#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(a, b, c, d)
71#define my_rc_read_dictionary(a) rc_read_dictionary(a)
72#endif
73int my_rc_read_config(char *);
74
52char *server = NULL; 75char *server = NULL;
53char *username = NULL; 76char *username = NULL;
54char *password = NULL; 77char *password = NULL;
@@ -133,33 +156,33 @@ main (int argc, char **argv)
133 usage4 (_("Could not parse arguments")); 156 usage4 (_("Could not parse arguments"));
134 157
135 str = strdup ("dictionary"); 158 str = strdup ("dictionary");
136 if ((config_file && rc_read_config (config_file)) || 159 if ((config_file && my_rc_read_config (config_file)) ||
137 rc_read_dictionary (rc_conf_str (str))) 160 my_rc_read_dictionary (my_rc_conf_str (str)))
138 die (STATE_UNKNOWN, _("Config file error")); 161 die (STATE_UNKNOWN, _("Config file error"));
139 162
140 service = PW_AUTHENTICATE_ONLY; 163 service = PW_AUTHENTICATE_ONLY;
141 164
142 memset (&data, 0, sizeof(data)); 165 memset (&data, 0, sizeof(data));
143 if (!(rc_avpair_add (&data.send_pairs, PW_SERVICE_TYPE, &service, 0) && 166 if (!(my_rc_avpair_add (&data.send_pairs, PW_SERVICE_TYPE, &service, 0) &&
144 rc_avpair_add (&data.send_pairs, PW_USER_NAME, username, 0) && 167 my_rc_avpair_add (&data.send_pairs, PW_USER_NAME, username, 0) &&
145 rc_avpair_add (&data.send_pairs, PW_USER_PASSWORD, password, 0) && 168 my_rc_avpair_add (&data.send_pairs, PW_USER_PASSWORD, password, 0) &&
146 (nasid==NULL || rc_avpair_add (&data.send_pairs, PW_NAS_IDENTIFIER, nasid, 0)))) 169 (nasid==NULL || my_rc_avpair_add (&data.send_pairs, PW_NAS_IDENTIFIER, nasid, 0))))
147 die (STATE_UNKNOWN, _("Out of Memory?")); 170 die (STATE_UNKNOWN, _("Out of Memory?"));
148 171
149 /* 172 /*
150 * Fill in NAS-IP-Address 173 * Fill in NAS-IP-Address
151 */ 174 */
152 175
153 if ((client_id = rc_own_ipaddress ()) == 0) 176 if ((client_id = my_rc_own_ipaddress ()) == 0)
154 return (ERROR_RC); 177 return (ERROR_RC);
155 178
156 if (rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) == 179 if (my_rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) ==
157 NULL) return (ERROR_RC); 180 NULL) return (ERROR_RC);
158 181
159 rc_buildreq (&data, PW_ACCESS_REQUEST, server, port, (int)timeout_interval, 182 my_rc_buildreq (&data, PW_ACCESS_REQUEST, server, port, (int)timeout_interval,
160 retries); 183 retries);
161 184
162 result = rc_send_server (&data, msg); 185 result = my_rc_send_server (&data, msg);
163 rc_avpair_free (data.send_pairs); 186 rc_avpair_free (data.send_pairs);
164 if (data.receive_pairs) 187 if (data.receive_pairs)
165 rc_avpair_free (data.receive_pairs); 188 rc_avpair_free (data.receive_pairs);
@@ -350,3 +373,15 @@ print_usage (void)
350 printf ("%s -H host -F config_file -u username -p password [-n nas-id] [-P port]\n\ 373 printf ("%s -H host -F config_file -u username -p password [-n nas-id] [-P port]\n\
351 [-t timeout] [-r retries] [-e expect]\n", progname); 374 [-t timeout] [-r retries] [-e expect]\n", progname);
352} 375}
376
377
378
379int my_rc_read_config(char * a)
380{
381#ifdef HAVE_LIBRADIUSCLIENT_NG
382 rch = rc_read_config(a);
383 return (rch == NULL) ? 1 : 0;
384#else
385 return rc_read_config(a);
386#endif
387}