]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Don't create the context for users in users.conf until we know at least one user...
authorRussell Bryant <russell@russellbryant.com>
Sun, 14 Oct 2007 15:24:52 +0000 (15:24 +0000)
committerRussell Bryant <russell@russellbryant.com>
Sun, 14 Oct 2007 15:24:52 +0000 (15:24 +0000)
(closes issue #10971)
Reported by: dimas
Patches:
      pbxconfig.patch uploaded by dimas (license 88)

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

pbx/pbx_config.c

index 225fb139a702c9679575ba092defc30432f865ee..5f2a963112a2041b1be5acb952941a9bacf6da8f 100644 (file)
@@ -2366,14 +2366,11 @@ static void pbx_load_users(void)
        int len;
        int hasvoicemail;
        int start, finish, x;
-       struct ast_context *con;
+       struct ast_context *con = NULL;
        
        cfg = ast_config_load("users.conf");
        if (!cfg)
                return;
-       con = ast_context_find_or_create(&local_contexts, userscontext, registrar);
-       if (!con)
-               return;
 
        for (cat = ast_category_browse(cfg, NULL); cat ; cat = ast_category_browse(cfg, cat)) {
                if (!strcasecmp(cat, "general"))
@@ -2425,6 +2422,16 @@ static void pbx_load_users(void)
                        }
                }
                if (!ast_strlen_zero(iface)) {
+                       /* Only create a context here when it is really needed. Otherwise default empty context
+                       created by pbx_config may conflict with the one explicitly created by pbx_ael */
+                       if (!con)
+                               con = ast_context_find_or_create(&local_contexts, userscontext, registrar);
+
+                       if (!con) {
+                               ast_log(LOG_ERROR, "Can't find/create user context '%s'\n", userscontext);
+                               return;
+                       }
+
                        /* Add hint */
                        ast_add_extension2(con, 0, cat, -1, NULL, NULL, iface, NULL, NULL, registrar);
                        /* If voicemail, use "stdexten" else use plain old dial */