summaryrefslogtreecommitdiffstats
path: root/web/attachments/240319-wrapper.patch
blob: 0d852efc0ac67f37270ef77181dd9d289824cb76 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
--- check_radius_orig.c	2007-08-07 22:34:39.000000000 +0200
+++ check_radius.c	2007-08-07 23:07:46.000000000 +0200
@@ -43,12 +43,28 @@
 #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);
 void print_usage (void);
 
+/* libradiusclient(-ng) wrapper functions */
+int my_rc_read_dictionary(const char *);
+VALUE_PAIR *my_rc_avpair_add(VALUE_PAIR **, int, void *, int);
+UINT4 my_rc_own_ipaddress();
+void my_rc_buildreq(SEND_DATA *, int, char *, unsigned short, int, int);
+int my_rc_send_server(SEND_DATA *, char *);
+char *my_rc_conf_str(char *);
+int my_rc_read_config(char *);
+
+
+
 char *server = NULL;
 char *username = NULL;
 char *password = NULL;
@@ -133,33 +149,33 @@
 		usage4 (_("Could not parse arguments"));
 
 	str = strdup ("dictionary");
-	if ((config_file && rc_read_config (config_file)) ||
-			rc_read_dictionary (rc_conf_str (str)))
+	if ((config_file && my_rc_read_config (config_file)) ||
+			my_rc_read_dictionary (my_rc_conf_str (str)))
 		die (STATE_UNKNOWN, _("Config file error"));
 
 	service = PW_AUTHENTICATE_ONLY;
 
 	memset (&data, 0, sizeof(data));
-	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))))
+	if (!(my_rc_avpair_add (&data.send_pairs, PW_SERVICE_TYPE, &service, 0) &&
+				my_rc_avpair_add (&data.send_pairs, PW_USER_NAME, username, 0) &&
+				my_rc_avpair_add (&data.send_pairs, PW_USER_PASSWORD, password, 0) &&
+				(nasid==NULL || my_rc_avpair_add (&data.send_pairs, PW_NAS_IDENTIFIER, nasid, 0))))
 		die (STATE_UNKNOWN, _("Out of Memory?"));
 
 	/* 
 	 * Fill in NAS-IP-Address 
 	 */
 
-	if ((client_id = rc_own_ipaddress ()) == 0)
+	if ((client_id = my_rc_own_ipaddress ()) == 0)
 		return (ERROR_RC);
 
-	if (rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) ==
+	if (my_rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) ==
 			NULL) return (ERROR_RC);
 
-	rc_buildreq (&data, PW_ACCESS_REQUEST, server, port, (int)timeout_interval,
+	my_rc_buildreq (&data, PW_ACCESS_REQUEST, server, port, (int)timeout_interval,
 	             retries);
 
-	result = rc_send_server (&data, msg);
+	result = my_rc_send_server (&data, msg);
 	rc_avpair_free (data.send_pairs);
 	if (data.receive_pairs)
 		rc_avpair_free (data.receive_pairs);
@@ -350,3 +366,70 @@
 	printf ("%s -H host -F config_file -u username -p password [-n nas-id] [-P port]\n\
                   [-t timeout] [-r retries] [-e expect]\n", progname);
 }
+
+
+
+
+int my_rc_read_dictionary(const char * a)
+{
+#ifdef HAVE_LIBRADIUSCLIENT_NG
+	return rc_read_dictionary(rch, a);
+#else
+	return rc_read_dictionary(a);
+#endif
+}
+
+VALUE_PAIR *my_rc_avpair_add(VALUE_PAIR ** a, int b, void * c, int d)
+{
+#ifdef HAVE_LIBRADIUSCLIENT_NG
+	return rc_avpair_add(rch, a, b, c, -1, d);
+#else
+	return rc_avpair_add(a, b, c, d);
+#endif
+}
+
+UINT4 my_rc_own_ipaddress()
+{
+#ifdef HAVE_LIBRADIUSCLIENT_NG
+	return rc_own_ipaddress(rch);
+#else
+	return rc_own_ipaddress();
+#endif
+}
+
+void my_rc_buildreq(SEND_DATA * a, int b, char * c, unsigned short d, int e, int f)
+{
+#ifdef HAVE_LIBRADIUSCLIENT_NG
+	return rc_buildreq(rch, a, b, c, d, e, f);
+#else
+	return rc_buildreq(a, b, c, d, e, f);
+#endif
+}
+
+int my_rc_send_server(SEND_DATA * a, char * b)
+{
+#ifdef HAVE_LIBRADIUSCLIENT_NG
+	return rc_send_server(rch, a, b);
+#else
+	return rc_send_server(a, b);
+#endif
+}
+
+int my_rc_read_config(char * a)
+{
+#ifdef HAVE_LIBRADIUSCLIENT_NG
+	rch = rc_read_config(a);
+	return (rch == NULL) ? 1 : 0;
+#else
+	return rc_read_config(a);
+#endif
+}
+
+char *my_rc_conf_str(char * a)
+{
+#ifdef HAVE_LIBRADIUSCLIENT_NG
+	return rc_conf_str(rch, a);
+#else
+	return rc_conf_str(a);
+#endif
+}