40 |
/* ************************************************************************* */ |
/* ************************************************************************* */ |
41 |
/* Functions local to this module */ |
/* Functions local to this module */ |
42 |
|
|
43 |
/* |
/* Decode a password and encode it again. */ |
|
* Decode a password and encode it again. |
|
|
*/ |
|
44 |
static void |
static void |
45 |
passwd_recode(VALUE_PAIR *pass_pair, char *new_secret, char *new_vector, |
passwd_recode(VALUE_PAIR *pass_pair, char *new_secret, char *new_vector, |
46 |
RADIUS_REQ *req) |
RADIUS_REQ *req) |
53 |
memset(password, 0, AUTH_STRING_LEN); |
memset(password, 0, AUTH_STRING_LEN); |
54 |
} |
} |
55 |
|
|
56 |
|
/* Decode a password and encode it again. */ |
57 |
|
static void |
58 |
|
tunnel_passwd_recode(VALUE_PAIR *pass_pair, char *new_secret, char *new_vector, |
59 |
|
RADIUS_REQ *req) |
60 |
|
{ |
61 |
|
char password[AUTH_STRING_LEN+1]; |
62 |
|
u_char tag; |
63 |
|
|
64 |
|
decrypt_tunnel_password(password, |
65 |
|
&tag, pass_pair, |
66 |
|
req->vector, req->secret); |
67 |
|
efree(pass_pair->avp_strvalue); |
68 |
|
encrypt_tunnel_password(pass_pair, |
69 |
|
tag, password, |
70 |
|
new_vector, new_secret); |
71 |
|
memset(password, 0, AUTH_STRING_LEN); |
72 |
|
} |
73 |
|
|
74 |
|
VALUE_PAIR * |
75 |
|
proxy_request_recode(RADIUS_REQ *radreq, VALUE_PAIR *plist, |
76 |
|
u_char *secret, u_char *vector) |
77 |
|
{ |
78 |
|
VALUE_PAIR *p; |
79 |
|
|
80 |
|
/* Recode password pair(s) */ |
81 |
|
for (p = plist; p; p = p->next) { |
82 |
|
if (p->prop & AP_ENCRYPT_RFC2138) |
83 |
|
passwd_recode(p, secret, vector, radreq); |
84 |
|
else if (p->prop & AP_ENCRYPT_RFC2868) |
85 |
|
tunnel_passwd_recode(p, secret, vector, radreq); |
86 |
|
} |
87 |
|
return plist; |
88 |
|
} |
89 |
|
|
90 |
/* ************************************************************************* */ |
/* ************************************************************************* */ |
91 |
/* Functions for finding the matching request in the list of outstanding ones. |
/* Functions for finding the matching request in the list of outstanding ones. |
92 |
*/ |
*/ |
171 |
return sendto(fd, pdu, size, 0, (struct sockaddr *)&sin, sizeof(sin)); |
return sendto(fd, pdu, size, 0, (struct sockaddr *)&sin, sizeof(sin)); |
172 |
} |
} |
173 |
|
|
|
VALUE_PAIR * |
|
|
proxy_request_recode(RADIUS_REQ *radreq, u_char *secret, u_char *vector) |
|
|
{ |
|
|
VALUE_PAIR *p, *plist = avl_dup(radreq->request); |
|
|
|
|
|
/* Recode password pair(s) */ |
|
|
for (p = plist; p; p = p->next) { |
|
|
if (p->attribute == DA_USER_PASSWORD |
|
|
|| p->attribute == DA_CHAP_PASSWORD) |
|
|
passwd_recode(p, secret, vector, radreq); |
|
|
} |
|
|
return plist; |
|
|
} |
|
|
|
|
174 |
int |
int |
175 |
proxy_send_request(int fd, RADIUS_REQ *radreq) |
proxy_send_request(int fd, RADIUS_REQ *radreq) |
176 |
{ |
{ |
200 |
|
|
201 |
rad_clt_random_vector(vector); |
rad_clt_random_vector(vector); |
202 |
|
|
203 |
plist = proxy_request_recode(radreq, server->secret, vector); |
plist = proxy_request_recode(radreq, avl_dup(radreq->request), |
204 |
|
server->secret, vector); |
205 |
|
|
206 |
/* Add a proxy-pair to the end of the request. */ |
/* Add a proxy-pair to the end of the request. */ |
207 |
p = avp_alloc(); |
p = avp_alloc(); |
419 |
|
|
420 |
/* Rebuild the RADIUS_REQ struct, so that the normal functions |
/* Rebuild the RADIUS_REQ struct, so that the normal functions |
421 |
can process it. Take care not to modify oldreq! */ |
can process it. Take care not to modify oldreq! */ |
422 |
|
|
423 |
radreq->server_reply = allowed_pairs; |
radreq->server_reply = proxy_request_recode(radreq, allowed_pairs, |
424 |
|
oldreq->secret, |
425 |
|
oldreq->vector); |
426 |
radreq->validated = 1; |
radreq->validated = 1; |
427 |
radreq->server_code = radreq->code; |
radreq->server_code = radreq->code; |
428 |
radreq->code = oldreq->code; |
radreq->code = oldreq->code; |