changeset 9131:c8bb7c18f17b HEAD

safe_mkstemp*() was used incorrectly. umask() no longer changes its behavior.
author Timo Sirainen <tss@iki.fi>
date Mon, 15 Jun 2009 20:48:12 -0400
parents 73b9d8556f5a
children 6886f1e18c76
files src/lib-storage/index/dbox/dbox-index.c src/lib/file-dotlock.c
diffstat 2 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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 dbox_mailbox *mbox, string_t *temp_path,
 				bool locked)
 {
-	mode_t old_mask;
 	int fd;
 
 	if (locked) {
@@ -559,9 +558,8 @@
 	}
 
 	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,
--- 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 @@
 {
 	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 @@
 				    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;