Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
	GMainLoop *loop;
	guint bus;

	loop = g_main_loop_new(NULL, FALSE);

	bus = g_bus_own_name(G_BUS_TYPE_SYSTEM,
	                     "org.freedesktop.login1",
	                     G_BUS_NAME_OWNER_FLAGS_NONE,
	                     on_bus_acquired,
	                     on_name_acquired,
	                     on_name_lost,
	                     loop,
	                     NULL);

	/* create /run/systemd/seats, since that's how GDM checks whether logind is
	 * running - see LOGIND_RUNNING() */
	if (-1 == g_mkdir_with_parents("/run/systemd/seats", 0755))
		goto cleanup;

	g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "entering the main loop");
	g_main_loop_run(loop);
	g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "exited the main loop");

cleanup:
	signals_unsubscribe();
	bus_close();

	g_main_loop_unref(loop);

	g_bus_unown_name(bus);

	return 0;
}
Ejemplo n.º 2
0
int main(int argc, char *argv[])
{
	GMainLoop *loop;
	guint bus;

	loop = g_main_loop_new(NULL, FALSE);

	bus = g_bus_own_name(G_BUS_TYPE_SYSTEM,
	                     "org.freedesktop.login1",
	                     G_BUS_NAME_OWNER_FLAGS_NONE,
	                     on_bus_acquired,
	                     on_name_acquired,
	                     on_name_lost,
	                     loop,
	                     NULL);

	/* create /run/systemd/seats, since that's how GDM checks whether logind is
	 * running - see LOGIND_RUNNING() */
	if (-1 == g_mkdir_with_parents("/run/systemd/seats", 0755))
		goto cleanup;
	if (-1 == g_mkdir_with_parents("/run/systemd/sessions", 0755))
		goto cleanup;

	/* normally, /run/systemd/multi-session-x contains a file for each session,
	 * but since ConsoleKit's session IDs are D-Bus object paths, they contain /
	 * characeters, so extra sub-directories are required to prevent failure of
	 * mkdir() in LoginKit clients */
	if (-1 == g_mkdir_with_parents(
	                  "/run/systemd/multi-session-x/org/freedesktop/ConsoleKit",
	                  0755))
		goto cleanup;

	g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "entering the main loop");
	g_main_loop_run(loop);
	g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "exited the main loop");

cleanup:
	signals_unsubscribe();
	bus_close();

	g_main_loop_unref(loop);

	g_bus_unown_name(bus);

	return 0;
}