From 50d26713f044e1051da64c2efcbbdb479a43ae4f Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Mon, 5 Apr 2010 02:15:20 +0300 Subject: [PATCH] mbox: Check at storage init that root dir isn't a file. Delaying this check will just cause all kinds of errors later on. --HG-- branch : HEAD --- src/lib-storage/index/mbox/mbox-storage.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/lib-storage/index/mbox/mbox-storage.c b/src/lib-storage/index/mbox/mbox-storage.c index 3b57e09eb4..61c1541ded 100644 --- a/src/lib-storage/index/mbox/mbox-storage.c +++ b/src/lib-storage/index/mbox/mbox-storage.c @@ -122,6 +122,7 @@ mbox_storage_create(struct mail_storage *_storage, struct mail_namespace *ns, const char **error_r) { struct mbox_storage *storage = (struct mbox_storage *)_storage; + struct stat st; const char *dir; if (master_service_get_client_limit(master_service) > 1) { @@ -138,6 +139,13 @@ mbox_storage_create(struct mail_storage *_storage, struct mail_namespace *ns, _storage->temp_path_prefix = p_strconcat(_storage->pool, dir, "/", mailbox_list_get_temp_prefix(ns->list), NULL); } + if (stat(ns->list->set.root_dir, &st) == 0 && !S_ISDIR(st.st_mode)) { + *error_r = t_strdup_printf( + "mbox root directory can't be a file: %s " + "(http://wiki.dovecot.org/MailLocation/Mbox)", + ns->list->set.root_dir); + return -1; + } return 0; } @@ -483,13 +491,6 @@ static int create_inbox(struct mailbox *box) if (fd != -1) { (void)close(fd); return 0; - } else if (errno == ENOTDIR && - strncmp(inbox_path, rootdir, strlen(rootdir)) == 0) { - mail_storage_set_critical(box->storage, - "mbox root directory can't be a file: %s " - "(http://wiki.dovecot.org/MailLocation/Mbox)", - rootdir); - return -1; } else if (errno == EACCES) { mail_storage_set_critical(box->storage, "%s", mail_error_create_eacces_msg("open", inbox_path)); -- 2.47.3