main.c revision cef2be5fb553b05f421f86c1ef497f0dc29d069e
45312f52ff3a3d4c137447be4c7556500c2f8bf2Timo Sirainen/* Copyright (c) 2002-2009 Dovecot authors, see the included COPYING file */
8f1d14e3ada93a6d6ee64f73c6e6ae2364d8eba1Timo Sirainenvoid (*hook_client_created)(struct client **client) = NULL;
43d32cbe60fdaef2699d99f1ca259053e9350411Timo Sirainenstatic void log_error_callback(void *context ATTR_UNUSED)
2421fd34d51fed6da985c62b5e078d7e96640653Timo Sirainen /* the log fd is closed, don't die when trying to log later */
1b04762685272a53643ac2179939537a44c7c044Timo Sirainenstatic bool main_init(const struct pop3_settings *set, struct mail_user *user)
1b04762685272a53643ac2179939537a44c7c044Timo Sirainen const char *str;
f9ef36afc131626754716d6f4874a2ad04da0ac4Timo Sirainen /* If master dies, the log fd gets closed and we'll quit */
cd94aeaa294f7cc507206b4b2075852f00e14d61Timo Sirainen if (!i_stream_add_data(client->input, buf->data,
cd94aeaa294f7cc507206b4b2075852f00e14d61Timo Sirainen i_panic("Couldn't add client input to stream");
548f87789cf9865572b7b86f7be5a9bbfa132f3fTimo Sirainenstatic void main_deinit(void)
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainenstatic void client_connected(const struct master_service_connection *conn)
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen /* we can't handle this yet */
812883e7758a86f615b9508ef10df1339123da83Timo Sirainen const struct setting_parser_info *set_roots[] = {
1b04762685272a53643ac2179939537a44c7c044Timo Sirainen enum mail_storage_service_flags storage_service_flags =
4dbe08e1f7f1271299ada9338ff5015367efd0b7Timo Sirainen printf("-ERR pop3 binary must not be started from "
4dbe08e1f7f1271299ada9338ff5015367efd0b7Timo Sirainen "inetd, use pop3-login instead.\n");
1b04762685272a53643ac2179939537a44c7c044Timo Sirainen service_flags |= MASTER_SERVICE_FLAG_STANDALONE;
1b04762685272a53643ac2179939537a44c7c044Timo Sirainen service_flags |= MAIL_STORAGE_SERVICE_FLAG_DISALLOW_ROOT;
4d4d6d4745682790c20d759ba93dbea46b812c5dTimo Sirainen master_service = master_service_init("pop3", service_flags, argc, argv);
1b04762685272a53643ac2179939537a44c7c044Timo Sirainen while ((c = getopt(argc, argv, master_service_getopt_string())) > 0) {
4d4d6d4745682790c20d759ba93dbea46b812c5dTimo Sirainen if (!master_service_parse_option(master_service, c, optarg))
cef2be5fb553b05f421f86c1ef497f0dc29d069eTimo Sirainen if (input.username == NULL && IS_STANDALONE())
cef2be5fb553b05f421f86c1ef497f0dc29d069eTimo Sirainen i_fatal("login_executable setting must be pop3-login, "
4d4d6d4745682790c20d759ba93dbea46b812c5dTimo Sirainen mail_user = mail_storage_service_init_user(master_service,
4d4d6d4745682790c20d759ba93dbea46b812c5dTimo Sirainen set = mail_storage_service_get_settings(master_service);
1b04762685272a53643ac2179939537a44c7c044Timo Sirainen /* fake that we're running, so we know if client was destroyed
1b04762685272a53643ac2179939537a44c7c044Timo Sirainen while initializing */