Beispiel #1
0
static void restart(void)
{
	mroute4_disable(0);
	mroute6_disable(0);
	mcgroup4_disable();
	mcgroup6_disable();
	/* No need to close the IPC, only at cleanup. */

	/* Update list of interfaces and create new virtual interface mappings in kernel. */
	iface_init();
	mroute4_enable(do_vifs, table_id, cache_tmo);
	mroute6_enable(do_vifs, table_id);
}
Beispiel #2
0
/* Init everything before forking, so we can fail and return an
 * error code in the parent and the initscript will fail */
static void start_server(int background)
{
	int sd, api = 0;

	if (background && daemonize())
		return;

	smclog(LOG_NOTICE, 0, "%s", version_info);

	/* Build list of multicast-capable physical interfaces that
	 * are currently assigned an IP address. */
	iface_init();

	if (!mroute4_enable())
		api++;

	if (!mroute6_enable())
		api++;

	/* At least one API (IPv4 or IPv6) must have initialized successfully
	 * otherwise we abort the server initialization. */
	if (!api) {
		smclog(LOG_INIT, ENOPROTOOPT, "Kernel does not support multicast routing");
		exit(1);
	}

	sd = ipc_server_init();
	if (sd < 0)
		smclog(LOG_WARNING, errno, "Failed setting up IPC socket, client communication disabled");

	atexit(clean);
	signal_init();
	read_conf_file(conf_file);

	/* Everything setup, notify any clients by creating the pidfile */
	if (pidfile(NULL))
		smclog(LOG_WARNING, errno, "Failed creating pidfile");

	server_loop(sd);
}
Beispiel #3
0
/* Init everything before forking, so we can fail and return an
 * error code in the parent and the initscript will fail */
static int start_server(void)
{
	int api = 2, busy = 0;

	if (geteuid() != 0) {
		smclog(LOG_ERR, "Need root privileges to start %s", prognm);
		return 1;
	}

	if (background) {
		if (daemon(0, 0) < 0) {
			smclog(LOG_ERR, "Failed daemonizing: %s", strerror(errno));
			return 1;
		}
	}

	/* Hello world! */
	smclog(LOG_NOTICE, "%s", version_info);

	if (startup_delay > 0) {
		smclog(LOG_INFO, "Startup delay requested, waiting %d sec before continuing.", startup_delay);
		sleep(startup_delay);
	}

	/*
	 * Timer API needs to be initilized before mroute4_enable()
	 */
	timer_init();

	/*
	 * Build list of multicast-capable physical interfaces
	 */
	iface_init();

	if (mroute4_enable(do_vifs, table_id, cache_tmo)) {
		if (errno == EADDRINUSE)
			busy++;
		api--;
	}

	if (mroute6_enable(do_vifs, table_id)) {
		if (errno == EADDRINUSE)
			busy++;
		api--;
	}

	/* At least one API (IPv4 or IPv6) must have initialized successfully
	 * otherwise we abort the server initialization. */
	if (!api) {
		if (busy)
			smclog(LOG_ERR, "Another multicast routing application is already running.");
		else
			smclog(LOG_ERR, "Kernel does not support multicast routing.");
		exit(1);
	}

	atexit(clean);
	signal_init();
	ipc_init();

	conf_read(conf_file, do_vifs);

	/* Everything setup, notify any clients waiting for us */
	notify_ready(pid_file, uid, gid);

	/* Drop root privileges before entering the server loop */
	cap_drop_root(uid, gid);

	return server_loop();
}