[dovecot-cvs] dovecot/src/master auth-process.c,1.7,1.8
cras at procontrol.fi
cras at procontrol.fi
Tue Nov 26 15:50:32 EET 2002
Update of /home/cvs/dovecot/src/master
In directory danu:/home/cras/dovecot/src/master
Modified Files:
auth-process.c
Log Message:
Close old fds before dup2()ing to fd 3, so we don't close it accidentally.
Index: auth-process.c
===================================================================
RCS file: /home/cvs/dovecot/src/master/auth-process.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- auth-process.c 25 Nov 2002 13:19:55 -0000 1.7
+++ auth-process.c 26 Nov 2002 13:50:30 -0000 1.8
@@ -196,6 +196,9 @@
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);
@@ -211,9 +214,15 @@
if (dup2(fd[1], 0) < 0)
i_fatal("login: dup2() failed: %m");
+ (void)close(fd[0]);
+ (void)close(fd[1]);
+
/* move login communication handle to 3 */
- if (dup2(listen_fd, 3) < 0)
- i_fatal("login: dup2() failed: %m");
+ 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 */
@@ -222,12 +231,6 @@
if (dup2(null_fd, 2) < 0)
i_fatal("login: dup2() failed: %m");
- (void)close(listen_fd);
-
- (void)close(fd[0]);
- (void)close(fd[1]);
-
- clean_child_process();
/* setup access environment - needs to be done after
clean_child_process() since it clears environment */
More information about the dovecot-cvs
mailing list