view src/imap-hibernate/main.c @ 22656:1789bf2a1e01

director: Make sure HOST-RESET-USERS isn't used with max_moving_users=0 The reset command would just hang in that case. doveadm would never have sent this, so this is just an extra sanity check.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sun, 05 Nov 2017 23:51:56 +0200
parents 2e2563132d5f
children cb108f786fb4
line wrap: on
line source

/* Copyright (c) 2014-2017 Dovecot authors, see the included COPYING file */

#include "lib.h"
#include "restrict-access.h"
#include "master-service.h"
#include "master-service-settings.h"
#include "imap-client.h"
#include "imap-hibernate-client.h"
#include "imap-master-connection.h"

static bool debug = FALSE;

static void client_connected(struct master_service_connection *conn)
{
	master_service_client_connection_accept(conn);
	imap_hibernate_client_create(conn->fd, debug);
}

int main(int argc, char *argv[])
{
	enum master_service_flags service_flags =
		MASTER_SERVICE_FLAG_UPDATE_PROCTITLE;
	const char *error;
	int c;

	master_service = master_service_init("imap-hibernate", service_flags,
					     &argc, &argv, "D");
	while ((c = master_getopt(master_service)) > 0) {
		switch (c) {
		case 'D':
			debug = TRUE;
			break;
		default:
			return FATAL_DEFAULT;
		}
	}

	if (master_service_settings_read_simple(master_service, NULL, &error) < 0)
		i_fatal("Error reading configuration: %s", error);

	master_service_init_log(master_service, "imap-hibernate: ");
	restrict_access_by_env(NULL, FALSE);
	restrict_access_allow_coredumps(TRUE);

	imap_clients_init();
	imap_master_connections_init();
	imap_hibernate_clients_init();
	master_service_init_finish(master_service);

	master_service_run(master_service, client_connected);

	imap_master_connections_deinit();
	imap_hibernate_clients_deinit();
	imap_clients_deinit();
	master_service_deinit(&master_service);
        return 0;
}