Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 180082) +++ apps/app_voicemail.c (working copy) @@ -7903,18 +7903,26 @@ { 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, "It 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_NOTICE, "Ignoring duplicated mailbox %s\n", mbox); + return NULL; + } + if (!strcasecmp(context, vmu->context) && !strcasecmp(mbox, vmu->mailbox)) { + ast_log(LOG_NOTICE, "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; } Index: configs/voicemail.conf.sample =================================================================== --- configs/voicemail.conf.sample (revision 180082) +++ configs/voicemail.conf.sample (working copy) @@ -188,6 +188,9 @@ ; searchcontexts=yes ; Current default behavior is to search only the default context ; if one is not specified. The older behavior was to search all contexts. ; This option restores the old behavior [DEFAULT=no] + ; Note: If you have this option enabled, then you will be required to have + ; unique mailbox names across all contexts. Otherwise, an ambiguity is created + ; since it is impossible to know which mailbox to retrieve when one is requested. ; callback=fromvm ; Context to call back from ; if not listed, calling the sender back will not be permitted ; exitcontext=fromvm ; Context to go to on user exit such as * or 0