[PATCH v2] cli/insert: new message file can be world-readable (rely on umask)

Daniel Kahn Gillmor dkg at fifthhorseman.net
Tue Feb 6 11:43:56 PST 2018


There are legitimate cases (public archives) where a user might
actually want their archive to be readable to the world.

"notmuch insert" historically used mode 0600 (unreadable by group or
other), but that choice doesn't appear to have been specifically
justified (perhaps an abundance of caution?).

This patch also adjusts the default mode used for --create-folder, to
be mode 0755 before the application of the umask.

If the user wants "notmuch insert" to create files or folders that are
not readable by group or other, they can set their umask more
restrictively.
---
 notmuch-insert.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/notmuch-insert.c b/notmuch-insert.c
index 48490b51..4f1116ed 100644
--- a/notmuch-insert.c
+++ b/notmuch-insert.c
@@ -162,7 +162,7 @@ static bool
 maildir_create_folder (const void *ctx, const char *maildir)
 {
     const char *subdirs[] = { "cur", "new", "tmp" };
-    const int mode = 0700;
+    const int mode = 0755;
     char *subdir;
     unsigned int i;
 
@@ -227,7 +227,7 @@ maildir_mktemp (const void *ctx, const char *maildir, char **path_out)
 	    return -1;
 	}
 
-	fd = open (path, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0600);
+	fd = open (path, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0644);
     } while (fd == -1 && errno == EEXIST);
 
     if (fd == -1) {
-- 
2.15.1



More information about the notmuch mailing list