]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
/dev/stderr works now in log paths.
authorTimo Sirainen <tss@iki.fi>
Sat, 8 Feb 2003 15:42:46 +0000 (17:42 +0200)
committerTimo Sirainen <tss@iki.fi>
Sat, 8 Feb 2003 15:42:46 +0000 (17:42 +0200)
--HG--
branch : HEAD

dovecot-example.conf
src/login-common/main.c
src/master/auth-process.c
src/master/mail-process.c
src/master/main.c
src/master/master-login-interface.h

index 8fd32994fc60a26420b7b424c188beeca8b9cda2..0d3dc06b491b2d5753ecd82102ec3e9a590c67ee 100644 (file)
@@ -49,7 +49,8 @@
 # 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
index 903a0ba5d76efed355cc4fde6cd814945341119a..99ba52e8bd7de89e0e0df0cd66e9c2953d3d6286 100644 (file)
@@ -212,7 +212,7 @@ int main(int argc __attr_unused__, char *argv[], char *envp[])
        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 */
index e7cc8215f2e5a4356fe3e8ace0aa896b91235782..01c20f3c9dbbdfb4118772cd392152b4198e2064 100644 (file)
@@ -293,12 +293,10 @@ static pid_t create_auth_process(struct auth_settings *auth_set)
        (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();
 
index 2ac2d7f4ca0e74ef66a7c1d90c468933205fe5ab..21dc7b42693b8e263e70a092613b16260102155d 100644 (file)
@@ -140,8 +140,6 @@ int create_mail_process(int socket, struct ip_addr *ip,
                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");
index 10e8195a227531c867876f5a6e7e2eba3c7fdad4..603206811477431b1c5aea95e5fe31c1cf90621e 100644 (file)
@@ -281,6 +281,21 @@ static void open_fds(void)
                        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)
index 50477181aac7a3a934984944591fd57fec0d5ef6..5e3ede24dcfc12593984cd9aa281feb46deddee0 100644 (file)
@@ -5,7 +5,7 @@
 
 #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;