]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
chan_sip: Fix a bug causing SIP reloads to remove all entries from the registry
authorJonathan Rose <jrose@digium.com>
Thu, 1 Nov 2012 14:52:23 +0000 (14:52 +0000)
committerJonathan Rose <jrose@digium.com>
Thu, 1 Nov 2012 14:52:23 +0000 (14:52 +0000)
A regression was introduced in chan_sip by changes to sip reload introduced by
r349097. That patch moved peer purging from the beginning of the reload to
after the general configuration was finished. This patch fixes that by undoing
the repositioning of the original peer purging code and using a similar
function after performing general configuration that purges only autocreated
peers that were created when persist mode isn't enabled.

(closes issue ASTERISK-20611)
Reported by: Alisher
Review: https://reviewboard.asterisk.org/r/2171/

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@375575 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c
configs/sip.conf.sample

index 950f9460989b511555954e5e76ed6a41245dfcc1..38de6df717685bf47a877764fa7476a887d34cca 100644 (file)
@@ -30766,7 +30766,16 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
 static int peer_markall_func(void *device, void *arg, int flags)
 {
        struct sip_peer *peer = device;
-       if (!peer->selfdestruct || sip_cfg.autocreatepeer != AUTOPEERS_PERSIST) {
+       if (!peer->selfdestruct) {
+               peer->the_mark = 1;
+       }
+       return 0;
+}
+
+static int peer_markall_autopeers_func(void *device, void *arg, int flags)
+{
+       struct sip_peer *peer = device;
+       if (peer->selfdestruct) {
                peer->the_mark = 1;
        }
        return 0;
@@ -30908,6 +30917,11 @@ static int reload_config(enum channelreloadreason reason)
                ast_mutex_unlock(&authl_lock);
 
                cleanup_all_regs();
+
+               /* Then, actually destroy users and registry */
+               ASTOBJ_CONTAINER_DESTROYALL(&regl, sip_registry_destroy);
+               ast_debug(4, "--------------- Done destroying registry list\n");
+               ao2_t_callback(peers, OBJ_NODATA, peer_markall_func, NULL, "callback to mark all peers");
        }
 
        /* Reset certificate handling for TLS sessions */
@@ -31634,11 +31648,8 @@ static int reload_config(enum channelreloadreason reason)
                max_subexpiry = max_expiry;
        }
 
-       if (reason != CHANNEL_MODULE_LOAD) {
-               /* Then, actually destroy users and registry */
-               ASTOBJ_CONTAINER_DESTROYALL(&regl, sip_registry_destroy);
-               ast_debug(4, "--------------- Done destroying registry list\n");
-               ao2_t_callback(peers, OBJ_NODATA, peer_markall_func, NULL, "callback to mark all peers");
+       if (reason != CHANNEL_MODULE_LOAD && sip_cfg.autocreatepeer != AUTOPEERS_PERSIST) {
+               ao2_t_callback(peers, OBJ_NODATA, peer_markall_autopeers_func, NULL, "callback to mark autopeers for destruction");
        }
 
        if (subscribe_network_change) {
index ba481c048475dbdc8b8202cf5209fc8292fe2432..3d6db9798ee2f0588031e98bb3078fac3fc18fc6 100644 (file)
@@ -510,14 +510,14 @@ srvlookup=yes                   ; Enable DNS SRV lookups on outbound calls
 ;
 ;refer_addheaders=yes  ; on by default
 
-;autocreatepeers=no             ; Allow any not exsplicitly defined here UAC to register
-                                ; WITHOUT AUTHENTICATION. Enabling this options poses a high
-                                ; potential security risk and should be avoided unless the 
-                                ; server is behind a trusted firewall. 
-                                ; When enabled by setting to "yes", the autocreated peers are
-                                ; pruned immediately when the "sip reload" command is issued
-                                ; through CLI. When enabled by setting to "persist", the auto-
-                                ; created peers survive the "sip reload" command.
+;autocreatepeer=no             ; Allow any UAC not explicitly defined to register
+                               ; WITHOUT AUTHENTICATION. Enabling this options poses a high
+                               ; potential security risk and should be avoided unless the
+                               ; server is behind a trusted firewall.
+                               ; If set to "yes", then peers created in this fashion
+                               ; are purged during SIP reloads.
+                               ; When set to "persist", the peers created in this fashion
+                               ; are not purged during SIP reloads.
 
 ;
 ;------------------------ TLS settings ------------------------------------------------------------