mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-30 10:33:13 +00:00
First attempt at fixing bug #131 (authenticate BYE)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1382 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -381,7 +381,7 @@ static int transmit_reinvite_with_sdp(struct sip_pvt *p, struct ast_rtp *rtp, st
|
|||||||
static int transmit_info_with_digit(struct sip_pvt *p, char digit);
|
static int transmit_info_with_digit(struct sip_pvt *p, char digit);
|
||||||
static int transmit_message_with_text(struct sip_pvt *p, char *text);
|
static int transmit_message_with_text(struct sip_pvt *p, char *text);
|
||||||
static int transmit_refer(struct sip_pvt *p, char *dest);
|
static int transmit_refer(struct sip_pvt *p, char *dest);
|
||||||
static int do_proxy_auth(struct sip_pvt *p, struct sip_request *req);
|
static int do_proxy_auth(struct sip_pvt *p, struct sip_request *req, char *msg);
|
||||||
static char *getsipuri(char *header);
|
static char *getsipuri(char *header);
|
||||||
static void free_old_route(struct sip_route *route);
|
static void free_old_route(struct sip_route *route);
|
||||||
static int build_reply_digest(struct sip_pvt *p, char *orig_header, char *digest, int digest_len);
|
static int build_reply_digest(struct sip_pvt *p, char *orig_header, char *digest, int digest_len);
|
||||||
@@ -4039,11 +4039,11 @@ static int do_register_auth(struct sip_pvt *p, struct sip_request *req) {
|
|||||||
return transmit_register(p->registry,"REGISTER",digest);
|
return transmit_register(p->registry,"REGISTER",digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_proxy_auth(struct sip_pvt *p, struct sip_request *req) {
|
static int do_proxy_auth(struct sip_pvt *p, struct sip_request *req, char *msg) {
|
||||||
char digest[256];
|
char digest[256];
|
||||||
p->authtries++;
|
p->authtries++;
|
||||||
memset(digest,0,sizeof(digest));
|
memset(digest,0,sizeof(digest));
|
||||||
if (reply_digest(p,req, "Proxy-Authenticate", "INVITE", digest, sizeof(digest) )) {
|
if (reply_digest(p,req, "Proxy-Authenticate", msg, digest, sizeof(digest) )) {
|
||||||
/* No way to authenticate */
|
/* No way to authenticate */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -4325,6 +4325,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
|
|||||||
ast_queue_frame(p->owner, &af, 0);
|
ast_queue_frame(p->owner, &af, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
p->authtries = 0;
|
||||||
transmit_request(p, "ACK", seqno, 0);
|
transmit_request(p, "ACK", seqno, 0);
|
||||||
/* Go ahead and send bye at this point */
|
/* Go ahead and send bye at this point */
|
||||||
if (p->pendingbye) {
|
if (p->pendingbye) {
|
||||||
@@ -4375,12 +4376,16 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
|
|||||||
/* First we ACK */
|
/* First we ACK */
|
||||||
transmit_request(p, "ACK", seqno, 0);
|
transmit_request(p, "ACK", seqno, 0);
|
||||||
/* Then we AUTH */
|
/* Then we AUTH */
|
||||||
if ((p->authtries > 1) || do_proxy_auth(p, req)) {
|
if ((p->authtries > 1) || do_proxy_auth(p, req, "INVITE")) {
|
||||||
ast_log(LOG_NOTICE, "Failed to authenticate on INVITE to '%s'\n", get_header(&p->initreq, "From"));
|
ast_log(LOG_NOTICE, "Failed to authenticate on INVITE to '%s'\n", get_header(&p->initreq, "From"));
|
||||||
p->needdestroy = 1;
|
p->needdestroy = 1;
|
||||||
}
|
}
|
||||||
} else
|
} else if (!strcasecmp(msg, "BYE")) {
|
||||||
p->needdestroy = 1;
|
if ((p->authtries > 1) || do_proxy_auth(p, req, "BYE")) {
|
||||||
|
ast_log(LOG_NOTICE, "Failed to authenticate on BYE to '%s'\n", get_header(&p->initreq, "From"));
|
||||||
|
p->needdestroy = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 501: /* Not Implemented */
|
case 501: /* Not Implemented */
|
||||||
if (!strcasecmp(msg, "INVITE"))
|
if (!strcasecmp(msg, "INVITE"))
|
||||||
|
Reference in New Issue
Block a user