commit 890883f12e8d8dd3309743eb95cf0b04f6e39ea0 Author: Aki Tuomi Date: Mon Mar 19 18:39:27 2018 +0200 dsync: Revert to /tmp if home does not exist Fixes doveadm: Error: Couldn't lock .dovecot-sync.lock: safe_mkstemp(.dovecot-sync.lock) failed: No such file or directory diff --git a/src/doveadm/dsync/dsync-brain.c b/src/doveadm/dsync/dsync-brain.c index c2b8169..1e84182 100644 --- a/src/doveadm/dsync/dsync-brain.c +++ b/src/doveadm/dsync/dsync-brain.c @@ -401,6 +401,7 @@ dsync_brain_lock(struct dsync_brain *brain, const char *remote_hostname) .lock_method = FILE_LOCK_METHOD_FCNTL, }; const char *home, *error, *local_hostname = my_hostdomain(); + struct stat st; bool created; int ret; @@ -437,8 +438,21 @@ dsync_brain_lock(struct dsync_brain *brain, const char *remote_hostname) if (brain->verbose_proctitle) process_title_set(dsync_brain_get_proctitle_full(brain, DSYNC_BRAIN_TITLE_LOCKING)); - brain->lock_path = p_strconcat(brain->pool, home, - "/"DSYNC_LOCK_FILENAME, NULL); + + /* if homedir does not yet exist, create lock under tmpdir */ + if (stat(home, &st) < 0) { + if (errno != ENOENT) { + i_error("stat(%s) failed: %m", home); + return -1; + } + brain->lock_path = p_strdup_printf(brain->pool, "%s/%s-%s", + brain->user->set->mail_temp_dir, + brain->user->username, + "/"DSYNC_LOCK_FILENAME); + } else { + brain->lock_path = p_strconcat(brain->pool, home, + "/"DSYNC_LOCK_FILENAME, NULL); + } brain->lock_fd = file_create_locked(brain->lock_path, &lock_set, &brain->lock, &created, &error); if (brain->lock_fd == -1)