int main (int argc, char **argv) { GMainLoop *main_loop; GOptionContext *context; GDBusConnection *connection; GdmSlave *slave; static char *display_id = NULL; static GOptionEntry entries [] = { { "display-id", 0, 0, G_OPTION_ARG_STRING, &display_id, N_("Display ID"), N_("ID") }, { NULL } }; bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); textdomain (GETTEXT_PACKAGE); setlocale (LC_ALL, ""); context = g_option_context_new (_("GNOME Display Manager Slave")); g_option_context_add_main_entries (context, entries, NULL); g_option_context_parse (context, &argc, &argv, NULL); g_option_context_free (context); /* For debugging */ /*sleep (10);*/ connection = get_system_bus (); if (connection == NULL) { goto out; } gdm_xerrors_init (); gdm_log_init (); settings = gdm_settings_new (); if (settings == NULL) { g_warning ("Unable to initialize settings"); goto out; } if (! gdm_settings_direct_init (settings, DATADIR "/gdm/gdm.schemas", "/")) { g_warning ("Unable to initialize settings"); goto out; } gdm_log_set_debug (is_debug_set ()); if (display_id == NULL) { g_critical ("No display ID set"); exit (1); } if (! gdm_settings_client_init (DATADIR "/gdm/gdm.schemas", "/")) { g_critical ("Unable to initialize settings client"); exit (1); } main_loop = g_main_loop_new (NULL, FALSE); g_unix_signal_add (SIGTERM, on_shutdown_signal_cb, main_loop); g_unix_signal_add (SIGINT, on_shutdown_signal_cb, main_loop); g_unix_signal_add (SIGUSR2, on_sigusr2_cb, NULL); slave = gdm_simple_slave_new (display_id); if (slave == NULL) { goto out; } g_signal_connect (slave, "stopped", G_CALLBACK (on_slave_stopped), main_loop); gdm_slave_start (slave); g_main_loop_run (main_loop); if (slave != NULL) { g_object_unref (slave); } g_main_loop_unref (main_loop); out: g_debug ("Slave finished"); g_object_unref (connection); return gdm_return_code; }
int main (int argc, char **argv) { GMainLoop *main_loop; GOptionContext *context; GdmSessionWorker *worker; const char *address; gboolean is_for_reauth; static GOptionEntry entries [] = { { NULL } }; bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); textdomain (GETTEXT_PACKAGE); setlocale (LC_ALL, ""); /* Translators: worker is a helper process that does the work of starting up a session */ context = g_option_context_new (_("GNOME Display Manager Session Worker")); g_option_context_add_main_entries (context, entries, NULL); g_option_context_parse (context, &argc, &argv, NULL); g_option_context_free (context); gdm_log_init (); settings = gdm_settings_new (); if (settings == NULL) { g_warning ("Unable to initialize settings"); exit (1); } if (! gdm_settings_direct_init (settings, DATADIR "/gdm/gdm.schemas", "/")) { g_warning ("Unable to initialize settings"); exit (1); } gdm_log_set_debug (is_debug_set ()); address = g_getenv ("GDM_SESSION_DBUS_ADDRESS"); if (address == NULL) { g_warning ("GDM_SESSION_DBUS_ADDRESS not set"); exit (1); } is_for_reauth = g_getenv ("GDM_SESSION_FOR_REAUTH") != NULL; worker = gdm_session_worker_new (address, is_for_reauth); main_loop = g_main_loop_new (NULL, FALSE); g_unix_signal_add (SIGTERM, on_shutdown_signal_cb, main_loop); g_unix_signal_add (SIGINT, on_shutdown_signal_cb, main_loop); g_unix_signal_add (SIGUSR1, on_sigusr1_cb, NULL); g_main_loop_run (main_loop); if (worker != NULL) { g_object_unref (worker); } g_main_loop_unref (main_loop); g_debug ("Worker finished"); return 0; }
int main (int argc, char **argv) { State *state = NULL; GOptionContext *context = NULL; static char **args = NULL; static gboolean run_script = FALSE; static gboolean allow_remote_connections = FALSE; gboolean debug = FALSE; gboolean ret; int exit_status = EX_OK; static GOptionEntry entries [] = { { "run-script", 'r', 0, G_OPTION_ARG_NONE, &run_script, N_("Run program through /etc/gdm/Xsession wrapper script"), NULL }, { "allow-remote-connections", 'a', 0, G_OPTION_ARG_NONE, &allow_remote_connections, N_("Listen on TCP socket"), NULL }, { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &args, "", "" }, { NULL } }; bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); textdomain (GETTEXT_PACKAGE); setlocale (LC_ALL, ""); gdm_log_init (); context = g_option_context_new (_("GNOME Display Manager X Session Launcher")); g_option_context_add_main_entries (context, entries, NULL); g_option_context_parse (context, &argc, &argv, NULL); g_option_context_free (context); if (args == NULL || args[0] == NULL || args[1] != NULL) { g_warning ("gdm-x-session takes one argument (the session)"); exit_status = EX_USAGE; goto out; } init_state (&state); state->session_command = args[0]; state->settings = gdm_settings_new (); ret = gdm_settings_direct_init (state->settings, DATADIR "/gdm/gdm.schemas", "/"); if (!ret) { g_printerr ("Unable to initialize settings"); exit_status = EX_DATAERR; goto out; } gdm_settings_direct_get_boolean (GDM_KEY_DEBUG, &debug); state->debug_enabled = debug; gdm_log_set_debug (debug); state->main_loop = g_main_loop_new (NULL, FALSE); state->cancellable = g_cancellable_new (); g_unix_signal_add (SIGTERM, (GSourceFunc) on_sigterm, state); ret = spawn_x_server (state, allow_remote_connections, state->cancellable); if (!ret) { g_printerr ("Unable to run X server"); exit_status = EX_SOFTWARE; goto out; } ret = spawn_bus (state, state->cancellable); if (!ret) { g_printerr ("Unable to run session message bus"); exit_status = EX_SOFTWARE; goto out; } ret = register_display (state, state->cancellable); if (!ret) { g_printerr ("Unable to register display with display manager"); exit_status = EX_SOFTWARE; goto out; } ret = spawn_session (state, run_script, state->cancellable); if (!ret) { g_printerr ("Unable to run session"); exit_status = EX_SOFTWARE; goto out; } g_main_loop_run (state->main_loop); /* Only use exit status of session if we're here because it exit */ if (state->session_subprocess == NULL) { exit_status = state->session_exit_status; } out: signal_subprocesses (state); wait_on_subprocesses (state); clear_state (&state); return exit_status; }
int main (int argc, char **argv) { GMainLoop *main_loop; GOptionContext *context; DBusGConnection *connection; GdmSlave *slave; static char *display_id = NULL; GdmSignalHandler *signal_handler; static GOptionEntry entries [] = { { "display-id", 0, 0, G_OPTION_ARG_STRING, &display_id, N_("Display ID"), N_("ID") }, { NULL } }; bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); textdomain (GETTEXT_PACKAGE); setlocale (LC_ALL, ""); g_type_init (); context = g_option_context_new (_("GNOME Display Manager Slave")); g_option_context_add_main_entries (context, entries, NULL); g_option_context_parse (context, &argc, &argv, NULL); g_option_context_free (context); connection = get_system_bus (); if (connection == NULL) { goto out; } gdm_xerrors_init (); gdm_log_init (); settings = gdm_settings_new (); if (settings == NULL) { g_warning ("Unable to initialize settings"); goto out; } if (! gdm_settings_direct_init (settings, DATADIR "/gdm/gdm.schemas", "/")) { g_warning ("Unable to initialize settings"); goto out; } gdm_log_set_debug (is_debug_set ()); if (display_id == NULL) { g_critical ("No display ID set"); exit (1); } main_loop = g_main_loop_new (NULL, FALSE); signal_handler = gdm_signal_handler_new (); gdm_signal_handler_set_fatal_func (signal_handler, (GDestroyNotify)g_main_loop_quit, main_loop); gdm_signal_handler_add (signal_handler, SIGTERM, signal_cb, NULL); gdm_signal_handler_add (signal_handler, SIGINT, signal_cb, NULL); gdm_signal_handler_add (signal_handler, SIGILL, signal_cb, NULL); gdm_signal_handler_add (signal_handler, SIGBUS, signal_cb, NULL); gdm_signal_handler_add (signal_handler, SIGFPE, signal_cb, NULL); gdm_signal_handler_add (signal_handler, SIGHUP, signal_cb, NULL); gdm_signal_handler_add (signal_handler, SIGSEGV, signal_cb, NULL); gdm_signal_handler_add (signal_handler, SIGABRT, signal_cb, NULL); gdm_signal_handler_add (signal_handler, SIGUSR1, signal_cb, NULL); gdm_signal_handler_add (signal_handler, SIGUSR2, signal_cb, NULL); slave = gdm_product_slave_new (display_id); if (slave == NULL) { goto out; } g_signal_connect (slave, "stopped", G_CALLBACK (on_slave_stopped), main_loop); gdm_slave_start (slave); g_main_loop_run (main_loop); if (slave != NULL) { g_object_unref (slave); } if (signal_handler != NULL) { g_object_unref (signal_handler); } if (main_loop != NULL) { g_main_loop_unref (main_loop); } out: g_debug ("Slave finished"); return gdm_return_code; }