]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dsync: If lock file can't be created because home is missing, mkdir the home
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 24 Apr 2018 15:50:38 +0000 (18:50 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Thu, 26 Apr 2018 14:37:09 +0000 (17:37 +0300)
src/doveadm/dsync/dsync-brain.c

index c2b8169f1a4cc9e796fbab49e39b06b67ea744a0..6bc013ff538438fdb518a0beaa84b4f89066aa8a 100644 (file)
@@ -441,6 +441,13 @@ dsync_brain_lock(struct dsync_brain *brain, const char *remote_hostname)
                                       "/"DSYNC_LOCK_FILENAME, NULL);
        brain->lock_fd = file_create_locked(brain->lock_path, &lock_set,
                                            &brain->lock, &created, &error);
+       if (brain->lock_fd == -1 && errno == ENOENT) {
+               /* home directory not created */
+               if (mail_user_home_mkdir(brain->user) < 0)
+                       return -1;
+               brain->lock_fd = file_create_locked(brain->lock_path, &lock_set,
+                       &brain->lock, &created, &error);
+       }
        if (brain->lock_fd == -1)
                i_error("Couldn't lock %s: %s", brain->lock_path, error);
        else if (brain->debug) {