summaryrefslogtreecommitdiffstats
path: root/web/attachments/240320-ifdef.patch
blob: 983a1cec544dfe9a1d6bc16c9355bfcefd9c6854 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
--- check_radius_orig.c	2007-08-07 22:34:39.000000000 +0200
+++ check_radius_ifdef.c	2007-08-07 22:34:01.000000000 +0200
@@ -42,8 +42,12 @@
 #include "common.h"
 #include "utils.h"
 #include "netutils.h"
-
+#ifdef HAVE_LIBRADIUSCLIENT_NG
+#include <radiusclient-ng.h>
+rc_handle *rch = NULL;
+#else
 #include <radiusclient.h>
+#endif
 
 int process_arguments (int, char **);
 void print_help (void);
@@ -133,26 +137,49 @@
 		usage4 (_("Could not parse arguments"));
 
 	str = strdup ("dictionary");
+#ifdef HAVE_LIBRADIUSCLIENT_NG
+	if ((config_file && ! (rch = rc_read_config (config_file))) ||
+			rc_read_dictionary (rch, rc_conf_str (rch, str)))
+#else
 	if ((config_file && rc_read_config (config_file)) ||
 			rc_read_dictionary (rc_conf_str (str)))
+#endif
 		die (STATE_UNKNOWN, _("Config file error"));
 
 	service = PW_AUTHENTICATE_ONLY;
 
 	memset (&data, 0, sizeof(data));
+#ifdef HAVE_LIBRADIUSCLIENT_NG
+	if (!(rc_avpair_add (rch, &data.send_pairs, PW_SERVICE_TYPE, &service, -1, 0) &&
+				rc_avpair_add (rch, &data.send_pairs, PW_USER_NAME, username, -1, 0) &&
+				rc_avpair_add (rch, &data.send_pairs, PW_USER_PASSWORD, password, -1, 0) &&
+				(nasid==NULL || rc_avpair_add (rch, &data.send_pairs, PW_NAS_IDENTIFIER, nasid, -1, 0))))
+#else
 	if (!(rc_avpair_add (&data.send_pairs, PW_SERVICE_TYPE, &service, 0) &&
 				rc_avpair_add (&data.send_pairs, PW_USER_NAME, username, 0) &&
 				rc_avpair_add (&data.send_pairs, PW_USER_PASSWORD, password, 0) &&
 				(nasid==NULL || rc_avpair_add (&data.send_pairs, PW_NAS_IDENTIFIER, nasid, 0))))
+#endif
 		die (STATE_UNKNOWN, _("Out of Memory?"));
 
 	/* 
 	 * Fill in NAS-IP-Address 
 	 */
 
+#ifdef HAVE_LIBRADIUSCLIENT_NG
+	if ((client_id = rc_own_ipaddress (rch)) == 0)
+#else
 	if ((client_id = rc_own_ipaddress ()) == 0)
+#endif
 		return (ERROR_RC);
 
+#ifdef HAVE_LIBRADIUSCLIENT_NG
+	if (rc_avpair_add (rch, &(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id,-1, 0) ==
+			NULL) return (ERROR_RC);
+	rc_buildreq (rch, &data, PW_ACCESS_REQUEST, server, port, (int)timeout_interval,
+	             retries);
+	result = rc_send_server (rch, &data, msg);
+#else
 	if (rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) ==
 			NULL) return (ERROR_RC);
 
@@ -160,6 +187,8 @@
 	             retries);
 
 	result = rc_send_server (&data, msg);
+#endif
+
 	rc_avpair_free (data.send_pairs);
 	if (data.receive_pairs)
 		rc_avpair_free (data.receive_pairs);