]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
master: Don't unlink login sockets at startup if someone is listening to them.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 16 Nov 2016 09:35:42 +0000 (11:35 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 16 Nov 2016 10:24:44 +0000 (12:24 +0200)
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.

src/master/common.h
src/master/main.c
src/master/master-settings.c

index aab7cde5227fae402f04055d322c7c9386aab3b1..c17e36f8696032be0e92e66715e9d8b446fbb6f7 100644 (file)
@@ -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);
index 9e54896aedd55b830882e971b52007f7cde3705c..5cf1ac40817c8278d5473c242bf24a78142d18f0 100644 (file)
@@ -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)
index 216eb07be5e112b741d976f4ad0cf5301ea398ce..88e498df78faae5057f9657c3cfa8a4f2025694d 100644 (file)
@@ -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? "