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
1.4
Olle Johansson 20 years ago
parent 225d8d5270
commit 2240245389

@ -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 */
if ((eventparam = strchr(event, ';')))
*eventparam++ = '\0';
/* Handle authentication if this is our first subscribe */ /* Handle authentication if this is our first subscribe */
res = check_user_full(p, req, SIP_SUBSCRIBE, e, 0, sin, ignore, &authpeer); res = check_user_full(p, req, SIP_SUBSCRIBE, e, 0, sin, ignore, &authpeer);
if (res) { if (res) {
if (res < 0) { if (res < 0) {
ast_log(LOG_NOTICE, "Failed to authenticate user %s for SUBSCRIBE\n", get_header(req, "From")); 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); ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
return 0;
} }
return 0;
}
/* Initialize the context if it hasn't been already */ /* Check if this user/peer is allowed to subscribe at all */
if (!ast_strlen_zero(p->subscribecontext)) if (!ast_test_flag(&p->flags[1], SIP_PAGE2_ALLOWSUBSCRIBE)) {
ast_string_field_set(p, context, p->subscribecontext); transmit_response(p, "403 Forbidden (policy)", req);
else if (ast_strlen_zero(p->context)) ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
ast_string_field_set(p, context, default_context); return 0;
}
/* Get destination right away */ /* Initialize the context if it hasn't been already */
gotdest = get_destination(p, NULL); if (!ast_strlen_zero(p->subscribecontext))
build_contact(p); ast_string_field_set(p, context, p->subscribecontext);
if (gotdest) { else if (ast_strlen_zero(p->context))
transmit_response(p, "404 Not Found", req); ast_string_field_set(p, context, default_context);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
return 0; /* Get destination right away */
} else { gotdest = get_destination(p, NULL);
/* Initialize tag for new subscriptions */ build_contact(p);
if (ast_strlen_zero(p->tag)) if (gotdest) {
make_our_tag(p->tag, sizeof(p->tag)); transmit_response(p, "404 Not Found", req);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
if (!strcmp(event, "presence") || !strcmp(event, "dialog")) { /* Presence, RFC 3842 */ return 0;
} else {
/* Header from Xten Eye-beam Accept: multipart/related, application/rlmi+xml, application/pidf+xml, application/xpidf+xml */ /* Initialize tag for new subscriptions */
if (strstr(accept, "application/pidf+xml")) { if (ast_strlen_zero(p->tag))
p->subscribed = PIDF_XML; /* RFC 3863 format */ make_our_tag(p->tag, sizeof(p->tag));
} else if (strstr(accept, "application/dialog-info+xml")) {
p->subscribed = DIALOG_INFO_XML;
/* 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 */
} else if (strstr(accept, "application/xpidf+xml")) {
p->subscribed = XPIDF_XML; /* Early pre-RFC 3863 format with MSN additions (Microsoft Messenger) */
} else if (strstr(p->useragent, "Polycom")) {
p->subscribed = XPIDF_XML; /* Polycoms subscribe for "event: dialog" but don't include an "accept:" header */
} else {
/* Can't find a format for events that we know about */
transmit_response(p, "489 Bad Event", req);
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;
}
p->subscribed = MWI_NOTIFICATION; if (!strcmp(event, "presence") || !strcmp(event, "dialog")) { /* Presence, RFC 3842 */
if (authpeer->mwipvt && authpeer->mwipvt != p) /* Destroy old PVT if this is a new one */
/* We only allow one subscription per peer */ /* Header from Xten Eye-beam Accept: multipart/related, application/rlmi+xml, application/pidf+xml, application/xpidf+xml */
sip_destroy(authpeer->mwipvt); if (strstr(accept, "application/pidf+xml")) {
authpeer->mwipvt = p; /* Link from peer to pvt */ p->subscribed = PIDF_XML; /* RFC 3863 format */
p->relatedpeer = authpeer; /* Link from pvt to peer */ } else if (strstr(accept, "application/dialog-info+xml")) {
} else { /* At this point, Asterisk does not understand the specified event */ p->subscribed = DIALOG_INFO_XML;
transmit_response(p, "489 Bad Event", req); /* IETF draft: draft-ietf-sipping-dialog-package-05.txt */
if (option_debug > 1) } else if (strstr(accept, "application/cpim-pidf+xml")) {
ast_log(LOG_DEBUG, "Received SIP subscribe for unknown event package: %s\n", event); p->subscribed = CPIM_PIDF_XML; /* RFC 3863 format */
} else if (strstr(accept, "application/xpidf+xml")) {
p->subscribed = XPIDF_XML; /* Early pre-RFC 3863 format with MSN additions (Microsoft Messenger) */
} else if (strstr(p->useragent, "Polycom")) {
p->subscribed = XPIDF_XML; /* Polycoms subscribe for "event: dialog" but don't include an "accept:" header */
} else {
/* Can't find a format for events that we know about */
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;
}
} 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)

Loading…
Cancel
Save