diff -Naru /s/mutt-2.2.12/globals.h ./globals.h --- /s/mutt-2.2.12/globals.h 2023-09-01 08:32:23.000000000 +0200 +++ ./globals.h 2023-09-10 10:13:54.320014522 +0200 @@ -250,6 +250,8 @@ WHERE short ScoreThresholdRead; WHERE short ScoreThresholdFlag; +WHERE short SaveFilePerm; + #ifdef USE_SIDEBAR WHERE short SidebarWidth; WHERE LIST *SidebarWhitelist; diff -Naru /s/mutt-2.2.12/init.h ./init.h --- /s/mutt-2.2.12/init.h 2023-09-01 08:32:23.000000000 +0200 +++ ./init.h 2023-09-10 10:18:22.900015368 +0200 @@ -3460,6 +3460,11 @@ ** \fBNote:\fP This only applies to mbox and MMDF folders, Mutt does not ** delete MH and Maildir directories. */ + { "save_file_perm", DT_NUM, R_NONE, {.p=&SaveFilePerm}, {.l=0600} }, + /* + ** This variable controls the permissions of saved attachments. + ** Use standard POSIX permissions in octal notation, i.e. 0644. + */ { "save_history", DT_NUM, R_NONE, {.p=&SaveHist}, {.l=0} }, /* ** .pp diff -Naru /s/mutt-2.2.12/main.c ./main.c --- /s/mutt-2.2.12/main.c 2023-09-01 08:32:23.000000000 +0200 +++ ./main.c 2023-09-10 10:15:20.128014792 +0200 @@ -690,7 +690,10 @@ mutt_error = mutt_nocurses_error; mutt_message = mutt_nocurses_error; SRAND (time (NULL)); - umask (077); + if(SaveFilePerm==600) + umask (077); + else + umask (000); memset (Options, 0, sizeof (Options)); memset (QuadOptions, 0, sizeof (QuadOptions)); diff -Naru /s/mutt-2.2.12/muttlib.c ./muttlib.c --- /s/mutt-2.2.12/muttlib.c 2023-08-18 05:03:18.000000000 +0200 +++ ./muttlib.c 2023-09-10 10:36:18.872018760 +0200 @@ -2562,6 +2562,22 @@ BUFFER *safe_file = NULL; BUFFER *safe_dir = NULL; + /* Convert file permission from decadic to octal */ + unsigned short own=0; + unsigned short grp=0; + unsigned short oth=0; + unsigned short SFPoct=0; + own=SaveFilePerm/100; + grp=(SaveFilePerm-own*100)/10; + oth=SaveFilePerm-(own*100)-(grp*10); + if(own>7||grp>7||oth>7) + { + SFPoct=0600; + dprint(1,(debugfile,"safe_open: Value %d is not valid octal permission mask.\n",SaveFilePerm)); + } + else + SFPoct=own<<6|grp<<3|oth; + if (flags & O_EXCL) { safe_file = mutt_buffer_pool_get (); @@ -2573,7 +2589,7 @@ goto cleanup; } - if ((fd = open (mutt_b2s (safe_file), flags, 0600)) < 0) + if ((fd = open (mutt_b2s (safe_file), flags, SFPoct)) < 0) { rmdir (mutt_b2s (safe_dir)); goto cleanup; @@ -2588,7 +2604,7 @@ } } - if ((fd = open (path, flags & ~O_EXCL, 0600)) < 0) + if ((fd = open (path, flags & ~O_EXCL, SFPoct)) < 0) goto cleanup; /* make sure the file is not symlink */