]> 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)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 26 Apr 2018 17:28:21 +0000 (20:28 +0300)
src/doveadm/dsync/dsync-brain.c

index ec75a0e75e1df9f0c722d9cf7215c3e6403ed06d..b2c2b33ae3903d128688c506bc44fc5de05cfa24 100644 (file)
@@ -442,6 +442,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) {