dovecot-2.0: safe_mkstemp()'s mode parameter didn't override uma...

dovecot at dovecot.org dovecot at dovecot.org
Fri May 1 19:30:33 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/92d0383cc323
changeset: 9191:92d0383cc323
user:      Timo Sirainen <tss at iki.fi>
date:      Fri May 01 12:30:07 2009 -0400
description:
safe_mkstemp()'s mode parameter didn't override umask as it was supposed to.

diffstat:

1 file changed, 4 insertions(+), 1 deletion(-)
src/lib/safe-mkstemp.c |    5 ++++-

diffs (22 lines):

diff -r cc280979ea8d -r 92d0383cc323 src/lib/safe-mkstemp.c
--- a/src/lib/safe-mkstemp.c	Thu Apr 30 20:22:59 2009 -0400
+++ b/src/lib/safe-mkstemp.c	Fri May 01 12:30:07 2009 -0400
@@ -16,6 +16,7 @@ int safe_mkstemp(string_t *prefix, mode_
 	size_t prefix_len;
 	struct stat st;
 	unsigned char randbuf[8];
+	mode_t old_umask;
 	int fd;
 
 	prefix_len = str_len(prefix);
@@ -32,7 +33,9 @@ int safe_mkstemp(string_t *prefix, mode_
 			return -1;
 		}
 
-		fd = open(str_c(prefix), O_RDWR | O_EXCL | O_CREAT, mode);
+		old_umask = umask(0666 ^ mode);
+		fd = open(str_c(prefix), O_RDWR | O_EXCL | O_CREAT, 0666);
+		umask(old_umask);
 		if (fd != -1)
 			break;
 


More information about the dovecot-cvs mailing list