From: Timo Sirainen Date: Wed, 16 Jun 2004 06:09:31 +0000 (+0300) Subject: EXAMINE/STATUS should also update metadata changes, they don't really open X-Git-Tag: 1.1.alpha1~3957 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f190f4cbb9233a3a6830956cb5c7ae56a577b79;p=thirdparty%2Fdovecot%2Fcore.git EXAMINE/STATUS should also update metadata changes, they don't really open the mbox as readonly. --HG-- branch : HEAD --- diff --git a/src/lib-storage/index/index-storage.h b/src/lib-storage/index/index-storage.h index a3d893f124..bedde75c70 100644 --- a/src/lib-storage/index/index-storage.h +++ b/src/lib-storage/index/index-storage.h @@ -87,6 +87,7 @@ struct index_mailbox { unsigned int mbox_locks; struct dotlock mbox_dotlock; unsigned int mbox_lock_id, mbox_mail_lock_id; + int mbox_readonly; uint32_t mbox_extra_idx; diff --git a/src/lib-storage/index/mbox/mbox-file.c b/src/lib-storage/index/mbox/mbox-file.c index 24e1c08a1d..f4c5a263d3 100644 --- a/src/lib-storage/index/mbox/mbox-file.c +++ b/src/lib-storage/index/mbox/mbox-file.c @@ -15,7 +15,12 @@ int mbox_file_open(struct index_mailbox *ibox) i_assert(ibox->mbox_fd == -1); - fd = open(ibox->path, ibox->readonly ? O_RDONLY : O_RDWR); + fd = open(ibox->path, ibox->mbox_readonly ? O_RDONLY : O_RDWR); + if (fd == -1 && errno == EACCES && !ibox->mbox_readonly) { + ibox->mbox_readonly = TRUE; + fd = open(ibox->path, O_RDONLY); + } + if (fd == -1) { mbox_set_syscall_error(ibox, "open()"); return -1; diff --git a/src/lib-storage/index/mbox/mbox-sync.c b/src/lib-storage/index/mbox/mbox-sync.c index adf2db320d..ea87d725e5 100644 --- a/src/lib-storage/index/mbox/mbox-sync.c +++ b/src/lib-storage/index/mbox/mbox-sync.c @@ -69,6 +69,8 @@ static int mbox_sync_lock(struct mbox_sync_context *sync_ctx, int lock_type) struct stat old_st, st; uoff_t old_from_offset = 0, old_offset = 0; + i_assert(lock_type != F_WRLCK || !ibox->mbox_readonly); + if (sync_ctx->lock_id != 0) { if (fstat(sync_ctx->fd, &old_st) < 0) { mbox_set_syscall_error(ibox, "stat()"); @@ -232,7 +234,7 @@ static int mbox_sync_read_index_syncs(struct mbox_sync_context *sync_ctx, *sync_expunge_r = FALSE; - if (sync_ctx->ibox->readonly || sync_ctx->index_sync_ctx == NULL) + if (sync_ctx->ibox->mbox_readonly || sync_ctx->index_sync_ctx == NULL) return 0; mbox_sync_buffer_delete_old(sync_ctx->syncs, uid); @@ -506,7 +508,7 @@ static int mbox_sync_handle_header(struct mbox_sync_mail_context *mail_ctx) if (sync_ctx->first_uid == 0) sync_ctx->first_uid = mail_ctx->mail.uid; - if (sync_ctx->ibox->readonly) + if (sync_ctx->ibox->mbox_readonly) return 0; if (sync_ctx->expunged_space > 0 && sync_ctx->need_space_seq == 0) { @@ -1055,7 +1057,8 @@ int mbox_sync(struct index_mailbox *ibox, int last_commit, int lock) if (mail_index_sync_end(index_sync_ctx) < 0) ret = -1; - if (sync_ctx.base_uid_last != sync_ctx.next_uid-1 && ret == 0) { + if (sync_ctx.base_uid_last != sync_ctx.next_uid-1 && ret == 0 && + !ibox->mbox_readonly) { /* rewrite X-IMAPbase header. do it after mail_index_sync_end() so previous transactions have been committed. */ /* FIXME: ugly .. */