[asterisk-commits] jpeeler: trunk r235342 - in /trunk: ./ configs/ include/asterisk/ res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Dec 16 14:25:31 CST 2009
Author: jpeeler
Date: Wed Dec 16 14:25:27 2009
New Revision: 235342
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=235342
Log:
Add auth_policy option to jabber.conf for auto user registration.
The option is global and currently the acceptable values as noted in the sample
config are accept or deny.
(closes issue #15228)
Reported by: lp0
Modified:
trunk/CHANGES
trunk/configs/jabber.conf.sample
trunk/include/asterisk/jabber.h
trunk/res/res_jabber.c
Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=235342&r1=235341&r2=235342
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Wed Dec 16 14:25:27 2009
@@ -367,6 +367,7 @@
code set to 2.
* An 'X' option has been added to the asterisk application which enables #exec support.
This allows #exec to be used in asterisk.conf.
+ * jabber.conf supports a new option auth_policy that toggles auto user registration.
------------------------------------------------------------------------------
--- Functionality changes from Asterisk 1.6.1 to Asterisk 1.6.2 -------------
Modified: trunk/configs/jabber.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/jabber.conf.sample?view=diff&rev=235342&r1=235341&r2=235342
==============================================================================
--- trunk/configs/jabber.conf.sample (original)
+++ trunk/configs/jabber.conf.sample Wed Dec 16 14:25:27 2009
@@ -4,6 +4,9 @@
;;setup (ie, using your personal Gtalk account for a test)
;;you might lose your contacts list. Default is 'no'.
;autoregister=yes ;;Auto register users from buddy list.
+;auth_policy=accept ;;Auto accept users' subscription requests (default).
+ ;;Set to deny for auto denial.
+
;[asterisk] ;;label
;type=client ;;Client or Component connection
Modified: trunk/include/asterisk/jabber.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/jabber.h?view=diff&rev=235342&r1=235341&r2=235342
==============================================================================
--- trunk/include/asterisk/jabber.h (original)
+++ trunk/include/asterisk/jabber.h Wed Dec 16 14:25:27 2009
@@ -84,7 +84,8 @@
enum {
AJI_AUTOPRUNE = (1 << 0),
- AJI_AUTOREGISTER = (1 << 1)
+ AJI_AUTOREGISTER = (1 << 1),
+ AJI_AUTOACCEPT = (1 << 2)
};
enum aji_btype {
Modified: trunk/res/res_jabber.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_jabber.c?view=diff&rev=235342&r1=235341&r2=235342
==============================================================================
--- trunk/res/res_jabber.c (original)
+++ trunk/res/res_jabber.c Wed Dec 16 14:25:27 2009
@@ -353,7 +353,7 @@
static ast_mutex_t messagelock;
/*! \brief Global flags, initialized to default values */
-static struct ast_flags globalflags = { AJI_AUTOREGISTER };
+static struct ast_flags globalflags = { AJI_AUTOREGISTER | AJI_AUTOACCEPT };
/*!
* \internal
@@ -2410,22 +2410,24 @@
switch (pak->subtype) {
case IKS_TYPE_SUBSCRIBE:
- presence = iks_new("presence");
- status = iks_new("status");
- if (presence && status) {
- iks_insert_attrib(presence, "type", "subscribed");
- iks_insert_attrib(presence, "to", pak->from->full);
- iks_insert_attrib(presence, "from", client->jid->full);
- if (pak->id)
- iks_insert_attrib(presence, "id", pak->id);
- iks_insert_cdata(status, "Asterisk has approved subscription", 0);
- iks_insert_node(presence, status);
- ast_aji_send(client, presence);
- } else
- ast_log(LOG_ERROR, "Unable to allocate nodes\n");
-
- iks_delete(presence);
- iks_delete(status);
+ if (ast_test_flag(&client->flags, AJI_AUTOACCEPT)) {
+ presence = iks_new("presence");
+ status = iks_new("status");
+ if (presence && status) {
+ iks_insert_attrib(presence, "type", "subscribed");
+ iks_insert_attrib(presence, "to", pak->from->full);
+ iks_insert_attrib(presence, "from", client->jid->full);
+ if (pak->id)
+ iks_insert_attrib(presence, "id", pak->id);
+ iks_insert_cdata(status, "Asterisk has approved subscription", 0);
+ iks_insert_node(presence, status);
+ ast_aji_send(client, presence);
+ } else
+ ast_log(LOG_ERROR, "Unable to allocate nodes\n");
+
+ iks_delete(presence);
+ iks_delete(status);
+ }
if (client->component)
aji_set_presence(client, pak->from->full, iks_find_attrib(pak->x, "to"), client->status, client->statusmessage);
@@ -3410,6 +3412,13 @@
ast_set2_flag(&client->flags, ast_true(var->value), AJI_AUTOPRUNE);
else if (!strcasecmp(var->name, "autoregister"))
ast_set2_flag(&client->flags, ast_true(var->value), AJI_AUTOREGISTER);
+ else if (!strcasecmp(var->name, "auth_policy")) {
+ if (!strcasecmp(var->value, "accept")) {
+ ast_set_flag(&client->flags, AJI_AUTOACCEPT);
+ } else {
+ ast_clear_flag(&client->flags, AJI_AUTOACCEPT);
+ }
+ }
else if (!strcasecmp(var->name, "buddy"))
aji_create_buddy((char *)var->value, client);
else if (!strcasecmp(var->name, "priority"))
@@ -3595,7 +3604,7 @@
return -1;
/* Reset flags to default value */
- ast_set_flag(&globalflags, AJI_AUTOREGISTER);
+ ast_set_flag(&globalflags, AJI_AUTOREGISTER | AJI_AUTOACCEPT);
if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) {
ast_log(LOG_WARNING, "No such configuration file %s\n", JABBER_CONFIG);
@@ -3610,6 +3619,12 @@
ast_set2_flag(&globalflags, ast_true(var->value), AJI_AUTOPRUNE);
} else if (!strcasecmp(var->name, "autoregister")) {
ast_set2_flag(&globalflags, ast_true(var->value), AJI_AUTOREGISTER);
+ } else if (!strcasecmp(var->name, "auth_policy")) {
+ if (!strcasecmp(var->value, "accept")) {
+ ast_set_flag(&globalflags, AJI_AUTOACCEPT);
+ } else {
+ ast_clear_flag(&globalflags, AJI_AUTOACCEPT);
+ }
}
}
More information about the asterisk-commits
mailing list