From 6a38ed970ff7a742c87f29a9f227690029d1eba3 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 24 Apr 2018 18:50:38 +0300 Subject: [PATCH] dsync: If lock file can't be created because home is missing, mkdir the home --- src/doveadm/dsync/dsync-brain.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/doveadm/dsync/dsync-brain.c b/src/doveadm/dsync/dsync-brain.c index ec75a0e75e..b2c2b33ae3 100644 --- a/src/doveadm/dsync/dsync-brain.c +++ b/src/doveadm/dsync/dsync-brain.c @@ -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) { -- 2.47.3