dovecot-2.0: mbox: Ignore utime()=EPERM failures when trying to ...

dovecot at dovecot.org dovecot at dovecot.org
Tue Nov 16 20:47:52 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/3daec8435d29
changeset: 12427:3daec8435d29
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Nov 16 18:47:48 2010 +0000
description:
mbox: Ignore utime()=EPERM failures when trying to set atime back.
This happens with shared mboxes when file's owner isn't the process's euid.

diffstat:

 src/lib-storage/index/mbox/mbox-save.c |  6 ++++--
 src/lib-storage/index/mbox/mbox-sync.c |  6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diffs (43 lines):

diff -r 3aced5ececd7 -r 3daec8435d29 src/lib-storage/index/mbox/mbox-save.c
--- a/src/lib-storage/index/mbox/mbox-save.c	Mon Nov 15 17:40:12 2010 +0000
+++ b/src/lib-storage/index/mbox/mbox-save.c	Tue Nov 16 18:47:48 2010 +0000
@@ -763,12 +763,14 @@
 	}
 
 	if (ret == 0 && ctx->orig_atime != st.st_atime) {
-		/* try to set atime back to its original value */
+		/* try to set atime back to its original value.
+		   (it'll fail with EPERM for shared mailboxes where we aren't
+		   the file's owner) */
 		struct utimbuf buf;
 
 		buf.modtime = st.st_mtime;
 		buf.actime = ctx->orig_atime;
-		if (utime(mbox->box.path, &buf) < 0)
+		if (utime(mbox->box.path, &buf) < 0 && errno != EPERM)
 			mbox_set_syscall_error(mbox, "utime()");
 	}
 
diff -r 3aced5ececd7 -r 3daec8435d29 src/lib-storage/index/mbox/mbox-sync.c
--- a/src/lib-storage/index/mbox/mbox-sync.c	Mon Nov 15 17:40:12 2010 +0000
+++ b/src/lib-storage/index/mbox/mbox-sync.c	Tue Nov 16 18:47:48 2010 +0000
@@ -1904,7 +1904,9 @@
 
 	if (ret == 0 && mbox->mbox_fd != -1 && sync_ctx.keep_recent &&
 	    !readonly) {
-		/* try to set atime back to its original value */
+		/* try to set atime back to its original value.
+		   (it'll fail with EPERM for shared mailboxes where we aren't
+		   the file's owner) */
 		struct utimbuf buf;
 		struct stat st;
 
@@ -1913,7 +1915,7 @@
 		else {
 			buf.modtime = st.st_mtime;
 			buf.actime = sync_ctx.orig_atime;
-			if (utime(mbox->box.path, &buf) < 0)
+			if (utime(mbox->box.path, &buf) < 0 && errno != EPERM)
 				mbox_set_syscall_error(mbox, "utime()");
 		}
 	}


More information about the dovecot-cvs mailing list