From: Timo Sirainen Date: Mon, 20 Oct 2003 06:18:58 +0000 (+0300) Subject: fixed dovecot-uidlist permissions for shared mailboxes X-Git-Tag: 1.1.alpha1~4281 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=181aa01111e2de2dae413b4c1ccfcfc4e801ac40;p=thirdparty%2Fdovecot%2Fcore.git fixed dovecot-uidlist permissions for shared mailboxes --HG-- branch : HEAD --- diff --git a/src/lib-index/mail-index.h b/src/lib-index/mail-index.h index ae5b7dc490..aa7809a3d4 100644 --- a/src/lib-index/mail-index.h +++ b/src/lib-index/mail-index.h @@ -329,6 +329,7 @@ struct mail_index { mail_lock_notify_callback_t *lock_notify_cb; void *lock_notify_context; + mode_t mail_create_mode; unsigned int private_flags_mask; /* these fields are OR'ed to the fields in index header once we @@ -366,7 +367,8 @@ struct mail_index { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0 #endif /* defaults - same as above but prefixed with mail_index_. */ diff --git a/src/lib-index/maildir/maildir-uidlist.c b/src/lib-index/maildir/maildir-uidlist.c index 254be9ece7..1b3e0a31e5 100644 --- a/src/lib-index/maildir/maildir-uidlist.c +++ b/src/lib-index/maildir/maildir-uidlist.c @@ -20,14 +20,17 @@ int maildir_uidlist_try_lock(struct mail_index *index) { const char *path; + mode_t old_mask; int fd; if (INDEX_IS_UIDLIST_LOCKED(index)) return 1; path = t_strconcat(index->control_dir, "/" MAILDIR_UIDLIST_NAME, NULL); + old_mask = umask(0777 & ~index->mail_create_mode); fd = file_dotlock_open(path, NULL, 0, 0, UIDLIST_LOCK_STALE_TIMEOUT, NULL, NULL); + umask(old_mask); if (fd == -1) { if (errno == EAGAIN) return 0; diff --git a/src/lib-storage/index/index-storage.h b/src/lib-storage/index/index-storage.h index 311b4c263f..eba3509bb4 100644 --- a/src/lib-storage/index/index-storage.h +++ b/src/lib-storage/index/index-storage.h @@ -29,8 +29,6 @@ struct index_mailbox { enum mailbox_lock_type lock_type; struct mail_cache_transaction_ctx *trans_ctx; - mode_t mail_create_mode; /* for maildir */ - struct timeout *autosync_to; struct index_autosync_file *autosync_files; struct index_autosync_io *autosync_ios; diff --git a/src/lib-storage/index/maildir/maildir-save.c b/src/lib-storage/index/maildir/maildir-save.c index 93b5942187..a389b866b9 100644 --- a/src/lib-storage/index/maildir/maildir-save.c +++ b/src/lib-storage/index/maildir/maildir-save.c @@ -38,7 +38,7 @@ maildir_read_into_tmp(struct index_mailbox *ibox, const char *dir, int fd; fd = maildir_create_tmp(ibox->index, dir, - ibox->mail_create_mode, &path); + ibox->index->mail_create_mode, &path); if (fd == -1) return NULL; diff --git a/src/lib-storage/index/maildir/maildir-storage.c b/src/lib-storage/index/maildir/maildir-storage.c index d17727560e..81aa82df54 100644 --- a/src/lib-storage/index/maildir/maildir-storage.c +++ b/src/lib-storage/index/maildir/maildir-storage.c @@ -418,9 +418,9 @@ maildir_open(struct mail_storage *storage, const char *name, /* for shared mailboxes get the create mode from the permissions of dovecot-shared file */ if (stat(t_strconcat(path, "/dovecot-shared", NULL), &st) < 0) - ibox->mail_create_mode = 0600; + index->mail_create_mode = 0600; else { - ibox->mail_create_mode = st.st_mode & 0666; + index->mail_create_mode = st.st_mode & 0666; index->private_flags_mask = MAIL_SEEN; } diff --git a/src/lib/file-dotlock.c b/src/lib/file-dotlock.c index 8ce94d1f12..85dfa47b88 100644 --- a/src/lib/file-dotlock.c +++ b/src/lib/file-dotlock.c @@ -190,7 +190,7 @@ static int create_temp_file(const char *prefix, const char **path_r) return -1; } - fd = open(*path_r, O_RDWR | O_EXCL | O_CREAT, 0644); + fd = open(*path_r, O_RDWR | O_EXCL | O_CREAT, 0666); if (fd != -1) return fd;