]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mbox: Ignore utime()=EPERM failures when trying to set atime back.
authorTimo Sirainen <tss@iki.fi>
Tue, 16 Nov 2010 18:47:48 +0000 (18:47 +0000)
committerTimo Sirainen <tss@iki.fi>
Tue, 16 Nov 2010 18:47:48 +0000 (18:47 +0000)
This happens with shared mboxes when file's owner isn't the process's euid.

src/lib-storage/index/mbox/mbox-save.c
src/lib-storage/index/mbox/mbox-sync.c

index b69f078a8264b0e578f33b5e613689f3c4014e15..df151697bb54f990a83b81388d798d455f14a827 100644 (file)
@@ -763,12 +763,14 @@ int mbox_transaction_save_commit_pre(struct mail_save_context *_ctx)
        }
 
        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()");
        }
 
index 88aff6c602f53b2ccf08ddc38b353270e01eb389..d2c2287f2a03f8b7810e392a8c0c859397971423 100644 (file)
@@ -1904,7 +1904,9 @@ again:
 
        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 @@ again:
                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()");
                }
        }