dovecot-2.0: mbox: Check at storage init that root dir isn't a f...

dovecot at dovecot.org dovecot at dovecot.org
Mon Apr 5 02:15:23 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/f8d9bf024e0f
changeset: 11050:f8d9bf024e0f
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Apr 05 02:15:20 2010 +0300
description:
mbox: Check at storage init that root dir isn't a file.
Delaying this check will just cause all kinds of errors later on.

diffstat:

 src/lib-storage/index/mbox/mbox-storage.c |  15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diffs (39 lines):

diff -r ea5bb5676b3f -r f8d9bf024e0f src/lib-storage/index/mbox/mbox-storage.c
--- a/src/lib-storage/index/mbox/mbox-storage.c	Mon Apr 05 01:54:28 2010 +0300
+++ b/src/lib-storage/index/mbox/mbox-storage.c	Mon Apr 05 02:15:20 2010 +0300
@@ -122,6 +122,7 @@
 		    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 @@
 		_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 @@
 	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));


More information about the dovecot-cvs mailing list