Skip to content

Commit

Permalink
master: Don't unlink login sockets at startup if someone is listening…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
sirainen committed Nov 16, 2016
1 parent 253000d commit be7c7c4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/master/common.h
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/master/main.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/master/master-settings.c
Expand Up @@ -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? "
Expand Down

0 comments on commit be7c7c4

Please sign in to comment.