summaryrefslogtreecommitdiffstats
path: root/plugins/check_radius.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_radius.c')
-rw-r--r--plugins/check_radius.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/plugins/check_radius.c b/plugins/check_radius.c
index 518f158..b3b8c82 100644
--- a/plugins/check_radius.c
+++ b/plugins/check_radius.c
@@ -62,14 +62,12 @@ void print_usage (void);
62#else 62#else
63#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,e,f) 63#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,e,f)
64#endif 64#endif
65#define my_rc_own_ipaddress() rc_own_ipaddress(rch)
66#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(rch,a,b,c,-1,d) 65#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(rch,a,b,c,-1,d)
67#define my_rc_read_dictionary(a) rc_read_dictionary(rch, a) 66#define my_rc_read_dictionary(a) rc_read_dictionary(rch, a)
68#else 67#else
69#define my_rc_conf_str(a) rc_conf_str(a) 68#define my_rc_conf_str(a) rc_conf_str(a)
70#define my_rc_send_server(a,b) rc_send_server(a, b) 69#define my_rc_send_server(a,b) rc_send_server(a, b)
71#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(a,b,c,d,e,f) 70#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(a,b,c,d,e,f)
72#define my_rc_own_ipaddress() rc_own_ipaddress()
73#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(a, b, c, d) 71#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(a, b, c, d)
74#define my_rc_read_dictionary(a) rc_read_dictionary(a) 72#define my_rc_read_dictionary(a) rc_read_dictionary(a)
75#endif 73#endif
@@ -155,6 +153,8 @@ Please note that all tags must be lowercase to use the DocBook XML DTD.
155int 153int
156main (int argc, char **argv) 154main (int argc, char **argv)
157{ 155{
156 struct sockaddr_storage ss;
157 char name[HOST_NAME_MAX];
158 char msg[BUFFER_LEN]; 158 char msg[BUFFER_LEN];
159 SEND_DATA data; 159 SEND_DATA data;
160 int result = STATE_UNKNOWN; 160 int result = STATE_UNKNOWN;
@@ -190,15 +190,14 @@ main (int argc, char **argv)
190 die (STATE_UNKNOWN, _("Invalid NAS-Identifier\n")); 190 die (STATE_UNKNOWN, _("Invalid NAS-Identifier\n"));
191 } 191 }
192 192
193 if (nasipaddress != NULL) { 193 if (nasipaddress == NULL) {
194 if (rc_good_ipaddr (nasipaddress)) 194 if (gethostname (name, sizeof(name)) != 0)
195 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n")); 195 die (STATE_UNKNOWN, _("gethostname() failed!\n"));
196 if ((client_id = rc_get_ipaddr(nasipaddress)) == 0) 196 nasipaddress = name;
197 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
198 } else {
199 if ((client_id = my_rc_own_ipaddress ()) == 0)
200 die (STATE_UNKNOWN, _("Can't find local IP for NAS-IP-Address\n"));
201 } 197 }
198 if (!dns_lookup (nasipaddress, &ss, AF_INET)) /* TODO: Support IPv6. */
199 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
200 client_id = ntohl (((struct sockaddr_in *)&ss)->sin_addr.s_addr);
202 if (my_rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) == NULL) 201 if (my_rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) == NULL)
203 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n")); 202 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
204 203