diff -pruN asterisk-1.4.0/apps/app_voicemail.c asterisk-1.4.0-pc/apps/app_voicemail.c --- asterisk-1.4.0/apps/app_voicemail.c 2006-12-20 13:56:09.000000000 +1100 +++ asterisk-1.4.0-pc/apps/app_voicemail.c 2007-03-08 14:13:59.434828381 +1100 @@ -2758,13 +2758,16 @@ static void run_externnotify(char *conte if (!ast_strlen_zero(context)) snprintf(ext_context, sizeof(ext_context), "%s@%s", extension, context); else - ast_copy_string(ext_context, extension, sizeof(ext_context)); + snprintf(ext_context, sizeof(ext_context), "%s@", extension); if (!strcasecmp(externnotify, "smdi")) { - if (ast_app_has_voicemail(ext_context, NULL)) + if (ast_app_has_voicemail(ext_context, NULL)) { + ast_log(LOG_DEBUG, "SMDI set MWI ext %s!\n", extension); ast_smdi_mwi_set(smdi_iface, extension); - else + } else { + ast_log(LOG_DEBUG, "SMDI unset MWI ext %s!\n", extension); ast_smdi_mwi_unset(smdi_iface, extension); + } if ((mwi_msg = ast_smdi_mwi_message_wait(smdi_iface, SMDI_MWI_WAIT_TIMEOUT))) { ast_log(LOG_ERROR, "Error executing SMDI MWI change for %s on %s\n", extension, smdi_iface->name); @@ -3107,6 +3110,11 @@ static int leave_voicemail(struct ast_ch ast_filerename(tmptxtfile, fn, NULL); rename(tmptxtfile, txtfile); + /* Properly set permissions on voicemail text descriptor file. + Unfortunately mkstemp() makes this file 0600 on most unix systems. */ + if ((res = chmod(txtfile, VOICEMAIL_FILE_MODE)) < 0) + ast_log(LOG_ERROR, "Couldn't set permissions on voicemail text file %s: %s", txtfile, strerror(errno)); + ast_unlock_path(dir); #ifndef IMAP_STORAGE /* Are there to be more recipients of this message? */ @@ -7913,7 +7921,7 @@ static int play_record_review(struct ast ast_channel_setoption(chan, AST_OPTION_RXGAIN, &record_gain, sizeof(record_gain), 0); 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); + cmd = ast_play_and_record_full(chan, playfile, recordfile, VOICEMAIL_FILE_MODE, maxtime, fmt, duration, silencethreshold, maxsilence, unlockdir, acceptdtmf, canceldtmf); if (record_gain) ast_channel_setoption(chan, AST_OPTION_RXGAIN, &zero_gain, sizeof(zero_gain), 0); if (cmd == -1) { diff -pruN asterisk-1.4.0/include/asterisk/app.h asterisk-1.4.0-pc/include/asterisk/app.h --- asterisk-1.4.0/include/asterisk/app.h 2006-07-31 01:02:34.000000000 +1000 +++ asterisk-1.4.0-pc/include/asterisk/app.h 2007-03-08 11:49:08.348427000 +1100 @@ -167,7 +167,7 @@ int ast_control_streamfile(struct ast_ch /*! Play a stream and wait for a digit, returning the digit that was pressed */ int ast_play_and_wait(struct ast_channel *chan, const char *fn); -int ast_play_and_record_full(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime_sec, const char *fmt, int *duration, int silencethreshold, int maxsilence_ms, const char *path, const char *acceptdtmf, const char *canceldtmf); +int ast_play_and_record_full(struct ast_channel *chan, const char *playfile, const char *recordfile, int filemode, int maxtime_sec, const char *fmt, int *duration, int silencethreshold, int maxsilence_ms, const char *path, const char *acceptdtmf, const char *canceldtmf); /*! Record a file for a max amount of time (in seconds), in a given list of formats separated by '|', outputting the duration of the recording, and with a maximum \n diff -pruN asterisk-1.4.0/include/asterisk.h asterisk-1.4.0-pc/include/asterisk.h --- asterisk-1.4.0/include/asterisk.h 2006-12-17 07:12:41.000000000 +1100 +++ asterisk-1.4.0-pc/include/asterisk.h 2007-03-08 11:45:54.030173000 +1100 @@ -33,6 +33,9 @@ #define DEFAULT_LANGUAGE "en" +#define DEFAULT_DIR_MODE 0770 +#define DEFAULT_FILE_MODE 0660 + #define DEFAULT_SAMPLE_RATE 8000 #define DEFAULT_SAMPLES_PER_MS ((DEFAULT_SAMPLE_RATE)/1000) diff -pruN asterisk-1.4.0/main/app.c asterisk-1.4.0-pc/main/app.c --- asterisk-1.4.0/main/app.c 2006-10-31 03:27:34.000000000 +1100 +++ asterisk-1.4.0-pc/main/app.c 2007-03-08 11:55:18.104113000 +1100 @@ -484,7 +484,7 @@ static int global_maxsilence = 0; * @param canceldtmf DTMF digits that will cancel the recording. */ -static int __ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int beep, int silencethreshold, int maxsilence, const char *path, int prepend, const char *acceptdtmf, const char *canceldtmf) +static int __ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int filemode, int maxtime, const char *fmt, int *duration, int beep, int silencethreshold, int maxsilence, const char *path, int prepend, const char *acceptdtmf, const char *canceldtmf) { int d = 0; char *fmts; @@ -546,7 +546,7 @@ static int __ast_play_and_record(struct end = start = time(NULL); /* pre-initialize end to be same as start in case we never get into loop */ for (x = 0; x < fmtcnt; x++) { - others[x] = ast_writefile(prepend ? prependfile : recordfile, sfmt[x], comment, O_TRUNC, 0, 0700); + others[x] = ast_writefile(prepend ? prependfile : recordfile, sfmt[x], comment, O_TRUNC, 0, filemode); if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "x=%d, open writing: %s format: %s, %p\n", x, prepend ? prependfile : recordfile, sfmt[x], others[x]); @@ -743,19 +743,19 @@ static int __ast_play_and_record(struct static char default_acceptdtmf[] = "#"; static char default_canceldtmf[] = ""; -int ast_play_and_record_full(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int silencethreshold, int maxsilence, const char *path, const char *acceptdtmf, const char *canceldtmf) +int ast_play_and_record_full(struct ast_channel *chan, const char *playfile, const char *recordfile, int filemode, int maxtime, const char *fmt, int *duration, int silencethreshold, int maxsilence, const char *path, const char *acceptdtmf, const char *canceldtmf) { - return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, 0, silencethreshold, maxsilence, path, 0, S_OR(acceptdtmf, default_acceptdtmf), S_OR(canceldtmf, default_canceldtmf)); + return __ast_play_and_record(chan, playfile, recordfile, filemode, maxtime, fmt, duration, 0, silencethreshold, maxsilence, path, 0, S_OR(acceptdtmf, default_acceptdtmf), S_OR(canceldtmf, default_canceldtmf)); } int ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int silencethreshold, int maxsilence, const char *path) { - return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, 0, silencethreshold, maxsilence, path, 0, default_acceptdtmf, default_canceldtmf); + return __ast_play_and_record(chan, playfile, recordfile, DEFAULT_FILE_MODE, maxtime, fmt, duration, 0, silencethreshold, maxsilence, path, 0, default_acceptdtmf, default_canceldtmf); } int ast_play_and_prepend(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime, char *fmt, int *duration, int beep, int silencethreshold, int maxsilence) { - return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, beep, silencethreshold, maxsilence, NULL, 1, default_acceptdtmf, default_canceldtmf); + return __ast_play_and_record(chan, playfile, recordfile, DEFAULT_FILE_MODE, maxtime, fmt, duration, beep, silencethreshold, maxsilence, NULL, 1, default_acceptdtmf, default_canceldtmf); } /* Channel group core functions */