dovecot-2.0: dbox: If file can't be opened read-write, fallback ...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Apr 28 21:31:21 EEST 2011
details: http://hg.dovecot.org/dovecot-2.0/rev/de7c0d84c560
changeset: 12758:de7c0d84c560
user: Timo Sirainen <tss at iki.fi>
date: Thu Apr 28 21:31:16 2011 +0300
description:
dbox: If file can't be opened read-write, fallback to read-only.
diffstat:
src/lib-storage/index/dbox-common/dbox-file.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diffs (21 lines):
diff -r 5429f41aa6c1 -r de7c0d84c560 src/lib-storage/index/dbox-common/dbox-file.c
--- a/src/lib-storage/index/dbox-common/dbox-file.c Thu Apr 28 21:30:21 2011 +0300
+++ b/src/lib-storage/index/dbox-common/dbox-file.c Thu Apr 28 21:31:16 2011 +0300
@@ -165,11 +165,16 @@
static int dbox_file_open_fd(struct dbox_file *file, bool try_altpath)
{
const char *path;
+ int flags = O_RDWR;
bool alt = FALSE;
/* try the primary path first */
path = file->primary_path;
- while ((file->fd = open(path, O_RDWR)) == -1) {
+ while ((file->fd = open(path, flags)) == -1) {
+ if (errno == EACCES && flags == O_RDWR) {
+ flags = O_RDONLY;
+ continue;
+ }
if (errno != ENOENT) {
mail_storage_set_critical(&file->storage->storage,
"open(%s) failed: %m", path);
More information about the dovecot-cvs
mailing list