]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Fail at startup if root mail directory isn't a directory
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 26 Jun 2017 16:19:44 +0000 (19:19 +0300)
committerGitLab <gitlab@git.dovecot.net>
Wed, 28 Jun 2017 18:58:15 +0000 (21:58 +0300)
src/lib-storage/mail-storage.c

index df89b209f483b316b6e8710482603865eb93f448..b53771875ba0ff9740c423b04c1cac46a420cf1f 100644 (file)
@@ -231,11 +231,15 @@ mail_storage_verify_root(const char *root_dir, bool autocreate,
 
        if (stat(root_dir, &st) == 0) {
                /* exists */
-               return 1;
+               if (S_ISDIR(st.st_mode))
+                       return 1;
+               *error_r = t_strdup_printf(
+                       "Root mail directory is a file: %s", root_dir);
+               return -1;
        } else if (errno == EACCES) {
                *error_r = mail_error_eacces_msg("stat", root_dir);
                return -1;
-       } else if (errno != ENOENT && errno != ENOTDIR) {
+       } else if (errno != ENOENT) {
                *error_r = t_strdup_printf("stat(%s) failed: %m", root_dir);
                return -1;
        } else if (!autocreate) {