Author: mjordan Date: Wed Mar 25 10:30:42 2015 New Revision: 433396 URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=433396 Log: res_xmpp: Buddies are always auto-registered when processing the roster
Due to a quirk in the configuration handling of res_xmpp, the 'autoregister' setting was never actually processed. This was due to not properly copying over the global settings to the client settings when applying the configuration to the run-time object. Review: https://reviewboard.asterisk.org/r/4496/ ASTERISK-14233 ASTERISK-24780 #close Reported by: Simon Arlott patches: asterisk-13.1.0-24780 uploaded by Simon Arlott (License 5756) ........ Merged revisions 433395 from http://svn.asterisk.org/svn/asterisk/branches/11 Modified: branches/13/ (props changed) branches/13/res/res_xmpp.c Propchange: branches/13/ ------------------------------------------------------------------------------ Binary property 'branch-11-merged' - no diff available. Modified: branches/13/res/res_xmpp.c URL: http://svnview.digium.com/svn/asterisk/branches/13/res/res_xmpp.c?view=diff&rev=433396&r1=433395&r2=433396 ============================================================================== --- branches/13/res/res_xmpp.c (original) +++ branches/13/res/res_xmpp.c Wed Mar 25 10:30:42 2015 @@ -470,6 +470,7 @@ int message_timeout; /*!< Timeout for messages */ int priority; /*!< Resource priority */ struct ast_flags flags; /*!< Various options that have been set */ + struct ast_flags mod_flags; /*!< Global options that have been modified */ enum ikshowtype status; /*!< Presence status */ struct ast_xmpp_client *client; /*!< Pointer to the client */ struct ao2_container *buddies; /*!< Configured buddies */ @@ -741,8 +742,6 @@ if (!(cfg->global = ao2_alloc(sizeof(*cfg->global), NULL))) { goto error; } - - ast_set_flag(&cfg->global->general, XMPP_AUTOREGISTER | XMPP_AUTOACCEPT | XMPP_USETLS | XMPP_USESASL | XMPP_KEEPALIVE); if (!(cfg->clients = ao2_container_alloc(1, xmpp_config_hash, xmpp_config_cmp))) { goto error; @@ -3835,6 +3834,10 @@ static int xmpp_client_config_post_apply(void *obj, void *arg, int flags) { struct ast_xmpp_client_config *cfg = obj; + RAII_VAR(struct xmpp_config *, gcfg, ao2_global_obj_ref(globals), ao2_cleanup); + + /* Merge global options that have not been modified */ + ast_copy_flags(&cfg->flags, &gcfg->global->general, ~(cfg->mod_flags.flags) & (XMPP_AUTOPRUNE | XMPP_AUTOREGISTER | XMPP_AUTOACCEPT)); /* Merge buddies as need be */ ao2_callback(cfg->buddies, OBJ_MULTIPLE | OBJ_UNLINK, xmpp_client_config_merge_buddies, cfg->client->buddies); @@ -4511,10 +4514,13 @@ ast_set2_flag(&cfg->flags, ast_true(var->value), XMPP_KEEPALIVE); } else if (!strcasecmp(var->name, "autoprune")) { ast_set2_flag(&cfg->flags, ast_true(var->value), XMPP_AUTOPRUNE); + ast_set2_flag(&cfg->mod_flags, 1, XMPP_AUTOPRUNE); } else if (!strcasecmp(var->name, "autoregister")) { ast_set2_flag(&cfg->flags, ast_true(var->value), XMPP_AUTOREGISTER); + ast_set2_flag(&cfg->mod_flags, 1, XMPP_AUTOREGISTER); } else if (!strcasecmp(var->name, "auth_policy")) { ast_set2_flag(&cfg->flags, !strcasecmp(var->value, "accept") ? 1 : 0, XMPP_AUTOACCEPT); + ast_set2_flag(&cfg->mod_flags, 1, XMPP_AUTOACCEPT); } else if (!strcasecmp(var->name, "sendtodialplan")) { ast_set2_flag(&cfg->flags, ast_true(var->value), XMPP_SEND_TO_DIALPLAN); } else { @@ -4605,6 +4611,11 @@ aco_option_register(&cfg_info, "port", ACO_EXACT, client_options, "5222", OPT_UINT_T, 0, FLDSET(struct ast_xmpp_client_config, port)); aco_option_register(&cfg_info, "timeout", ACO_EXACT, client_options, "5", OPT_UINT_T, 0, FLDSET(struct ast_xmpp_client_config, message_timeout)); + /* Global options that can be overridden per client must not specify a default */ + aco_option_register_custom(&cfg_info, "autoprune", ACO_EXACT, client_options, NULL, client_bitfield_handler, 0); + aco_option_register_custom(&cfg_info, "autoregister", ACO_EXACT, client_options, NULL, client_bitfield_handler, 0); + aco_option_register_custom(&cfg_info, "auth_policy", ACO_EXACT, client_options, NULL, client_bitfield_handler, 0); + aco_option_register_custom(&cfg_info, "debug", ACO_EXACT, client_options, "no", client_bitfield_handler, 0); aco_option_register_custom(&cfg_info, "type", ACO_EXACT, client_options, "client", client_bitfield_handler, 0); aco_option_register_custom(&cfg_info, "distribute_events", ACO_EXACT, client_options, "no", client_bitfield_handler, 0); @@ -4612,9 +4623,6 @@ aco_option_register_custom(&cfg_info, "usesasl", ACO_EXACT, client_options, "yes", client_bitfield_handler, 0); aco_option_register_custom(&cfg_info, "forceoldssl", ACO_EXACT, client_options, "no", client_bitfield_handler, 0); aco_option_register_custom(&cfg_info, "keepalive", ACO_EXACT, client_options, "yes", client_bitfield_handler, 0); - aco_option_register_custom(&cfg_info, "autoprune", ACO_EXACT, client_options, "no", client_bitfield_handler, 0); - aco_option_register_custom(&cfg_info, "autoregister", ACO_EXACT, client_options, "yes", client_bitfield_handler, 0); - aco_option_register_custom(&cfg_info, "auth_policy", ACO_EXACT, client_options, "accept", client_bitfield_handler, 0); aco_option_register_custom(&cfg_info, "sendtodialplan", ACO_EXACT, client_options, "no", client_bitfield_handler, 0); aco_option_register_custom(&cfg_info, "status", ACO_EXACT, client_options, "available", client_status_handler, 0); aco_option_register_custom(&cfg_info, "buddy", ACO_EXACT, client_options, NULL, client_buddy_handler, 0); -- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- svn-commits mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/svn-commits