changeset 5824:5d0aa827f130 HEAD

Reordered initialization code. Capabilities are now dropped as soon as possible.
author root@hurina
date Thu, 28 Jun 2007 02:13:07 +0300
parents c1b32cd98e68
children 6303dc5e3997
files src/master/main.c
diffstat 1 files changed, 5 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/master/main.c	Thu Jun 28 02:12:19 2007 +0300
+++ b/src/master/main.c	Thu Jun 28 02:13:07 2007 +0300
@@ -571,30 +571,25 @@
 
 static void main_init(bool log_error)
 {
+	drop_capabilities();
+
 	/* deny file access from everyone else except owner */
         (void)umask(0077);
 
-	/* close stderr unless we're logging into /dev/stderr. keep as little
-	   distance between closing it and opening the actual log file so that
-	   we don't lose anything. */
+	set_logfile(settings_root->defaults);
+	/* close stderr unless we're logging into /dev/stderr. */
 	if (!have_stderr(settings_root)) {
 		if (dup2(null_fd, 2) < 0)
 			i_fatal("dup2(2) failed: %m");
 	}
-
-	set_logfile(settings_root->defaults);
 	i_info("Dovecot v"VERSION" starting up");
 
-	log_init();
-
 	if (log_error) {
 		i_warning("This is Dovecot's warning log");
 		i_error("This is Dovecot's error log");
 		i_fatal("This is Dovecot's fatal log");
 	}
 
-	drop_capabilities();
-
 	lib_signals_init();
         lib_signals_set_handler(SIGINT, TRUE, sig_die, NULL);
         lib_signals_set_handler(SIGTERM, TRUE, sig_die, NULL);
@@ -606,6 +601,7 @@
 	pids = hash_create(default_pool, default_pool, 128, NULL, NULL);
 	lib_signals_set_handler(SIGCHLD, TRUE, sigchld_handler, NULL);
 
+	log_init();
 	ssl_init();
 	dict_process_init();
 	auth_processes_init();