dovecot-1.2: safe_mkstemp*() was used incorrectly. umask() no lo...

dovecot at dovecot.org dovecot at dovecot.org
Tue Jun 16 03:48:18 EEST 2009


details:   http://hg.dovecot.org/dovecot-1.2/rev/c8bb7c18f17b
changeset: 9131:c8bb7c18f17b
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Jun 15 20:48:12 2009 -0400
description:
safe_mkstemp*() was used incorrectly. umask() no longer changes its behavior.

diffstat:

2 files changed, 6 insertions(+), 5 deletions(-)
src/lib-storage/index/dbox/dbox-index.c |    6 ++----
src/lib/file-dotlock.c                  |    5 ++++-

diffs (46 lines):

diff -r 73b9d8556f5a -r c8bb7c18f17b src/lib-storage/index/dbox/dbox-index.c
--- a/src/lib-storage/index/dbox/dbox-index.c	Mon Jun 15 20:46:51 2009 -0400
+++ b/src/lib-storage/index/dbox/dbox-index.c	Mon Jun 15 20:48:12 2009 -0400
@@ -550,7 +550,6 @@ static int dbox_index_create_fd(struct d
 static int dbox_index_create_fd(struct dbox_mailbox *mbox, string_t *temp_path,
 				bool locked)
 {
-	mode_t old_mask;
 	int fd;
 
 	if (locked) {
@@ -559,9 +558,8 @@ static int dbox_index_create_fd(struct d
 	}
 
 	str_append_c(temp_path, '.');
-	old_mask = umask(0777 & ~mbox->ibox.box.file_create_mode);
-	fd = safe_mkstemp_hostpid(temp_path, 0777, (uid_t)-1, (gid_t)-1);
-	umask(old_mask);
+	fd = safe_mkstemp_hostpid(temp_path, mbox->ibox.box.file_create_mode,
+				  (uid_t)-1, (gid_t)-1);
 
 	if (fd == -1) {
 		mail_storage_set_critical(mbox->ibox.box.storage,
diff -r 73b9d8556f5a -r c8bb7c18f17b src/lib/file-dotlock.c
--- a/src/lib/file-dotlock.c	Mon Jun 15 20:46:51 2009 -0400
+++ b/src/lib/file-dotlock.c	Mon Jun 15 20:48:12 2009 -0400
@@ -319,6 +319,7 @@ static int try_create_lock_hardlink(stru
 {
 	const char *temp_prefix = lock_info->set->temp_prefix;
 	const char *p;
+	mode_t old_mask;
 
 	if (lock_info->temp_path == NULL) {
 		/* we'll need our temp file first. */
@@ -346,8 +347,10 @@ static int try_create_lock_hardlink(stru
 				    my_hostname, my_pid);
 		}
 
-		lock_info->fd = safe_mkstemp(tmp_path, 0666,
+		old_mask = umask(0666);
+		lock_info->fd = safe_mkstemp(tmp_path, 0666 ^ old_mask,
 					     (uid_t)-1, (gid_t)-1);
+		umask(old_mask);
 		if (lock_info->fd == -1)
 			return -1;
 


More information about the dovecot-cvs mailing list