[dovecot-cvs] dovecot/src/master auth-process.c,1.8,1.9

cras at procontrol.fi cras at procontrol.fi
Tue Nov 26 15:58:28 EET 2002


Update of /home/cvs/dovecot/src/master
In directory danu:/tmp/cvs-serv11627

Modified Files:
	auth-process.c 
Log Message:
Still not correct order with dup2()ing.



Index: auth-process.c
===================================================================
RCS file: /home/cvs/dovecot/src/master/auth-process.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- auth-process.c	26 Nov 2002 13:50:30 -0000	1.8
+++ auth-process.c	26 Nov 2002 13:58:26 -0000	1.9
@@ -196,9 +196,6 @@
 		return pid;
 	}
 
-	/* close unwanted fds before we start dup2()ing them */
-	clean_child_process();
-
 	/* create socket for listening auth requests from imap-login */
 	path = t_strconcat(set_login_dir, "/", config->name, NULL);
 	(void)unlink(path);
@@ -217,13 +214,6 @@
 	(void)close(fd[0]);
 	(void)close(fd[1]);
 
-	/* move login communication handle to 3 */
-	if (listen_fd != 3) {
-		if (dup2(listen_fd, 3) < 0)
-			i_fatal("login: dup2() failed: %m");
-		(void)close(listen_fd);
-	}
-
 	/* 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 */
 	if (dup2(null_fd, 1) < 0)
@@ -231,6 +221,15 @@
 	if (dup2(null_fd, 2) < 0)
 		i_fatal("login: dup2() failed: %m");
 
+	clean_child_process();
+
+	/* move login communication handle to 3. do it last so we can be
+	   sure it's not closed afterwards. */
+	if (listen_fd != 3) {
+		if (dup2(listen_fd, 3) < 0)
+			i_fatal("login: dup2() failed: %m");
+		(void)close(listen_fd);
+	}
 
 	/* setup access environment - needs to be done after
 	   clean_child_process() since it clears environment */




More information about the dovecot-cvs mailing list