dovecot-2.1: maildir: If dovecot-uidlist can't be opened as read...
dovecot at dovecot.org
dovecot at dovecot.org
Mon May 14 19:01:56 EEST 2012
details: http://hg.dovecot.org/dovecot-2.1/rev/7f238016db81
changeset: 14525:7f238016db81
user: Timo Sirainen <tss at iki.fi>
date: Mon May 14 19:01:46 2012 +0300
description:
maildir: If dovecot-uidlist can't be opened as read-write, try opening as read-only.
diffstat:
src/lib-storage/index/maildir/maildir-uidlist.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diffs (57 lines):
diff -r 20d98b848f37 -r 7f238016db81 src/lib-storage/index/maildir/maildir-uidlist.c
--- a/src/lib-storage/index/maildir/maildir-uidlist.c Mon May 14 18:42:58 2012 +0300
+++ b/src/lib-storage/index/maildir/maildir-uidlist.c Mon May 14 19:01:46 2012 +0300
@@ -97,6 +97,7 @@
unsigned int locked_refresh:1;
unsigned int unsorted:1;
unsigned int have_mailbox_guid:1;
+ unsigned int opened_readonly:1;
};
struct maildir_uidlist_sync_ctx {
@@ -702,11 +703,16 @@
struct stat st;
uoff_t last_read_offset;
int fd, ret;
+ bool readonly = FALSE;
*retry_r = FALSE;
if (uidlist->fd == -1) {
fd = nfs_safe_open(uidlist->path, O_RDWR);
+ if (fd == -1 && errno == EACCES) {
+ fd = nfs_safe_open(uidlist->path, O_RDONLY);
+ readonly = TRUE;
+ }
if (fd == -1) {
if (errno != ENOENT) {
mail_storage_set_critical(storage,
@@ -807,6 +813,8 @@
(void)unlink(uidlist->path);
} else if (ret > 0) {
/* success */
+ if (readonly)
+ uidlist->recreate_on_change = TRUE;
uidlist->fd = fd;
uidlist->fd_dev = st.st_dev;
uidlist->fd_ino = st.st_ino;
@@ -917,6 +925,10 @@
}
uidlist->fd = nfs_safe_open(uidlist->path, O_RDWR);
+ if (uidlist->fd == -1 && errno == EACCES) {
+ uidlist->fd = nfs_safe_open(uidlist->path, O_RDONLY);
+ uidlist->recreate_on_change = TRUE;
+ }
if (uidlist->fd == -1 && errno != ENOENT) {
mail_storage_set_critical(uidlist->box->storage,
"open(%s) failed: %m", uidlist->path);
@@ -1510,6 +1522,8 @@
i_assert(uidlist->initial_hdr_read);
if (maildir_uidlist_open_latest(uidlist) < 0)
return -1;
+ if (uidlist->recreate_on_change)
+ return maildir_uidlist_recreate(uidlist);
}
i_assert(ctx->first_unwritten_pos != (unsigned int)-1);
More information about the dovecot-cvs
mailing list