summaryrefslogtreecommitdiff
path: root/accel-pptpd/auth
diff options
context:
space:
mode:
authorKozlov Dmitry <dima@server>2010-09-09 11:01:43 +0400
committerKozlov Dmitry <dima@server>2010-09-09 11:01:43 +0400
commit29b03dcfbd3b4783b0192e5f8c9bb6281acf44d5 (patch)
tree7e530a420c4c303706e39cc917f0ad8ea5d657e2 /accel-pptpd/auth
parent4dcca9422c5c001789b17c3266f3db8e0590568d (diff)
downloadaccel-ppp-29b03dcfbd3b4783b0192e5f8c9bb6281acf44d5.tar.gz
accel-ppp-29b03dcfbd3b4783b0192e5f8c9bb6281acf44d5.zip
radius: implemented accounting (start/stop/interim-update)
Diffstat (limited to 'accel-pptpd/auth')
-rw-r--r--accel-pptpd/auth/auth_chap_md5.c7
-rw-r--r--accel-pptpd/auth/auth_mschap_v1.c18
-rw-r--r--accel-pptpd/auth/auth_mschap_v2.c19
-rw-r--r--accel-pptpd/auth/auth_pap.c4
4 files changed, 28 insertions, 20 deletions
diff --git a/accel-pptpd/auth/auth_chap_md5.c b/accel-pptpd/auth/auth_chap_md5.c
index 0bcec37..1abf63b 100644
--- a/accel-pptpd/auth/auth_chap_md5.c
+++ b/accel-pptpd/auth/auth_chap_md5.c
@@ -251,18 +251,17 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h
}else
{
chap_send_success(ad);
- auth_successed(ad->ppp);
+ auth_successed(ad->ppp, name);
}
free(passwd);
} else if (r == PWDB_DENIED) {
chap_send_failure(ad);
auth_failed(ad->ppp);
+ free(name);
} else {
chap_send_success(ad);
- auth_successed(ad->ppp);
+ auth_successed(ad->ppp, name);
}
-
- free(name);
}
static struct ppp_auth_handler_t chap=
diff --git a/accel-pptpd/auth/auth_mschap_v1.c b/accel-pptpd/auth/auth_mschap_v1.c
index 595fb15..4a7341b 100644
--- a/accel-pptpd/auth/auth_mschap_v1.c
+++ b/accel-pptpd/auth/auth_mschap_v1.c
@@ -82,7 +82,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)
{
@@ -209,6 +209,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-v1 Response id=%x <", msg->hdr.id);
print_buf(msg->lm_hash,24);
@@ -222,24 +223,27 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h
{
log_error("mschap-v1: id mismatch\n");
chap_send_failure(ad);
- ppp_terminate(ad->ppp, 0);
+ auth_failed(ad->ppp);
}
if (msg->val_size!=RESPONSE_VALUE_SIZE)
{
log_error("mschap-v1: value-size should be %i, expected %i\n",RESPONSE_VALUE_SIZE,msg->val_size);
chap_send_failure(ad);
- ppp_terminate(ad->ppp, 0);
+ auth_failed(ad->ppp);
}
- if (chap_check_response(ad,msg))
+ name = strndup(msg->name,ntohs(msg->hdr.len)-sizeof(*msg)+2);
+
+ if (chap_check_response(ad, msg, name))
{
chap_send_failure(ad);
auth_failed(ad->ppp);
+ free(name);
}else
{
chap_send_success(ad);
- auth_successed(ad->ppp);
+ auth_successed(ad->ppp, name);
}
}
@@ -272,17 +276,15 @@ 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;
uint8_t z_hash[21];
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)
{
diff --git a/accel-pptpd/auth/auth_mschap_v2.c b/accel-pptpd/auth/auth_mschap_v2.c
index 01127cf..6f1de0e 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)
{
diff --git a/accel-pptpd/auth/auth_pap.c b/accel-pptpd/auth/auth_pap.c
index 7337468..288bccb 100644
--- a/accel-pptpd/auth/auth_pap.c
+++ b/accel-pptpd/auth/auth_pap.c
@@ -184,13 +184,13 @@ static int pap_recv_req(struct pap_auth_data_t *p,struct pap_hdr_t *hdr)
pap_send_nak(p, hdr->id);
auth_failed(p->ppp);
ret=-1;
+ free(peer_id);
} else {
pap_send_ack(p, hdr->id);
- auth_successed(p->ppp);
+ auth_successed(p->ppp, peer_id);
ret = 0;
}
- free(peer_id);
free(passwd);
return ret;