]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fixed dovecot-uidlist permissions for shared mailboxes
authorTimo Sirainen <tss@iki.fi>
Mon, 20 Oct 2003 06:18:58 +0000 (09:18 +0300)
committerTimo Sirainen <tss@iki.fi>
Mon, 20 Oct 2003 06:18:58 +0000 (09:18 +0300)
--HG--
branch : HEAD

src/lib-index/mail-index.h
src/lib-index/maildir/maildir-uidlist.c
src/lib-storage/index/index-storage.h
src/lib-storage/index/maildir/maildir-save.c
src/lib-storage/index/maildir/maildir-storage.c
src/lib/file-dotlock.c

index ae5b7dc490fce14a71916f9ed2953fe8c1908693..aa7809a3d4a9959754fb1693eb5ff2f2ec0c880f 100644 (file)
@@ -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_. */
index 254be9ece7ddcce0d9dc549e9836df8c7d611edb..1b3e0a31e577a603b372c777006881c77bae0ebe 100644 (file)
 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;
index 311b4c263f015d1f1021f69d8d025783557bc1e1..eba3509bb4414095de8c97bddf191522e1388835 100644 (file)
@@ -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;
index 93b59421871641175dff9fa3e0c8a7bb07fc9baf..a389b866b93e19866b6587819fbd7f5dca991e38 100644 (file)
@@ -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;
 
index d17727560e05c8c6a4350e86e2811e3539bc1b4d..81aa82df54cd014d4192d97ceb5929df04c07e85 100644 (file)
@@ -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;
        }
 
index 8ce94d1f121dabc8e48d5d6c07ec1b64900d1abf..85dfa47b887e97e3fcd8ed42fa4423f39e6951d4 100644 (file)
@@ -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;