Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 37320) +++ apps/app_voicemail.c (working copy) @@ -795,21 +795,24 @@ if(mkdir(dest, mode) && errno != EEXIST) { ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", dest, strerror(errno)); return 0; - } + } else + chmod(dest, mode); } if(ext && ext[0] != '\0') { make_dir(dest, len, context, ext, ""); if(mkdir(dest, mode) && errno != EEXIST) { ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", dest, strerror(errno)); return 0; - } + } else + chmod(dest, mode); } if(mailbox && mailbox[0] != '\0') { make_dir(dest, len, context, ext, mailbox); if(mkdir(dest, mode) && errno != EEXIST) { ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", dest, strerror(errno)); return 0; - } + } else + chmod(dest, mode); } return 1; } @@ -2632,6 +2635,7 @@ snprintf(txtfile, sizeof(txtfile), "%s.txt", fn); ast_filerename(tmptxtfile, fn, NULL); rename(tmptxtfile, txtfile); + chmod(txtfile, VOICEMAIL_FILE_MODE); ast_unlock_path(dir); @@ -3523,12 +3527,9 @@ /* if (ast_play_and_wait(chan, "vm-savedto")) break; */ - snprintf(todir, sizeof(todir), "%s%s/%s/INBOX", VM_SPOOL_DIR, vmtmp->context, vmtmp->mailbox); - snprintf(sys, sizeof(sys), "mkdir -p %s\n", todir); snprintf(ext_context, sizeof(ext_context), "%s@%s", vmtmp->mailbox, vmtmp->context); - ast_log(LOG_DEBUG, "%s", sys); - ast_safe_system(sys); - + create_dirpath(todir, sizeof(todir), vmtmp->context, vmtmp->mailbox, "INBOX"); + res = count_messages(receiver, todir); if ( (res == ERROR_LOCK_PATH) || (res < 0) ) { @@ -6613,6 +6614,13 @@ signed char zero_gain = 0; char *acceptdtmf = "#"; char *canceldtmf = ""; + char *tmp = ast_strdupa(fmt); + int i; + char tmpfile[256]; + AST_DECLARE_APP_ARGS(fmts, + AST_APP_ARG(fmt[10]); + ); + AST_STANDARD_APP_ARGS(fmts, tmp); /* Note that urgent and private are for flagging messages as such in the future */ @@ -6670,6 +6678,16 @@ if (ast_test_flag(vmu, VM_OPERATOR)) canceldtmf = "0"; cmd = ast_play_and_record_full(chan, playfile, recordfile, maxtime, fmt, duration, silencethreshold, maxsilence, unlockdir, acceptdtmf, canceldtmf); + + /* We have a problem with relying on umask for this, since umask + * affects all files created. If our voicemail files need to have a + * more restrictive permission set than other files recorded, then + * we need to set the voicemail permissions explicitly. */ + for (i = 0; i < fmts.argc; i++) { + snprintf(tmpfile, sizeof(tmpfile), "%s.%s", recordfile, strcasecmp(fmts.fmt[i], "wav49") ? fmts.fmt[i] : "WAV"); + chmod(tmpfile, VOICEMAIL_FILE_MODE); + } + if (record_gain) ast_channel_setoption(chan, AST_OPTION_RXGAIN, &zero_gain, sizeof(zero_gain), 0); if (cmd == -1) {