From 0da4342b220c8ed2108a332a2a9703c80fbcc2ea Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Wed, 19 Dec 2018 16:13:48 +0100 Subject: mdeliver: keep permissions of message for freshly created files --- mdeliver.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'mdeliver.c') diff --git a/mdeliver.c b/mdeliver.c index e53e5e2..41d1e01 100644 --- a/mdeliver.c +++ b/mdeliver.c @@ -1,3 +1,4 @@ +#include #include #include @@ -84,7 +85,11 @@ tryagain: snprintf(tmp, sizeof tmp, "%s/tmp/%s", targetdir, id); - outfd = open(tmp, O_CREAT | O_WRONLY | O_EXCL, 0666); + struct stat st; + if (fstat(fileno(infile), &st) < 0) + st.st_mode = 0600; + outfd = open(tmp, O_CREAT | O_WRONLY | O_EXCL, + st.st_mode & 07777); if (outfd < 0) { if (errno == EEXIST) goto tryagain; -- cgit 1.4.1