mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
Do not link the guest account with any configured XMPP client (in
jabber.conf). The actual connection is made when a call comes in Asterisk. Fix the ast_aji_get_client function that was not able to retrieve an XMPP client from its JID. (closes issue #12085) Reported by: junky Tested by: phsultan git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@119740 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -276,17 +276,12 @@ static struct gtalk *find_gtalk(char *name, char *connection)
|
|||||||
if (!gtalk && strchr(name, '@'))
|
if (!gtalk && strchr(name, '@'))
|
||||||
gtalk = ASTOBJ_CONTAINER_FIND_FULL(>alk_list, name, user,,, strcasecmp);
|
gtalk = ASTOBJ_CONTAINER_FIND_FULL(>alk_list, name, user,,, strcasecmp);
|
||||||
|
|
||||||
if (!gtalk) { /* guest call */
|
if (!gtalk) {
|
||||||
|
/* guest call */
|
||||||
ASTOBJ_CONTAINER_TRAVERSE(>alk_list, 1, {
|
ASTOBJ_CONTAINER_TRAVERSE(>alk_list, 1, {
|
||||||
ASTOBJ_RDLOCK(iterator);
|
ASTOBJ_RDLOCK(iterator);
|
||||||
if (!strcasecmp(iterator->name, "guest")) {
|
if (!strcasecmp(iterator->name, "guest")) {
|
||||||
if (!strcasecmp(iterator->connection->jid->partial, connection)) {
|
gtalk = iterator;
|
||||||
gtalk = iterator;
|
|
||||||
} else if (!strcasecmp(iterator->connection->name, connection)) {
|
|
||||||
gtalk = iterator;
|
|
||||||
} else if (iterator->connection->component && !strcasecmp(iterator->connection->user,domain)) {
|
|
||||||
gtalk = iterator;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ASTOBJ_UNLOCK(iterator);
|
ASTOBJ_UNLOCK(iterator);
|
||||||
|
|
||||||
@@ -1165,6 +1160,16 @@ static int gtalk_newcall(struct gtalk *client, ikspak *pak)
|
|||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strcasecmp(client->name, "guest")){
|
||||||
|
/* the guest account is not tied to any configured XMPP client,
|
||||||
|
let's set it now */
|
||||||
|
client->connection = ast_aji_get_client(from);
|
||||||
|
if (!client->connection) {
|
||||||
|
ast_log(LOG_ERROR, "No XMPP client to talk to, us (partial JID) : %s\n", from);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
p = gtalk_alloc(client, from, pak->from->full, iks_find_attrib(pak->query, "id"));
|
p = gtalk_alloc(client, from, pak->from->full, iks_find_attrib(pak->query, "id"));
|
||||||
if (!p) {
|
if (!p) {
|
||||||
ast_log(LOG_WARNING, "Unable to allocate gtalk structure!\n");
|
ast_log(LOG_WARNING, "Unable to allocate gtalk structure!\n");
|
||||||
@@ -1627,11 +1632,22 @@ static struct ast_channel *gtalk_request(const char *type, int format, void *dat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
client = find_gtalk(to, sender);
|
client = find_gtalk(to, sender);
|
||||||
if (!client) {
|
if (!client) {
|
||||||
ast_log(LOG_WARNING, "Could not find recipient.\n");
|
ast_log(LOG_WARNING, "Could not find recipient.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
if (!strcasecmp(client->name, "guest")){
|
||||||
|
/* the guest account is not tied to any configured XMPP client,
|
||||||
|
let's set it now */
|
||||||
|
client->connection = ast_aji_get_client(sender);
|
||||||
|
if (!client->connection) {
|
||||||
|
ast_log(LOG_ERROR, "No XMPP client to talk to, us (partial JID) : %s\n", sender);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ASTOBJ_WRLOCK(client);
|
ASTOBJ_WRLOCK(client);
|
||||||
p = gtalk_alloc(client, strchr(sender, '@') ? sender : client->connection->jid->full, strchr(to, '@') ? to : client->user, NULL);
|
p = gtalk_alloc(client, strchr(sender, '@') ? sender : client->connection->jid->full, strchr(to, '@') ? to : client->user, NULL);
|
||||||
if (p)
|
if (p)
|
||||||
@@ -1931,13 +1947,13 @@ static int gtalk_load_config(void)
|
|||||||
ASTOBJ_CONTAINER_TRAVERSE(clients, 1, {
|
ASTOBJ_CONTAINER_TRAVERSE(clients, 1, {
|
||||||
ASTOBJ_WRLOCK(iterator);
|
ASTOBJ_WRLOCK(iterator);
|
||||||
ASTOBJ_WRLOCK(member);
|
ASTOBJ_WRLOCK(member);
|
||||||
member->connection = iterator;
|
member->connection = NULL;
|
||||||
iks_filter_add_rule(iterator->f, gtalk_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, "http://www.google.com/session", IKS_RULE_DONE);
|
iks_filter_add_rule(iterator->f, gtalk_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, "http://www.google.com/session", IKS_RULE_DONE);
|
||||||
iks_filter_add_rule(iterator->f, gtalk_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, "http://jabber.org/protocol/gtalk", IKS_RULE_DONE);
|
iks_filter_add_rule(iterator->f, gtalk_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, "http://jabber.org/protocol/gtalk", IKS_RULE_DONE);
|
||||||
ASTOBJ_UNLOCK(member);
|
ASTOBJ_UNLOCK(member);
|
||||||
ASTOBJ_CONTAINER_LINK(>alk_list, member);
|
|
||||||
ASTOBJ_UNLOCK(iterator);
|
ASTOBJ_UNLOCK(iterator);
|
||||||
});
|
});
|
||||||
|
ASTOBJ_CONTAINER_LINK(>alk_list, member);
|
||||||
} else {
|
} else {
|
||||||
ASTOBJ_UNLOCK(member);
|
ASTOBJ_UNLOCK(member);
|
||||||
ASTOBJ_UNREF(member, gtalk_member_destroy);
|
ASTOBJ_UNREF(member, gtalk_member_destroy);
|
||||||
|
@@ -2359,17 +2359,30 @@ static int aji_load_config(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief grab a aji_client structure by label name.
|
* \brief grab a aji_client structure by label name or JID
|
||||||
* \param void.
|
* (without the resource string)
|
||||||
* \return 1.
|
* \param name label or JID
|
||||||
|
* \return aji_client.
|
||||||
*/
|
*/
|
||||||
struct aji_client *ast_aji_get_client(const char *name)
|
struct aji_client *ast_aji_get_client(const char *name)
|
||||||
{
|
{
|
||||||
struct aji_client *client = NULL;
|
struct aji_client *client = NULL;
|
||||||
|
char *aux = NULL;
|
||||||
|
|
||||||
client = ASTOBJ_CONTAINER_FIND(&clients, name);
|
client = ASTOBJ_CONTAINER_FIND(&clients, name);
|
||||||
if (!client && !strchr(name, '@'))
|
if (!client && strchr(name, '@')) {
|
||||||
client = ASTOBJ_CONTAINER_FIND_FULL(&clients, name, user,,, strcasecmp);
|
ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, {
|
||||||
|
aux = ast_strdupa(iterator->user);
|
||||||
|
if (strchr(aux, '/')) {
|
||||||
|
/* strip resource for comparison */
|
||||||
|
aux = strsep(&aux, "/");
|
||||||
|
}
|
||||||
|
if (!strcasecmp(aux, name)) {
|
||||||
|
client = iterator;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user