diff options
author | Kozlov Dmitry <dima@server> | 2010-09-09 11:01:43 +0400 |
---|---|---|
committer | Kozlov Dmitry <dima@server> | 2010-09-09 11:01:43 +0400 |
commit | 29b03dcfbd3b4783b0192e5f8c9bb6281acf44d5 (patch) | |
tree | 7e530a420c4c303706e39cc917f0ad8ea5d657e2 /accel-pptpd/auth/auth_mschap_v2.c | |
parent | 4dcca9422c5c001789b17c3266f3db8e0590568d (diff) | |
download | accel-ppp-29b03dcfbd3b4783b0192e5f8c9bb6281acf44d5.tar.gz accel-ppp-29b03dcfbd3b4783b0192e5f8c9bb6281acf44d5.zip |
radius: implemented accounting (start/stop/interim-update)
Diffstat (limited to 'accel-pptpd/auth/auth_mschap_v2.c')
-rw-r--r-- | accel-pptpd/auth/auth_mschap_v2.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/accel-pptpd/auth/auth_mschap_v2.c b/accel-pptpd/auth/auth_mschap_v2.c index 01127cf7..6f1de0ed 100644 --- a/accel-pptpd/auth/auth_mschap_v2.c +++ b/accel-pptpd/auth/auth_mschap_v2.c @@ -95,7 +95,7 @@ struct chap_auth_data_t static void chap_send_challenge(struct chap_auth_data_t *ad); static void chap_recv(struct ppp_handler_t *h); -static int chap_check_response(struct chap_auth_data_t *ad, struct chap_response_t *res); +static int chap_check_response(struct chap_auth_data_t *ad, struct chap_response_t *res, char *name); static void print_buf(const uint8_t *buf,int size) { @@ -289,6 +289,7 @@ static void chap_send_challenge(struct chap_auth_data_t *ad) static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *hdr) { struct chap_response_t *msg=(struct chap_response_t*)hdr; + char *name; log_debug("recv [MSCHAP-v2 Response id=%x <", msg->hdr.id); print_buf(msg->peer_challenge,16); @@ -312,14 +313,22 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h ppp_terminate(ad->ppp, 0); } - if (chap_check_response(ad,msg)) + name=strndup(msg->name,ntohs(msg->hdr.len)-sizeof(*msg)+2); + if (!name) { + log_error("mschap-v2: out of memory\n"); + auth_failed(ad->ppp); + return; + } + + if (chap_check_response(ad, msg, name)) { chap_send_failure(ad); auth_failed(ad->ppp); + free(name); }else { chap_send_success(ad,msg); - auth_successed(ad->ppp); + auth_successed(ad->ppp, name); } } @@ -352,7 +361,7 @@ static void des_encrypt(const uint8_t *input, const uint8_t *key, uint8_t *outpu memcpy(output,res,8); } -static int chap_check_response(struct chap_auth_data_t *ad, struct chap_response_t *msg) +static int chap_check_response(struct chap_auth_data_t *ad, struct chap_response_t *msg, char *name) { MD4_CTX md4_ctx; SHA_CTX sha_ctx; @@ -361,10 +370,8 @@ static int chap_check_response(struct chap_auth_data_t *ad, struct chap_response uint8_t nt_hash[24]; char *passwd; char *u_passwd; - char *name; int i; - name=strndup(msg->name,ntohs(msg->hdr.len)-sizeof(*msg)+2); passwd=pwdb_get_passwd(ad->ppp,name); if (!passwd) { |