Reverse revision 16804 that disables authentication

and a lot of other issues...


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@16825 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Olle Johansson 2006-04-01 00:24:05 +00:00
parent 225d8d5270
commit 2240245389

View file

@ -6534,10 +6534,6 @@ static int cb_extensionstate(char *context, char* exten, int state, void *data)
{ {
struct sip_pvt *p = data; struct sip_pvt *p = data;
if (p == (struct sip_pvt *) NULL) {
ast_log(LOG_ERROR, "We're sent state change for channel we don't know... Major issue!!!!! Notify management!!!\n");
return 0;
}
switch(state) { switch(state) {
case AST_EXTENSION_DEACTIVATED: /* Retry after a while */ case AST_EXTENSION_DEACTIVATED: /* Retry after a while */
case AST_EXTENSION_REMOVED: /* Extension is gone */ case AST_EXTENSION_REMOVED: /* Extension is gone */
@ -11028,97 +11024,93 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
} else if (debug && ignore) } else if (debug && ignore)
ast_verbose("Ignoring this SUBSCRIBE request\n"); ast_verbose("Ignoring this SUBSCRIBE request\n");
/* Don't treat this SUBSCRIBE request as new if it isn't */ /* Find parameters to Event: header value and remove them for now */
if (!p->lastinvite) { if ((eventparam = strchr(event, ';')))
*eventparam++ = '\0';
/* Find parameters to Event: header value and remove them for now */ /* Handle authentication if this is our first subscribe */
if ((eventparam = strchr(event, ';'))) res = check_user_full(p, req, SIP_SUBSCRIBE, e, 0, sin, ignore, &authpeer);
*eventparam++ = '\0'; if (res) {
if (res < 0) {
/* Handle authentication if this is our first subscribe */ ast_log(LOG_NOTICE, "Failed to authenticate user %s for SUBSCRIBE\n", get_header(req, "From"));
res = check_user_full(p, req, SIP_SUBSCRIBE, e, 0, sin, ignore, &authpeer);
if (res) {
if (res < 0) {
ast_log(LOG_NOTICE, "Failed to authenticate user %s for SUBSCRIBE\n", get_header(req, "From"));
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
}
return 0;
}
/* Check if this user/peer is allowed to subscribe at all */
if (!ast_test_flag(&p->flags[1], SIP_PAGE2_ALLOWSUBSCRIBE)) {
transmit_response(p, "403 Forbidden (policy)", req);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
return 0;
}
/* Initialize the context if it hasn't been already */
if (!ast_strlen_zero(p->subscribecontext))
ast_string_field_set(p, context, p->subscribecontext);
else if (ast_strlen_zero(p->context))
ast_string_field_set(p, context, default_context);
/* Get destination right away */
gotdest = get_destination(p, NULL);
build_contact(p);
if (gotdest) {
transmit_response(p, "404 Not Found", req);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY); ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
return 0; }
} else { return 0;
/* Initialize tag for new subscriptions */ }
if (ast_strlen_zero(p->tag))
make_our_tag(p->tag, sizeof(p->tag)); /* Check if this user/peer is allowed to subscribe at all */
if (!ast_test_flag(&p->flags[1], SIP_PAGE2_ALLOWSUBSCRIBE)) {
if (!strcmp(event, "presence") || !strcmp(event, "dialog")) { /* Presence, RFC 3842 */ transmit_response(p, "403 Forbidden (policy)", req);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
/* Header from Xten Eye-beam Accept: multipart/related, application/rlmi+xml, application/pidf+xml, application/xpidf+xml */ return 0;
if (strstr(accept, "application/pidf+xml")) { }
p->subscribed = PIDF_XML; /* RFC 3863 format */
} else if (strstr(accept, "application/dialog-info+xml")) { /* Initialize the context if it hasn't been already */
p->subscribed = DIALOG_INFO_XML; if (!ast_strlen_zero(p->subscribecontext))
/* IETF draft: draft-ietf-sipping-dialog-package-05.txt */ ast_string_field_set(p, context, p->subscribecontext);
} else if (strstr(accept, "application/cpim-pidf+xml")) { else if (ast_strlen_zero(p->context))
p->subscribed = CPIM_PIDF_XML; /* RFC 3863 format */ ast_string_field_set(p, context, default_context);
} else if (strstr(accept, "application/xpidf+xml")) {
p->subscribed = XPIDF_XML; /* Early pre-RFC 3863 format with MSN additions (Microsoft Messenger) */ /* Get destination right away */
} else if (strstr(p->useragent, "Polycom")) { gotdest = get_destination(p, NULL);
p->subscribed = XPIDF_XML; /* Polycoms subscribe for "event: dialog" but don't include an "accept:" header */ build_contact(p);
} else { if (gotdest) {
/* Can't find a format for events that we know about */ transmit_response(p, "404 Not Found", req);
transmit_response(p, "489 Bad Event", req); ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY); return 0;
return 0; } else {
} /* Initialize tag for new subscriptions */
} else if (!strcmp(event, "message-summary") && !strcmp(accept, "application/simple-message-summary")) { if (ast_strlen_zero(p->tag))
/* Looks like they actually want a mailbox status make_our_tag(p->tag, sizeof(p->tag));
This version of Asterisk supports mailbox subscriptions
The subscribed URI needs to exist in the dial plan if (!strcmp(event, "presence") || !strcmp(event, "dialog")) { /* Presence, RFC 3842 */
In most devices, this is configurable to the voicemailmain extension you use
*/ /* Header from Xten Eye-beam Accept: multipart/related, application/rlmi+xml, application/pidf+xml, application/xpidf+xml */
if (!authpeer || ast_strlen_zero(authpeer->mailbox)) { if (strstr(accept, "application/pidf+xml")) {
transmit_response(p, "404 Not found (no mailbox)", req); p->subscribed = PIDF_XML; /* RFC 3863 format */
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY); } else if (strstr(accept, "application/dialog-info+xml")) {
ast_log(LOG_NOTICE, "Received SIP subscribe for peer without mailbox: %s\n", authpeer->name); p->subscribed = DIALOG_INFO_XML;
return 0; /* IETF draft: draft-ietf-sipping-dialog-package-05.txt */
} } else if (strstr(accept, "application/cpim-pidf+xml")) {
p->subscribed = CPIM_PIDF_XML; /* RFC 3863 format */
p->subscribed = MWI_NOTIFICATION; } else if (strstr(accept, "application/xpidf+xml")) {
if (authpeer->mwipvt && authpeer->mwipvt != p) /* Destroy old PVT if this is a new one */ p->subscribed = XPIDF_XML; /* Early pre-RFC 3863 format with MSN additions (Microsoft Messenger) */
/* We only allow one subscription per peer */ } else if (strstr(p->useragent, "Polycom")) {
sip_destroy(authpeer->mwipvt); p->subscribed = XPIDF_XML; /* Polycoms subscribe for "event: dialog" but don't include an "accept:" header */
authpeer->mwipvt = p; /* Link from peer to pvt */ } else {
p->relatedpeer = authpeer; /* Link from pvt to peer */ /* Can't find a format for events that we know about */
} else { /* At this point, Asterisk does not understand the specified event */ transmit_response(p, "489 Bad Event", req);
transmit_response(p, "489 Bad Event", req);
if (option_debug > 1)
ast_log(LOG_DEBUG, "Received SIP subscribe for unknown event package: %s\n", event);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY); ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
return 0;
}
} else if (!strcmp(event, "message-summary") && !strcmp(accept, "application/simple-message-summary")) {
/* Looks like they actually want a mailbox status
This version of Asterisk supports mailbox subscriptions
The subscribed URI needs to exist in the dial plan
In most devices, this is configurable to the voicemailmain extension you use
*/
if (!authpeer || ast_strlen_zero(authpeer->mailbox)) {
transmit_response(p, "404 Not found (no mailbox)", req);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
ast_log(LOG_NOTICE, "Received SIP subscribe for peer without mailbox: %s\n", authpeer->name);
return 0; return 0;
} }
if (p->subscribed != MWI_NOTIFICATION)
p->stateid = ast_extension_state_add(p->context, p->exten, cb_extensionstate, p); p->subscribed = MWI_NOTIFICATION;
if (authpeer->mwipvt && authpeer->mwipvt != p) /* Destroy old PVT if this is a new one */
/* We only allow one subscription per peer */
sip_destroy(authpeer->mwipvt);
authpeer->mwipvt = p; /* Link from peer to pvt */
p->relatedpeer = authpeer; /* Link from pvt to peer */
} else { /* At this point, Asterisk does not understand the specified event */
transmit_response(p, "489 Bad Event", req);
if (option_debug > 1)
ast_log(LOG_DEBUG, "Received SIP subscribe for unknown event package: %s\n", event);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
return 0;
} }
if (p->subscribed != MWI_NOTIFICATION)
p->stateid = ast_extension_state_add(p->context, p->exten, cb_extensionstate, p);
} }
if (!ignore && p) if (!ignore && p)