static gboolean gdm_local_display_factory_sync_seats (GdmLocalDisplayFactory *factory)
{
        GError *error = NULL;
        GVariant *result;
        GVariant *array;
        GVariantIter iter;
        const char *seat;

        result = g_dbus_connection_call_sync (factory->priv->connection,
                                              "org.freedesktop.login1",
                                              "/org/freedesktop/login1",
                                              "org.freedesktop.login1.Manager",
                                              "ListSeats",
                                              NULL,
                                              G_VARIANT_TYPE ("(a(so))"),
                                              G_DBUS_CALL_FLAGS_NONE,
                                              -1,
                                              NULL, &error);

        if (!result) {
                g_warning ("GdmLocalDisplayFactory: Failed to issue method call: %s", error->message);
                g_clear_error (&error);
                return FALSE;
        }

        array = g_variant_get_child_value (result, 0);
        g_variant_iter_init (&iter, array);

        while (g_variant_iter_loop (&iter, "(&so)", &seat, NULL)) {
                gboolean is_initial;
                const char *session_type = NULL;

                if (g_strcmp0 (seat, "seat0") == 0) {
                        is_initial = TRUE;
#ifdef ENABLE_WAYLAND_SUPPORT
                        gboolean wayland_enabled = FALSE;
                        if (gdm_settings_direct_get_boolean (GDM_KEY_WAYLAND_ENABLE, &wayland_enabled)) {
                                if (wayland_enabled) {
                                        session_type = "wayland";
                                }
                        }
#endif
                } else {
                        is_initial = FALSE;
                }

                create_display (factory, seat, session_type, is_initial);
        }

        g_variant_unref (result);
        g_variant_unref (array);
        return TRUE;
}
Example #2
0
static void
gdm_xdmcp_display_init (GdmXdmcpDisplay *xdmcp_display)
{

        gboolean allow_remote_autologin;

        xdmcp_display->priv = GDM_XDMCP_DISPLAY_GET_PRIVATE (xdmcp_display);

        allow_remote_autologin = FALSE;
        gdm_settings_direct_get_boolean (GDM_KEY_ALLOW_REMOTE_AUTOLOGIN, &allow_remote_autologin);

        g_object_set (G_OBJECT (xdmcp_display), "allow-timed-login", allow_remote_autologin, NULL);
}
static gboolean
is_debug_set (void)
{
        gboolean debug = FALSE;

        /* enable debugging for unstable builds */
        if (gdm_is_version_unstable ()) {
                return TRUE;
        }

        gdm_settings_direct_get_boolean (GDM_KEY_DEBUG, &debug);
        return debug;
}
static void
gdm_display_real_get_timed_login_details (GdmDisplay *display,
        gboolean   *enabledp,
        char      **usernamep,
        int        *delayp)
{
    gboolean res;
    gboolean enabled;
    int      delay;
    char    *username;

    enabled = FALSE;
    username = NULL;
    delay = 0;

#ifdef WITH_SYSTEMD
    /* FIXME: More careful thought needs to happen before we
     * can support auto/timed login on auxilliary seats in the
     * systemd path.
     */
    if (LOGIND_RUNNING()) {
        if (g_strcmp0 (display->priv->seat_id, "seat0") != 0) {
            goto out;
        }
    }
#endif

    res = gdm_settings_direct_get_boolean (GDM_KEY_AUTO_LOGIN_ENABLE, &enabled);
    if (res && enabled) {
        res = gdm_settings_direct_get_string (GDM_KEY_AUTO_LOGIN_USER, &username);
    }

    if (enabled && res && username != NULL && username[0] != '\0') {
        goto out;
    }

    g_free (username);
    username = NULL;
    enabled = FALSE;

    res = gdm_settings_direct_get_boolean (GDM_KEY_TIMED_LOGIN_ENABLE, &enabled);
    if (res && ! enabled) {
        goto out;
    }

    res = gdm_settings_direct_get_string (GDM_KEY_TIMED_LOGIN_USER, &username);
    if (res && (username == NULL || username[0] == '\0')) {
        enabled = FALSE;
        g_free (username);
        username = NULL;
        goto out;
    }

    delay = 0;
    res = gdm_settings_direct_get_int (GDM_KEY_TIMED_LOGIN_DELAY, &delay);

    if (res && delay <= 0) {
        /* we don't allow the timed login to have a zero delay */
        delay = 10;
    }

out:
    if (enabledp != NULL) {
        *enabledp = enabled;
    }
    if (usernamep != NULL) {
        *usernamep = username;
    } else {
        g_free (username);
    }
    if (delayp != NULL) {
        *delayp = delay;
    }
}
Example #5
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;
}
Example #6
0
static void
gdm_display_real_get_timed_login_details (GdmDisplay *display,
                                          gboolean   *enabledp,
                                          char      **usernamep,
                                          int        *delayp)
{
        gboolean res;
        gboolean enabled;
        int      delay;
        char    *username;

        enabled = FALSE;
        username = NULL;
        delay = 0;

        res = gdm_settings_direct_get_boolean (GDM_KEY_AUTO_LOGIN_ENABLE, &enabled);
        if (enabled) {
            res = gdm_settings_direct_get_string (GDM_KEY_AUTO_LOGIN_USER, &username);
        }

        if (enabled && username != NULL && username[0] != '\0') {
                goto out;
        }

        g_free (username);
        username = NULL;
        enabled = FALSE;

        res = gdm_settings_direct_get_boolean (GDM_KEY_TIMED_LOGIN_ENABLE, &enabled);
        if (! enabled) {
                goto out;
        }

        res = gdm_settings_direct_get_string (GDM_KEY_TIMED_LOGIN_USER, &username);
        if (username == NULL || username[0] == '\0') {
                enabled = FALSE;
                g_free (username);
                username = NULL;
                goto out;
        }

        delay = 0;
        res = gdm_settings_direct_get_int (GDM_KEY_TIMED_LOGIN_DELAY, &delay);

        if (delay <= 0) {
                /* we don't allow the timed login to have a zero delay */
                delay = 10;
        }

 out:
        if (enabledp != NULL) {
                *enabledp = enabled;
        }
        if (usernamep != NULL) {
                *usernamep = username;
        } else {
                g_free (username);
        }
        if (delayp != NULL) {
                *delayp = delay;
        }
}