summaryrefslogtreecommitdiff
path: root/accel-pptpd/auth
diff options
context:
space:
mode:
authorKozlov Dmitry <dima@server>2010-09-11 14:27:27 +0400
committerKozlov Dmitry <dima@server>2010-09-11 14:27:27 +0400
commit417ef849f1adcb3b655fbb2382e126b0b17aabbe (patch)
tree560cba379463fc8e912c7f73b54676b7c1582062 /accel-pptpd/auth
parentd0c060a39d3bf6f675666a1400b533511e24a26c (diff)
downloadaccel-ppp-417ef849f1adcb3b655fbb2382e126b0b17aabbe.tar.gz
accel-ppp-417ef849f1adcb3b655fbb2382e126b0b17aabbe.zip
log: implemented extensible loggin engine with per-session logging support
log: implemented log_file logging target with per-user/per-session support
Diffstat (limited to 'accel-pptpd/auth')
-rw-r--r--accel-pptpd/auth/auth_chap_md5.c30
-rw-r--r--accel-pptpd/auth/auth_mschap_v1.c30
-rw-r--r--accel-pptpd/auth/auth_mschap_v2.c32
-rw-r--r--accel-pptpd/auth/auth_pap.c16
4 files changed, 54 insertions, 54 deletions
diff --git a/accel-pptpd/auth/auth_chap_md5.c b/accel-pptpd/auth/auth_chap_md5.c
index 1abf63b..058dc67 100644
--- a/accel-pptpd/auth/auth_chap_md5.c
+++ b/accel-pptpd/auth/auth_chap_md5.c
@@ -76,13 +76,13 @@ static void print_buf(const uint8_t *buf,int size)
{
int i;
for(i=0;i<size;i++)
- log_debug("%x ",buf[i]);
+ log_ppp_debug("%x",buf[i]);
}
static void print_str(const char *buf,int size)
{
int i;
for(i=0;i<size;i++)
- log_debug("%c",buf[i]);
+ log_ppp_debug("%c",buf[i]);
}
@@ -152,7 +152,7 @@ static void chap_send_failure(struct chap_auth_data_t *ad)
.message=MSG_FAILURE,
};
- log_debug("send [CHAP Failure id=%x \"%s\"]\n",msg.hdr.id,MSG_FAILURE);
+ log_ppp_debug("send [CHAP Failure id=%x \"%s\"]\n",msg.hdr.id,MSG_FAILURE);
ppp_chan_send(ad->ppp,&msg,ntohs(msg.hdr.len)+2);
}
@@ -168,7 +168,7 @@ static void chap_send_success(struct chap_auth_data_t *ad)
.message=MSG_SUCCESS,
};
- log_debug("send [CHAP Success id=%x \"%s\"]\n",msg.hdr.id,MSG_SUCCESS);
+ log_ppp_debug("send [CHAP Success id=%x \"%s\"]\n",msg.hdr.id,MSG_SUCCESS);
ppp_chan_send(ad->ppp,&msg,ntohs(msg.hdr.len)+2);
}
@@ -187,9 +187,9 @@ static void chap_send_challenge(struct chap_auth_data_t *ad)
read(urandom_fd,ad->val,VALUE_SIZE);
memcpy(msg.val,ad->val,VALUE_SIZE);
- log_debug("send [CHAP Challenge id=%x <",msg.hdr.id);
+ log_ppp_debug("send [CHAP Challenge id=%x <",msg.hdr.id);
print_buf(msg.val,VALUE_SIZE);
- log_debug(">]\n");
+ log_ppp_debug(">]\n");
ppp_chan_send(ad->ppp,&msg,ntohs(msg.hdr.len)+2);
}
@@ -203,22 +203,22 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h
int r;
struct chap_challenge_t *msg=(struct chap_challenge_t*)hdr;
- log_debug("recv [CHAP Response id=%x <", msg->hdr.id);
+ log_ppp_debug("recv [CHAP Response id=%x <", msg->hdr.id);
print_buf(msg->val,msg->val_size);
- log_debug(">, name=\"");
+ log_ppp_debug(">, name=\"");
print_str(msg->name,ntohs(msg->hdr.len)-sizeof(*msg)+2);
- log_debug("\"]\n");
+ log_ppp_debug("\"]\n");
if (msg->hdr.id!=ad->id)
{
- log_error("chap-md5: id mismatch\n");
+ log_ppp_error("chap-md5: id mismatch\n");
chap_send_failure(ad);
ppp_terminate(ad->ppp, 0);
}
if (msg->val_size!=VALUE_SIZE)
{
- log_error("chap-md5: value-size should be %i, expected %i\n",VALUE_SIZE,msg->val_size);
+ log_ppp_error("chap-md5: value-size should be %i, expected %i\n",VALUE_SIZE,msg->val_size);
chap_send_failure(ad);
ppp_terminate(ad->ppp, 0);
}
@@ -232,7 +232,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h
if (!passwd)
{
free(name);
- log_debug("chap-md5: user not found\n");
+ log_ppp_debug("chap-md5: user not found\n");
chap_send_failure(ad);
return;
}
@@ -245,7 +245,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h
if (memcmp(md5,msg->val,sizeof(md5)))
{
- log_debug("chap-md5: challenge response mismatch\n");
+ log_ppp_debug("chap-md5: challenge response mismatch\n");
chap_send_failure(ad);
auth_failed(ad->ppp);
}else
@@ -282,14 +282,14 @@ static void chap_recv(struct ppp_handler_t *h)
if (d->ppp->chan_buf_size<sizeof(*hdr) || ntohs(hdr->len)<HDR_LEN || ntohs(hdr->len)<d->ppp->chan_buf_size-2)
{
- log_warn("CHAP: short packet received\n");
+ log_ppp_warn("CHAP: short packet received\n");
return;
}
if (hdr->code==CHAP_RESPONSE) chap_recv_response(d,hdr);
else
{
- log_warn("CHAP: unknown code received %x\n",hdr->code);
+ log_ppp_warn("CHAP: unknown code received %x\n",hdr->code);
}
}
diff --git a/accel-pptpd/auth/auth_mschap_v1.c b/accel-pptpd/auth/auth_mschap_v1.c
index 4a7341b..3a75d67 100644
--- a/accel-pptpd/auth/auth_mschap_v1.c
+++ b/accel-pptpd/auth/auth_mschap_v1.c
@@ -88,13 +88,13 @@ static void print_buf(const uint8_t *buf,int size)
{
int i;
for(i=0;i<size;i++)
- log_debug("%x",buf[i]);
+ log_ppp_debug("%x",buf[i]);
}
static void print_str(const char *buf,int size)
{
int i;
for(i=0;i<size;i++)
- log_debug("%c",buf[i]);
+ log_ppp_debug("%c",buf[i]);
}
@@ -164,7 +164,7 @@ static void chap_send_failure(struct chap_auth_data_t *ad)
.message=MSG_FAILURE,
};
- log_debug("send [MSCHAP-v1 Failure id=%x \"%s\"]\n",msg.hdr.id,MSG_FAILURE);
+ log_ppp_debug("send [MSCHAP-v1 Failure id=%x \"%s\"]\n",msg.hdr.id,MSG_FAILURE);
ppp_chan_send(ad->ppp,&msg,ntohs(msg.hdr.len)+2);
}
@@ -180,7 +180,7 @@ static void chap_send_success(struct chap_auth_data_t *ad)
.message=MSG_SUCCESS,
};
- log_debug("send [MSCHAP-v1 Success id=%x \"%s\"]\n",msg.hdr.id,MSG_SUCCESS);
+ log_ppp_debug("send [MSCHAP-v1 Success id=%x \"%s\"]\n",msg.hdr.id,MSG_SUCCESS);
ppp_chan_send(ad->ppp,&msg,ntohs(msg.hdr.len)+2);
}
@@ -199,9 +199,9 @@ static void chap_send_challenge(struct chap_auth_data_t *ad)
read(urandom_fd,ad->val,VALUE_SIZE);
memcpy(msg.val,ad->val,VALUE_SIZE);
- log_debug("send [MSCHAP-v1 Challenge id=%x <",msg.hdr.id);
+ log_ppp_debug("send [MSCHAP-v1 Challenge id=%x <",msg.hdr.id);
print_buf(msg.val,VALUE_SIZE);
- log_debug(">]\n");
+ log_ppp_debug(">]\n");
ppp_chan_send(ad->ppp,&msg,ntohs(msg.hdr.len)+2);
}
@@ -211,24 +211,24 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h
struct chap_response_t *msg=(struct chap_response_t*)hdr;
char *name;
- log_debug("recv [MSCHAP-v1 Response id=%x <", msg->hdr.id);
+ log_ppp_debug("recv [MSCHAP-v1 Response id=%x <", msg->hdr.id);
print_buf(msg->lm_hash,24);
- log_debug(">, <");
+ log_ppp_debug(">, <");
print_buf(msg->nt_hash,24);
- log_debug(">, F=%i, name=\"",msg->use_nt_hash);
+ log_ppp_debug(">, F=%i, name=\"",msg->use_nt_hash);
print_str(msg->name,ntohs(msg->hdr.len)-sizeof(*msg)+2);
- log_debug("\"]\n");
+ log_ppp_debug("\"]\n");
if (msg->hdr.id!=ad->id)
{
- log_error("mschap-v1: id mismatch\n");
+ log_ppp_error("mschap-v1: id mismatch\n");
chap_send_failure(ad);
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);
+ log_ppp_error("mschap-v1: value-size should be %i, expected %i\n",RESPONSE_VALUE_SIZE,msg->val_size);
chap_send_failure(ad);
auth_failed(ad->ppp);
}
@@ -289,7 +289,7 @@ static int chap_check_response(struct chap_auth_data_t *ad, struct chap_response
if (!passwd)
{
free(name);
- log_debug("mschap-v1: user not found\n");
+ log_ppp_debug("mschap-v1: user not found\n");
chap_send_failure(ad);
return -1;
}
@@ -335,14 +335,14 @@ static void chap_recv(struct ppp_handler_t *h)
if (d->ppp->chan_buf_size<sizeof(*hdr) || ntohs(hdr->len)<HDR_LEN || ntohs(hdr->len)<d->ppp->chan_buf_size-2)
{
- log_warn("mschap-v1: short packet received\n");
+ log_ppp_warn("mschap-v1: short packet received\n");
return;
}
if (hdr->code==CHAP_RESPONSE) chap_recv_response(d,hdr);
else
{
- log_warn("mschap-v1: unknown code received %x\n",hdr->code);
+ log_ppp_warn("mschap-v1: unknown code received %x\n",hdr->code);
}
}
diff --git a/accel-pptpd/auth/auth_mschap_v2.c b/accel-pptpd/auth/auth_mschap_v2.c
index 6f1de0e..6bd2c65 100644
--- a/accel-pptpd/auth/auth_mschap_v2.c
+++ b/accel-pptpd/auth/auth_mschap_v2.c
@@ -101,13 +101,13 @@ static void print_buf(const uint8_t *buf,int size)
{
int i;
for(i=0;i<size;i++)
- log_debug("%x",buf[i]);
+ log_ppp_debug("%x",buf[i]);
}
static void print_str(const char *buf,int size)
{
int i;
for(i=0;i<size;i++)
- log_debug("%c",buf[i]);
+ log_ppp_debug("%c",buf[i]);
}
@@ -177,7 +177,7 @@ static void chap_send_failure(struct chap_auth_data_t *ad)
.message=MSG_FAILURE,
};
- log_debug("send [MSCHAP-v2 Failure id=%x \"%s\"]\n",msg.hdr.id,MSG_FAILURE);
+ log_ppp_debug("send [MSCHAP-v2 Failure id=%x \"%s\"]\n",msg.hdr.id,MSG_FAILURE);
ppp_chan_send(ad->ppp,&msg,ntohs(msg.hdr.len)+2);
}
@@ -260,7 +260,7 @@ static void chap_send_success(struct chap_auth_data_t *ad, struct chap_response_
sprintf(msg.message+2+i*2,"%02X",response[i]);
msg.message[2+i*2]=' ';
- log_debug("send [MSCHAP-v2 Success id=%x \"%s\"]\n",msg.hdr.id,msg.message);
+ log_ppp_debug("send [MSCHAP-v2 Success id=%x \"%s\"]\n",msg.hdr.id,msg.message);
ppp_chan_send(ad->ppp,&msg,ntohs(msg.hdr.len)+2);
}
@@ -279,9 +279,9 @@ static void chap_send_challenge(struct chap_auth_data_t *ad)
read(urandom_fd,ad->val,VALUE_SIZE);
memcpy(msg.val,ad->val,VALUE_SIZE);
- log_debug("send [MSCHAP-v2 Challenge id=%x <",msg.hdr.id);
+ log_ppp_debug("send [MSCHAP-v2 Challenge id=%x <",msg.hdr.id);
print_buf(msg.val,VALUE_SIZE);
- log_debug(">]\n");
+ log_ppp_debug(">]\n");
ppp_chan_send(ad->ppp,&msg,ntohs(msg.hdr.len)+2);
}
@@ -291,31 +291,31 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h
struct chap_response_t *msg=(struct chap_response_t*)hdr;
char *name;
- log_debug("recv [MSCHAP-v2 Response id=%x <", msg->hdr.id);
+ log_ppp_debug("recv [MSCHAP-v2 Response id=%x <", msg->hdr.id);
print_buf(msg->peer_challenge,16);
- log_debug(">, <");
+ log_ppp_debug(">, <");
print_buf(msg->nt_hash,24);
- log_debug(">, F=%i, name=\"",msg->flags);
+ log_ppp_debug(">, F=%i, name=\"",msg->flags);
print_str(msg->name,ntohs(msg->hdr.len)-sizeof(*msg)+2);
- log_debug("\"]\n");
+ log_ppp_debug("\"]\n");
if (msg->hdr.id!=ad->id)
{
- log_error("mschap-v2: id mismatch\n");
+ log_ppp_error("mschap-v2: id mismatch\n");
chap_send_failure(ad);
ppp_terminate(ad->ppp, 0);
}
if (msg->val_size!=RESPONSE_VALUE_SIZE)
{
- log_error("mschap-v2: value-size should be %i, expected %i\n",RESPONSE_VALUE_SIZE,msg->val_size);
+ log_ppp_error("mschap-v2: value-size should be %i, expected %i\n",RESPONSE_VALUE_SIZE,msg->val_size);
chap_send_failure(ad);
ppp_terminate(ad->ppp, 0);
}
name=strndup(msg->name,ntohs(msg->hdr.len)-sizeof(*msg)+2);
if (!name) {
- log_error("mschap-v2: out of memory\n");
+ log_emerg("mschap-v2: out of memory\n");
auth_failed(ad->ppp);
return;
}
@@ -376,7 +376,7 @@ static int chap_check_response(struct chap_auth_data_t *ad, struct chap_response
if (!passwd)
{
free(name);
- log_debug("mschap-v2: user not found\n");
+ log_ppp_debug("mschap-v2: user not found\n");
chap_send_failure(ad);
return -1;
}
@@ -428,14 +428,14 @@ static void chap_recv(struct ppp_handler_t *h)
if (d->ppp->chan_buf_size<sizeof(*hdr) || ntohs(hdr->len)<HDR_LEN || ntohs(hdr->len)<d->ppp->chan_buf_size-2)
{
- log_warn("mschap-v2: short packet received\n");
+ log_ppp_warn("mschap-v2: short packet received\n");
return;
}
if (hdr->code==CHAP_RESPONSE) chap_recv_response(d,hdr);
else
{
- log_warn("mschap-v2: unknown code received %x\n",hdr->code);
+ log_ppp_warn("mschap-v2: unknown code received %x\n",hdr->code);
}
}
diff --git a/accel-pptpd/auth/auth_pap.c b/accel-pptpd/auth/auth_pap.c
index 288bccb..81098ce 100644
--- a/accel-pptpd/auth/auth_pap.c
+++ b/accel-pptpd/auth/auth_pap.c
@@ -120,7 +120,7 @@ static void pap_send_ack(struct pap_auth_data_t *p, int id)
msg->msg_len=sizeof(MSG_SUCCESSED)-1;
memcpy(msg->msg,MSG_SUCCESSED,sizeof(MSG_SUCCESSED));
- log_debug("send [PAP AuthAck id=%x \"%s\"]\n",id,MSG_SUCCESSED);
+ log_ppp_debug("send [PAP AuthAck id=%x \"%s\"]\n",id,MSG_SUCCESSED);
ppp_chan_send(p->ppp,msg,ntohs(msg->hdr.len)+2);
}
@@ -136,7 +136,7 @@ static void pap_send_nak(struct pap_auth_data_t *p, int id)
msg->msg_len=sizeof(MSG_FAILED)-1;
memcpy(msg->msg,MSG_FAILED,sizeof(MSG_FAILED));
- log_debug("send [PAP AuthNak id=%x \"%s\"]\n",id,MSG_FAILED);
+ log_ppp_debug("send [PAP AuthNak id=%x \"%s\"]\n",id,MSG_FAILED);
ppp_chan_send(p->ppp,msg,ntohs(msg->hdr.len)+2);
}
@@ -151,12 +151,12 @@ static int pap_recv_req(struct pap_auth_data_t *p,struct pap_hdr_t *hdr)
int passwd_len;
uint8_t *ptr=(uint8_t*)(hdr+1);
- log_debug("recv [PAP AuthReq id=%x]\n",hdr->id);
+ log_ppp_debug("recv [PAP AuthReq id=%x]\n",hdr->id);
peer_id_len=*(uint8_t*)ptr; ptr++;
if (peer_id_len>ntohs(hdr->len)-sizeof(*hdr)+2-1)
{
- log_warn("PAP: short packet received\n");
+ log_ppp_warn("PAP: short packet received\n");
return -1;
}
peer_id=(char*)ptr; ptr+=peer_id_len;
@@ -164,7 +164,7 @@ static int pap_recv_req(struct pap_auth_data_t *p,struct pap_hdr_t *hdr)
passwd_len=*(uint8_t*)ptr; ptr++;
if (passwd_len>ntohs(hdr->len)-sizeof(*hdr)+2-2-peer_id_len)
{
- log_warn("PAP: short packet received\n");
+ log_ppp_warn("PAP: short packet received\n");
return -1;
}
@@ -180,7 +180,7 @@ static int pap_recv_req(struct pap_auth_data_t *p,struct pap_hdr_t *hdr)
r = PWDB_SUCCESS;
}
if (r == PWDB_DENIED) {
- log_warn("PAP: authentication error\n");
+ log_ppp_warn("PAP: authentication error\n");
pap_send_nak(p, hdr->id);
auth_failed(p->ppp);
ret=-1;
@@ -203,14 +203,14 @@ static void pap_recv(struct ppp_handler_t *h)
if (d->ppp->chan_buf_size<sizeof(*hdr) || ntohs(hdr->len)<HDR_LEN || ntohs(hdr->len)<d->ppp->chan_buf_size-2)
{
- log_warn("PAP: short packet received\n");
+ log_ppp_warn("PAP: short packet received\n");
return;
}
if (hdr->code==PAP_REQ) pap_recv_req(d,hdr);
else
{
- log_warn("PAP: unknown code received %x\n",hdr->code);
+ log_ppp_warn("PAP: unknown code received %x\n",hdr->code);
}
}