comparison src/master/login-process.c @ 8881:774b0e8138bd HEAD

Call closelog() before dup2()ing fds.
author Timo Sirainen <tss@iki.fi>
date Wed, 01 Apr 2009 12:48:17 -0400
parents 1c76e82e0b36
children 933d95978040
comparison
equal deleted inserted replaced
8880:709128511fd5 8881:774b0e8138bd
705 &ssl_listen_count); 705 &ssl_listen_count);
706 for (i = 0; i < ssl_listen_count; i++, cur_fd++) 706 for (i = 0; i < ssl_listen_count; i++, cur_fd++)
707 dup2_append(&dups, listens[i].fd, cur_fd); 707 dup2_append(&dups, listens[i].fd, cur_fd);
708 } 708 }
709 709
710 /* make sure we don't leak syslog fd. try to do it as late as possible,
711 but also before dup2()s in case syslog fd is one of them. */
712 closelog();
713
710 if (dup2_array(&dups) < 0) 714 if (dup2_array(&dups) < 0)
711 i_fatal("Failed to dup2() fds"); 715 i_fatal("Failed to dup2() fds");
712 716
713 /* don't close any of these */ 717 /* don't close any of these */
714 for (tmp_fd = 0; tmp_fd < cur_fd; tmp_fd++) 718 for (tmp_fd = 0; tmp_fd < cur_fd; tmp_fd++)
721 725
722 env_put(t_strdup_printf("LISTEN_FDS=%u", listen_count)); 726 env_put(t_strdup_printf("LISTEN_FDS=%u", listen_count));
723 env_put(t_strdup_printf("SSL_LISTEN_FDS=%u", ssl_listen_count)); 727 env_put(t_strdup_printf("SSL_LISTEN_FDS=%u", ssl_listen_count));
724 728
725 restrict_process_size(group->set->login_process_size, (unsigned int)-1); 729 restrict_process_size(group->set->login_process_size, (unsigned int)-1);
726
727 /* make sure we don't leak syslog fd, but do it last so that
728 any errors above will be logged */
729 closelog();
730 730
731 client_process_exec(group->set->login_executable, ""); 731 client_process_exec(group->set->login_executable, "");
732 i_fatal_status(FATAL_EXEC, "execv(%s) failed: %m", 732 i_fatal_status(FATAL_EXEC, "execv(%s) failed: %m",
733 group->set->login_executable); 733 group->set->login_executable);
734 return -1; 734 return -1;