Mercurial > dovecot > original-hg > dovecot-1.2
changeset 5739:94161a726c8b HEAD
When trying to use mbox file as the root directory, give a nice error.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 14 Jun 2007 05:31:04 +0300 |
parents | 9f2e5701105f |
children | 05d06a1c0f0c |
files | src/lib-storage/index/mbox/mbox-storage.c |
diffstat | 1 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-storage.c Thu Jun 14 05:06:35 2007 +0300 +++ b/src/lib-storage/index/mbox/mbox-storage.c Thu Jun 14 05:31:04 2007 +0300 @@ -446,17 +446,25 @@ static int verify_inbox(struct mail_storage *storage) { - const char *inbox_path; + const char *inbox_path, *rootdir; int fd; inbox_path = mailbox_list_get_path(storage->list, "INBOX", MAILBOX_LIST_PATH_TYPE_MAILBOX); + rootdir = mailbox_list_get_path(storage->list, "", + MAILBOX_LIST_PATH_TYPE_DIR); /* make sure inbox file itself exists */ fd = open(inbox_path, O_RDWR | O_CREAT | O_EXCL, 0660); if (fd != -1) (void)close(fd); - else if (errno != EEXIST) { + else if (errno == ENOTDIR && + strncmp(inbox_path, rootdir, strlen(rootdir)) == 0) { + mail_storage_set_critical(storage, + "mbox root directory can't be a file: %s " + "(http://wiki.dovecot.org/MailLocation/Mbox)", + rootdir); + } else if (errno != EEXIST) { mail_storage_set_critical(storage, "open(%s, O_CREAT) failed: %m", inbox_path); }