Mercurial > dovecot > original-hg > dovecot-1.2
comparison src/master/login-process.c @ 9465:19aee456cec3 HEAD
master: When creating login processes, don't close any fds after dup2()s.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 05 Nov 2009 12:25:43 -0500 |
parents | ab32d7e2c0d6 |
children | 00cd9aacd03c |
comparison
equal
deleted
inserted
replaced
9464:939edf3ed09b | 9465:19aee456cec3 |
---|---|
646 /* create communication to process with a socket pair */ | 646 /* create communication to process with a socket pair */ |
647 if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0) { | 647 if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0) { |
648 i_error("socketpair() failed: %m"); | 648 i_error("socketpair() failed: %m"); |
649 return -1; | 649 return -1; |
650 } | 650 } |
651 fd_close_on_exec(fd[0], TRUE); | |
652 fd_close_on_exec(fd[1], TRUE); | |
651 | 653 |
652 max_log_lines_per_sec = | 654 max_log_lines_per_sec = |
653 group->set->login_process_per_connection ? 10 : 0; | 655 group->set->login_process_per_connection ? 10 : 0; |
654 log_fd = log_create_pipe(&log, max_log_lines_per_sec); | 656 log_fd = log_create_pipe(&log, max_log_lines_per_sec); |
655 if (log_fd < 0) | 657 if (log_fd < 0) |
673 process_names[group->mail_process_type]); | 675 process_names[group->mail_process_type]); |
674 log_set_prefix(log, prefix); | 676 log_set_prefix(log, prefix); |
675 log_set_pid(log, pid); | 677 log_set_pid(log, pid); |
676 | 678 |
677 net_set_nonblock(fd[0], TRUE); | 679 net_set_nonblock(fd[0], TRUE); |
678 fd_close_on_exec(fd[0], TRUE); | |
679 (void)login_process_new(group, pid, fd[0], FALSE); | 680 (void)login_process_new(group, pid, fd[0], FALSE); |
680 (void)close(fd[1]); | 681 (void)close(fd[1]); |
681 (void)close(log_fd); | 682 (void)close(log_fd); |
682 return pid; | 683 return pid; |
683 } | 684 } |
713 but also before dup2()s in case syslog fd is one of them. */ | 714 but also before dup2()s in case syslog fd is one of them. */ |
714 closelog(); | 715 closelog(); |
715 | 716 |
716 if (dup2_array(&dups) < 0) | 717 if (dup2_array(&dups) < 0) |
717 i_fatal("Failed to dup2() fds"); | 718 i_fatal("Failed to dup2() fds"); |
719 /* NOTE: don't close any fds below here. dup2_array() may have already | |
720 assigned other fds to them. */ | |
718 | 721 |
719 /* don't close any of these */ | 722 /* don't close any of these */ |
720 for (tmp_fd = 0; tmp_fd < cur_fd; tmp_fd++) | 723 for (tmp_fd = 0; tmp_fd < cur_fd; tmp_fd++) |
721 fd_close_on_exec(tmp_fd, FALSE); | 724 fd_close_on_exec(tmp_fd, FALSE); |
722 | |
723 (void)close(fd[0]); | |
724 (void)close(fd[1]); | |
725 | 725 |
726 login_process_init_env(group, getpid()); | 726 login_process_init_env(group, getpid()); |
727 | 727 |
728 env_put(t_strdup_printf("LISTEN_FDS=%u", listen_count)); | 728 env_put(t_strdup_printf("LISTEN_FDS=%u", listen_count)); |
729 env_put(t_strdup_printf("SSL_LISTEN_FDS=%u", ssl_listen_count)); | 729 env_put(t_strdup_printf("SSL_LISTEN_FDS=%u", ssl_listen_count)); |