From: Olle Johansson Date: Wed, 16 May 2007 10:38:18 +0000 (+0000) Subject: Issue #9681 - Handle www-auth on BYE X-Git-Tag: 1.4.5~174 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5acc63d688ba96d3ceed384529b1dcf963d4a088;p=thirdparty%2Fasterisk.git Issue #9681 - Handle www-auth on BYE git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@64602 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 883aaeebba..fd6edc73d9 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -12311,6 +12311,15 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_ handle_response_refer(p, resp, rest, req, seqno); else if (p->registry && sipmethod == SIP_REGISTER) res = handle_response_register(p, resp, rest, req, ignore, seqno); + else if (sipmethod == SIP_BYE) + if (ast_strlen_zero(p->authname)) + ast_log(LOG_WARNING, "Asked to authenticate %s, to %s:%d but we have no matching peer!\n", + msg, ast_inet_ntoa(p->recv.sin_addr), ntohs(p->recv.sin_port)); + ast_set_flag(&p->flags[0], SIP_NEEDDESTROY); + if ((p->authtries == MAX_AUTHTRIES) || do_proxy_auth(p, req, "WWW-Authenticate", "Authorization", sipmethod, 0)) { + ast_log(LOG_NOTICE, "Failed to authenticate on %s to '%s'\n", msg, get_header(&p->initreq, "From")); + ast_set_flag(&p->flags[0], SIP_NEEDDESTROY); + } else { ast_log(LOG_WARNING, "Got authentication request (401) on unknown %s to '%s'\n", sip_methods[sipmethod].text, get_header(req, "To")); ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);