Mercurial > dovecot > core-2.2
changeset 12427:3daec8435d29
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.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 16 Nov 2010 18:47:48 +0000 |
parents | 3aced5ececd7 |
children | 586d549732f5 |
files | src/lib-storage/index/mbox/mbox-save.c src/lib-storage/index/mbox/mbox-sync.c |
diffstat | 2 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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()"); }
--- 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()"); } }