Mercurial > dovecot > core-2.2
diff src/lib-storage/index/dbox-common/dbox-file.c @ 12965:de7c0d84c560
dbox: If file can't be opened read-write, fallback to read-only.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 28 Apr 2011 21:31:16 +0300 |
parents | edf79127fccd |
children | 80eef14e9e15 |
line wrap: on
line diff
--- 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);