Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6598:7eb8fd17f8c5 HEAD
Moved mail_create_mode/gid from struct maildir_mailbox to struct mailbox.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 21 Oct 2007 17:41:47 +0300 |
parents | 7b5b3b0c7002 |
children | a6f51026b969 |
files | src/lib-storage/index/index-storage.c src/lib-storage/index/maildir/maildir-copy.c src/lib-storage/index/maildir/maildir-keywords.c src/lib-storage/index/maildir/maildir-save.c src/lib-storage/index/maildir/maildir-storage.c src/lib-storage/index/maildir/maildir-storage.h src/lib-storage/index/maildir/maildir-uidlist.c src/lib-storage/mail-storage-private.h |
diffstat | 8 files changed, 32 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-storage.c Sun Oct 21 17:41:30 2007 +0300 +++ b/src/lib-storage/index/index-storage.c Sun Oct 21 17:41:47 2007 +0300 @@ -404,6 +404,11 @@ ibox->box.storage = storage; ibox->box.name = p_strdup(ibox->box.pool, name); + if (ibox->box.file_create_mode == 0) { + ibox->box.file_create_mode = 0600; + ibox->box.file_create_gid = (gid_t)-1; + } + array_create(&ibox->box.module_contexts, ibox->box.pool, sizeof(void *), 5);
--- a/src/lib-storage/index/maildir/maildir-copy.c Sun Oct 21 17:41:30 2007 +0300 +++ b/src/lib-storage/index/maildir/maildir-copy.c Sun Oct 21 17:41:47 2007 +0300 @@ -201,13 +201,10 @@ } static bool -maildir_compatible_file_modes(struct maildir_mailbox *mbox1, - struct mailbox *box2) +maildir_compatible_file_modes(struct mailbox *box1, struct mailbox *box2) { - struct maildir_mailbox *mbox2 = (struct maildir_mailbox *)box2; - - return mbox1->mail_create_mode == mbox2->mail_create_mode && - mbox2->mail_create_gid == mbox2->mail_create_gid; + return box1->file_create_mode == box2->file_create_mode && + box1->file_create_gid == box2->file_create_gid; } int maildir_copy(struct mailbox_transaction_context *_t, struct mail *mail, @@ -221,7 +218,7 @@ if (mbox->storage->copy_with_hardlinks && mail->box->storage == mbox->ibox.box.storage && - maildir_compatible_file_modes(mbox, mail->box)) { + maildir_compatible_file_modes(&mbox->ibox.box, mail->box)) { t_push(); ret = maildir_copy_hardlink(t, mail, flags, keywords, dest_mail);
--- a/src/lib-storage/index/maildir/maildir-keywords.c Sun Oct 21 17:41:30 2007 +0300 +++ b/src/lib-storage/index/maildir/maildir-keywords.c Sun Oct 21 17:41:47 2007 +0300 @@ -306,9 +306,9 @@ return -1; } - if (st.st_gid != mbox->mail_create_gid && - mbox->mail_create_gid != (gid_t)-1) { - if (fchown(fd, (uid_t)-1, mbox->mail_create_gid) < 0) { + if (st.st_gid != mbox->ibox.box.file_create_gid && + mbox->ibox.box.file_create_gid != (gid_t)-1) { + if (fchown(fd, (uid_t)-1, mbox->ibox.box.file_create_gid) < 0) { mail_storage_set_critical(mk->storage, "fchown(%s) failed: %m", path); } @@ -354,7 +354,7 @@ malicious symlinks */ lock_path = t_strconcat(mk->path, ".lock", NULL); (void)unlink(lock_path); - old_mask = umask(0777 & ~mk->mbox->mail_create_mode); + old_mask = umask(0777 & ~mk->mbox->ibox.box.file_create_mode); fd = file_dotlock_open(&mk->dotlock_settings, mk->path, DOTLOCK_CREATE_FLAG_NONBLOCK, &dotlock); umask(old_mask);
--- a/src/lib-storage/index/maildir/maildir-save.c Sun Oct 21 17:41:30 2007 +0300 +++ b/src/lib-storage/index/maildir/maildir-save.c Sun Oct 21 17:41:47 2007 +0300 @@ -288,6 +288,7 @@ static int maildir_create_tmp(struct maildir_mailbox *mbox, const char *dir, const char **fname_r) { + struct mailbox *box = &mbox->ibox.box; struct stat st; unsigned int prefix_len; const char *tmp_fname = NULL; @@ -310,12 +311,12 @@ if (stat(str_c(path), &st) == 0) { /* try another file name */ } else if (errno != ENOENT) { - mail_storage_set_critical(&mbox->storage->storage, + mail_storage_set_critical(box->storage, "stat(%s) failed: %m", str_c(path)); return -1; } else { /* doesn't exist */ - mode_t old_mask = umask(0777 & ~mbox->mail_create_mode); + mode_t old_mask = umask(0777 & ~box->file_create_mode); fd = open(str_c(path), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0777); umask(old_mask); @@ -330,15 +331,15 @@ *fname_r = tmp_fname; if (fd == -1) { if (ENOSPACE(errno)) { - mail_storage_set_error(&mbox->storage->storage, + mail_storage_set_error(box->storage, MAIL_ERROR_NOSPACE, MAIL_ERRSTR_NO_SPACE); } else { - mail_storage_set_critical(&mbox->storage->storage, + mail_storage_set_critical(box->storage, "open(%s) failed: %m", str_c(path)); } - } else if (mbox->mail_create_gid != (gid_t)-1) { - if (fchown(fd, (uid_t)-1, mbox->mail_create_gid) < 0) { - mail_storage_set_critical(&mbox->storage->storage, + } else if (box->file_create_gid != (gid_t)-1) { + if (fchown(fd, (uid_t)-1, box->file_create_gid) < 0) { + mail_storage_set_critical(box->storage, "fchown(%s) failed: %m", str_c(path)); } }
--- a/src/lib-storage/index/maildir/maildir-storage.c Sun Oct 21 17:41:30 2007 +0300 +++ b/src/lib-storage/index/maildir/maildir-storage.c Sun Oct 21 17:41:47 2007 +0300 @@ -428,12 +428,9 @@ mail_index_ext_register(index, "maildir", sizeof(mbox->maildir_hdr), 0, 0); - if (!shared) { - mbox->mail_create_mode = 0600; - mbox->mail_create_gid = (gid_t)-1; - } else { - mbox->mail_create_mode = st.st_mode & 0666; - mbox->mail_create_gid = st.st_gid; + if (shared) { + mbox->ibox.box.file_create_mode = st.st_mode & 0666; + mbox->ibox.box.file_create_gid = st.st_gid; mbox->ibox.box.private_flags_mask = MAIL_SEEN; }
--- a/src/lib-storage/index/maildir/maildir-storage.h Sun Oct 21 17:41:30 2007 +0300 +++ b/src/lib-storage/index/maildir/maildir-storage.h Sun Oct 21 17:41:47 2007 +0300 @@ -86,9 +86,6 @@ struct maildir_index_header maildir_hdr; uint32_t maildir_ext_id; - mode_t mail_create_mode; - gid_t mail_create_gid; - unsigned int syncing_commit:1; };
--- a/src/lib-storage/index/maildir/maildir-uidlist.c Sun Oct 21 17:41:30 2007 +0300 +++ b/src/lib-storage/index/maildir/maildir-uidlist.c Sun Oct 21 17:41:47 2007 +0300 @@ -134,7 +134,7 @@ } path = t_strconcat(mbox->control_dir, "/" MAILDIR_UIDLIST_NAME, NULL); - old_mask = umask(0777 & ~mbox->mail_create_mode); + old_mask = umask(0777 & ~mbox->ibox.box.file_create_mode); ret = file_dotlock_create(&uidlist->dotlock_settings, path, nonblock ? DOTLOCK_CREATE_FLAG_NONBLOCK : 0, &uidlist->dotlock); @@ -885,7 +885,7 @@ temp_path = t_strconcat(mbox->control_dir, "/" MAILDIR_UIDLIST_NAME ".tmp", NULL); - old_mask = umask(0777 & ~mbox->mail_create_mode); + old_mask = umask(0777 & ~mbox->ibox.box.file_create_mode); fd = open(temp_path, O_RDWR | O_CREAT | O_TRUNC, 0777); umask(old_mask); @@ -895,8 +895,8 @@ return -1; } - if (mbox->mail_create_gid != (gid_t)-1) { - if (fchown(fd, (uid_t)-1, mbox->mail_create_gid) < 0) { + if (mbox->ibox.box.file_create_gid != (gid_t)-1) { + if (fchown(fd, (uid_t)-1, mbox->ibox.box.file_create_gid) < 0) { mail_storage_set_critical(&mbox->storage->storage, "fchown(%s) failed: %m", temp_path); }
--- a/src/lib-storage/mail-storage-private.h Sun Oct 21 17:41:30 2007 +0300 +++ b/src/lib-storage/mail-storage-private.h Sun Oct 21 17:41:47 2007 +0300 @@ -181,6 +181,10 @@ /* User's private flags if this is a shared mailbox */ enum mail_flags private_flags_mask; + /* mode and GID to use for newly created files */ + mode_t file_create_mode; + gid_t file_create_gid; + /* Mailbox notification settings: */ unsigned int notify_min_interval; mailbox_notify_callback_t *notify_callback;