main.c revision 868572d42fb8c1e90ea5ab6a5cc5d98f16aec3b6
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr/* Copyright (C) 2002 Timo Sirainen */
cae3584efccc63f544c8748bd13d80e11bc79aefgza "unknown",
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr for (i = 0; i < max_len; i++) {
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr extern char **environ;
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr /* remove all environment, we don't need them */
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr /* set the failure log */
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr /* close fds for auth/login processes */
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.frstatic void children_check_timeout(void *context __attr_unused__,
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr /* get the type and remove from hash */
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr /* write errors to syslog */
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr process_type_name = process_names[process_type];
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr (int)pid, process_type_name, WTERMSIG(status));
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr if (pid == -1 && errno != EINTR && errno != ECHILD)
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr if (set_imap_listen == NULL || *set_imap_listen == '\0')
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr ret = net_gethostbyname(name, &ip, &ips_count);
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr i_fatal("Can't resolve address: %s", set_imap_listen);
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr i_fatal("No IPs for address: %s", set_imap_listen);
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.frstatic void open_fds(void)
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr if (imaps_ip == NULL && set_imaps_listen == NULL)
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr i_fatal("listen(%d) failed: %ms", set_imap_port);
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr imaps_fd = set_ssl_cert_file == NULL || set_ssl_key_file == NULL ||
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr i_fatal("listen(%d) failed: %m", set_imaps_port);
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr /* deny file access from everyone else except owner */
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr i_set_warning_handler(i_syslog_warning_handler);
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr /* log failures into specified log file */
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr i_set_failure_file(set_log_path, "imap-master");
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr i_set_failure_timestamp_format(set_log_timestamp);
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr pids = hash_create(default_pool, 128, NULL, NULL);
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr to_children = timeout_add(100, children_check_timeout, NULL);
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.frstatic void main_deinit(void)
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr i_warning("Killed with signal %d", lib_signal_kill);
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.frstatic void daemonize(void)
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr /* parse arguments */
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr const char *configfile = SYSCONFDIR "/" PACKAGE ".conf";
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr /* foreground */
cae3584efccc63f544c8748bd13d80e11bc79aefgza /* config file */
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr if (i == argc) i_fatal("Missing config file argument");
f8d0243a78c65ea3c46eb60fbeef799c3f6e9a5blxc@zitta.fr /* read and verify settings before forking */