# HG changeset patch # User Timo Sirainen # Date 1245113292 14400 # Node ID c8bb7c18f17b69a7831a5461a97ca792451d1b53 # Parent 73b9d8556f5a1662e7f9c4bd9a5da9689892412b safe_mkstemp*() was used incorrectly. umask() no longer changes its behavior. 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 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, 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 @@ { 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;