From: Timo Sirainen Date: Wed, 16 Nov 2016 09:35:42 +0000 (+0200) Subject: master: Don't unlink login sockets at startup if someone is listening to them. X-Git-Tag: 2.2.27~153 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f3fc24f545443366fca0cbeb2ece6ea7f760a93f;p=thirdparty%2Fdovecot%2Fcore.git master: Don't unlink login sockets at startup if someone is listening to them. The original check there never worked, because null_fd was always set. Normally the master.pid file would prevent this happening, but if it didn't exist, the sockets would be unlinked and usually also created back. --- diff --git a/src/master/common.h b/src/master/common.h index aab7cde522..c17e36f869 100644 --- a/src/master/common.h +++ b/src/master/common.h @@ -11,6 +11,7 @@ extern bool core_dumps_disabled; extern const char *ssl_manual_key_password; extern int null_fd, global_master_dead_pipe_fd[2]; extern struct service_list *services; +extern bool startup_finished; void process_exec(const char *cmd, const char *extra_args[]) ATTR_NORETURN ATTR_NULL(2); diff --git a/src/master/main.c b/src/master/main.c index 9e54896aed..5cf1ac4081 100644 --- a/src/master/main.c +++ b/src/master/main.c @@ -45,6 +45,7 @@ bool core_dumps_disabled; const char *ssl_manual_key_password; int null_fd, global_master_dead_pipe_fd[2]; struct service_list *services; +bool startup_finished = FALSE; static char *pidfile_path; static struct master_instance_list *instances; @@ -530,6 +531,7 @@ static void main_init(const struct master_settings *set) master_clients_init(); services_monitor_start(services); + startup_finished = TRUE; } static void global_dead_pipe_close(void) diff --git a/src/master/master-settings.c b/src/master/master-settings.c index 216eb07be5..88e498df78 100644 --- a/src/master/master-settings.c +++ b/src/master/master-settings.c @@ -721,8 +721,8 @@ static void unlink_sockets(const char *path, const char *prefix) listening in them. do this only at startup, because when SIGHUPing a child process might catch the new connection before it notices that it's supposed - to die. null_fd == -1 check is a bit kludgy, but works.. */ - if (null_fd == -1) { + to die. */ + if (!startup_finished) { int fd = net_connect_unix(str_c(str)); if (fd != -1 || errno != ECONNREFUSED) { i_fatal("Dovecot is already running? "