service-process.c revision 02c335c23bf5fa225a467c19f2c063fb0dc7b8c3
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen/* Copyright (c) 2005-2016 Dovecot authors, see the included COPYING file */
73bfdbe28c2ce6d143eadf0bab8ccfbe4cab0faeTimo Sirainenstatic void service_reopen_inet_listeners(struct service *service)
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen unsigned int i, count;
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen listeners = array_get(&service->listeners, &count);
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen for (i = 0; i < count; i++) {
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen if (!listeners[i]->reuse_port || listeners[i]->fd == -1)
18ddd4fba186b1b407cae98bb388fa8add7db48dTimo Sirainen if (service_listener_listen(listeners[i]) < 0)
8eea67470c1bd8562a62e7445d930bb2079b1a43Timo Sirainen /* stdin/stdout is already redirected to /dev/null. Other master fds
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen should have been opened with fd_close_on_exec() so we don't have to
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen worry about them.
8eea67470c1bd8562a62e7445d930bb2079b1a43Timo Sirainen because the destination fd might be another one's source fd we have
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen to be careful not to overwrite anything. dup() the fd when needed */
8eea67470c1bd8562a62e7445d930bb2079b1a43Timo Sirainen listeners = array_get(&service->listeners, &count);
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen dup2_append(&dups, service_anvil_global->log_fdpass_fd[0],
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen /* nonblocking anvil fd must be the first one. anvil treats it
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen as the master's fd */
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen dup2_append(&dups, service_anvil_global->nonblocking_fd[0], fd++);
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen dup2_append(&dups, service_anvil_global->blocking_fd[0], fd++);
for (i = 0; i < count; i++) {
case SERVICE_TYPE_LOG:
case SERVICE_TYPE_ANVIL:
case SERVICE_TYPE_CONFIG:
case SERVICE_TYPE_UNKNOWN:
case SERVICE_TYPE_LOGIN:
case SERVICE_TYPE_STARTUP:
closelog();
bool disallow_root;
unsigned int len;
case SERVICE_TYPE_CONFIG:
case SERVICE_TYPE_LOG:
const char *hostdomain)
static unsigned int uid_counter = 0;
const char *hostdomain;
bool process_forked;
return NULL;
return NULL;
if (pid < 0) {
return NULL;
if (pid == 0) {
if (process_forked) {
return process;
switch (status) {
case FATAL_LOGOPEN:
case FATAL_LOGWRITE:
case FATAL_LOGERROR:
case FATAL_OUTOFMEM:
case FATAL_EXEC:
case FATAL_DEFAULT:
return NULL;
#ifdef WCOREDUMP
if (core_dumps_disabled) {
#ifndef HAVE_PR_SET_DUMPABLE
const char *msg;
if (status == 0) {
const char *data;
int status)
T_BEGIN {
bool default_fatal;
} T_END;