aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_voicemail.c
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-03-05 18:58:48 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-03-05 18:58:48 +0000
commit96a98fe1607c04c36f18e381e5b971cabedf4e53 (patch)
tree315b4e1fc0e83be8ccc4a4234f6be70e581abaa8 /apps/app_voicemail.c
parent8f9e1e1445be0e3f7527f1a84dcc6d1dc9636258 (diff)
Fix broken mailbox parsing when searchcontexts option is enabled.
When using the searchcontexts option in voicemail.conf, the code made the assumption that all mailbox names defined were unique across all contexts. However, the code did nothing to actually enforce this assumption, nor did it do anything to alert a user that he may have created an ambiguity in his voicemail.conf file by defining the same mailbox name in multiple contexts. With this change, we now will issue a nice long warning if searchcontexts is on and we encounter the same mailbox name in multiple contexts and ignore any duplicates after the first box. Whether searchcontexts is enabled or not, if we come across a duplicate mailbox in the same context, then we will issue a warning and ignore the duplicated mailbox. I have also added a small note to voicemail.conf.sample in the explanation for searchcontexts explaining that you cannot define the same mailbox in multiple contexts if you have enabled the option. (closes issue #14599) Reported by: lmadsen Patches: 14599.patch uploaded by mmichelson (license 60) (with slight modification) Tested by: lmadsen git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@180380 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_voicemail.c')
-rw-r--r--apps/app_voicemail.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 019df23ff..1a4b4b055 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -7903,18 +7903,26 @@ static struct ast_vm_user *find_or_create(char *context, char *mbox)
{
struct ast_vm_user *vmu;
AST_LIST_TRAVERSE(&users, vmu, list) {
- if (ast_test_flag((&globalflags), VM_SEARCH) && !strcasecmp(mbox, vmu->mailbox))
- break;
- if (context && (!strcasecmp(context, vmu->context)) && (!strcasecmp(mbox, vmu->mailbox)))
- break;
+ if (ast_test_flag((&globalflags), VM_SEARCH) && !strcasecmp(mbox, vmu->mailbox)) {
+ if (strcasecmp(vmu->context, context)) {
+ ast_log(LOG_WARNING, "\nIt has been detected that you have defined mailbox '%s' in separate\
+ \n\tcontexts and that you have the 'searchcontexts' option on. This type of\
+ \n\tconfiguration creates an ambiguity that you likely do not want. Please\
+ \n\tamend your voicemail.conf file to avoid this situation.\n", mbox);
+ }
+ ast_log(LOG_WARNING, "Ignoring duplicated mailbox %s\n", mbox);
+ return NULL;
+ }
+ if (!strcasecmp(context, vmu->context) && !strcasecmp(mbox, vmu->mailbox)) {
+ ast_log(LOG_WARNING, "Ignoring duplicated mailbox %s in context %s\n", mbox, context);
+ return NULL;
+ }
}
- if (!vmu) {
- if ((vmu = ast_calloc(1, sizeof(*vmu)))) {
- ast_copy_string(vmu->context, context, sizeof(vmu->context));
- ast_copy_string(vmu->mailbox, mbox, sizeof(vmu->mailbox));
- AST_LIST_INSERT_TAIL(&users, vmu, list);
- }
+ if ((vmu = ast_calloc(1, sizeof(*vmu)))) {
+ ast_copy_string(vmu->context, context, sizeof(vmu->context));
+ ast_copy_string(vmu->mailbox, mbox, sizeof(vmu->mailbox));
+ AST_LIST_INSERT_TAIL(&users, vmu, list);
}
return vmu;
}