# SSL/TLS is used (LOGINDISABLED capability)
#disable_plaintext_auth = no
-# Use this logfile instead of syslog()
+# Use this logfile instead of syslog(). /dev/stderr can be used if you want to
+# use stderr for logging (ONLY /dev/stderr - otherwise it is closed).
#log_path =
# For informational messages, use this logfile instead of the default
const char *name;
#ifdef DEBUG
- fd_debug_verify_leaks(3, 1024);
+ fd_debug_verify_leaks(4, 1024);
#endif
/* NOTE: we start rooted, so keep the code minimal until
restrict_access_by_env() is called */
(void)close(fd[0]);
(void)close(fd[1]);
- /* set /dev/null handle into 1 and 2, so if something is printed into
- stdout/stderr it can't go anywhere where it could cause harm */
+ /* set stdout to /dev/null, so anything written into it gets ignored.
+ leave stderr alone, we might want to use it for logging. */
if (dup2(null_fd, 1) < 0)
i_fatal("login: dup2(1) failed: %m");
- if (dup2(null_fd, 2) < 0)
- i_fatal("login: dup2(2) failed: %m");
clean_child_process();
i_fatal("mail: dup2(stdin) failed: %m");
if (dup2(socket, 1) < 0)
i_fatal("mail: dup2(stdout) failed: %m");
- if (dup2(null_fd, 2) < 0)
- i_fatal("mail: dup2(stderr) failed: %m");
if (close(socket) < 0)
i_error("mail: close(mail client) failed: %m");
fd_close_on_exec(mail_fd[i], TRUE);
}
}
+
+ /* close stdin and stdout. close stderr unless we're logging
+ into /dev/stderr. */
+ if (dup2(null_fd, 0) < 0)
+ i_fatal("dup2(0) failed: %m");
+ if (dup2(null_fd, 1) < 0)
+ i_fatal("dup2(1) failed: %m");
+
+ if ((set->log_path == NULL ||
+ strcmp(set->log_path, "/dev/stderr") != 0) &&
+ (set->info_log_path == NULL ||
+ strcmp(set->info_log_path, "/dev/stderr") != 0)) {
+ if (dup2(null_fd, 2) < 0)
+ i_fatal("dup(0) failed: %m");
+ }
}
static void open_logfile(void)
#define LOGIN_MASTER_SOCKET_FD 0
#define LOGIN_LISTEN_FD 1
-#define LOGIN_SSL_LISTEN_FD 2
+#define LOGIN_SSL_LISTEN_FD 3
struct master_login_request {
unsigned int tag;