]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dbox: Fix creating dbox-alt-root symlink when mail root directory doesn't exist
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 13 Dec 2017 18:55:59 +0000 (20:55 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 14 Dec 2017 00:17:02 +0000 (02:17 +0200)
Broken by 74664ac6dcf88cfc2ae6378c87c20ba694385a23

src/lib-storage/index/dbox-common/dbox-storage.c

index 05f3f9524653554c451711254218601980f84a0f..b3ec85297960bf4881191d63dfc18f4e4a4690e2 100644 (file)
@@ -79,8 +79,15 @@ static void dbox_verify_alt_path(struct mailbox_list *list)
        /* unlink/create the current alt path symlink */
        i_unlink_if_exists(alt_symlink_path);
        if (alt_path != NULL) {
-               if (symlink(alt_path, alt_symlink_path) < 0 &&
-                   errno != EEXIST) {
+               int ret = symlink(alt_path, alt_symlink_path);
+               if (ret < 0 && errno == ENOENT) {
+                       /* root_dir doesn't exist yet - create it */
+                       if (mailbox_list_mkdir_root(list, root_dir,
+                                       MAILBOX_LIST_PATH_TYPE_DIR) < 0)
+                               return;
+                       ret = symlink(alt_path, alt_symlink_path);
+               }
+               if (ret < 0 && errno != EEXIST) {
                        i_error("symlink(%s, %s) failed: %m",
                                alt_path, alt_symlink_path);
                }