Exemplo n.º 1
0
static gboolean
gdm_display_real_manage (GdmDisplay *display)
{
    gboolean res;

    g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);

    g_debug ("GdmDisplay: manage display");

    /* If not explicitly prepared, do it now */
    if (display->priv->status == GDM_DISPLAY_UNMANAGED) {
        res = gdm_display_prepare (display);
        if (! res) {
            return FALSE;
        }
    }

    g_assert (display->priv->slave_proxy != NULL);

    g_timer_start (display->priv->slave_timer);

    gdm_slave_proxy_start (display->priv->slave_proxy);

    return TRUE;
}
Exemplo n.º 2
0
int
gdm_display_get_status (GdmDisplay *display)
{
    g_return_val_if_fail (GDM_IS_DISPLAY (display), 0);

    return display->priv->status;
}
Exemplo n.º 3
0
time_t
gdm_display_get_creation_time (GdmDisplay *display)
{
    g_return_val_if_fail (GDM_IS_DISPLAY (display), 0);

    return display->priv->creation_time;
}
Exemplo n.º 4
0
static gboolean
gdm_xdmcp_display_create_authority (GdmDisplay *display)
{
        g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);

        return GDM_DISPLAY_CLASS (gdm_xdmcp_display_parent_class)->create_authority (display);
}
Exemplo n.º 5
0
static void
gdm_display_finalize (GObject *object)
{
        GdmDisplay *display;

        g_return_if_fail (object != NULL);
        g_return_if_fail (GDM_IS_DISPLAY (object));

        display = GDM_DISPLAY (object);

        g_return_if_fail (display->priv != NULL);

        g_debug ("GdmDisplay: Finalizing display: %s", display->priv->id);
        g_free (display->priv->id);
        g_free (display->priv->seat_id);
        g_free (display->priv->remote_hostname);
        g_free (display->priv->x11_display_name);
        g_free (display->priv->x11_cookie);
        g_free (display->priv->slave_command);

        if (display->priv->access_file != NULL) {
                g_object_unref (display->priv->access_file);
        }

        if (display->priv->user_access_file != NULL) {
                g_object_unref (display->priv->user_access_file);
        }

        if (display->priv->slave_timer != NULL) {
                g_timer_destroy (display->priv->slave_timer);
        }

        G_OBJECT_CLASS (gdm_display_parent_class)->finalize (object);
}
Exemplo n.º 6
0
static gboolean
gdm_xdmcp_display_unmanage (GdmDisplay *display)
{
        g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);

        GDM_DISPLAY_CLASS (gdm_xdmcp_display_parent_class)->unmanage (display);
        return TRUE;
}
Exemplo n.º 7
0
static gboolean
gdm_display_real_finish (GdmDisplay *display)
{
    g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);

    _gdm_display_set_status (display, GDM_DISPLAY_FINISHED);

    g_debug ("GdmDisplay: finish display");

    return TRUE;
}
Exemplo n.º 8
0
gboolean
gdm_display_create_authority (GdmDisplay *display)
{
    gboolean ret;

    g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);

    g_object_ref (display);
    ret = GDM_DISPLAY_GET_CLASS (display)->create_authority (display);
    g_object_unref (display);

    return ret;
}
Exemplo n.º 9
0
gboolean
gdm_display_is_local (GdmDisplay *display,
                      gboolean   *local,
                      GError    **error)
{
    g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);

    if (local != NULL) {
        *local = display->priv->is_local;
    }

    return TRUE;
}
Exemplo n.º 10
0
gboolean
gdm_display_get_x11_display_name (GdmDisplay   *display,
                                  char        **x11_display,
                                  GError      **error)
{
    g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);

    if (x11_display != NULL) {
        *x11_display = g_strdup (display->priv->x11_display_name);
    }

    return TRUE;
}
Exemplo n.º 11
0
gboolean
gdm_display_get_x11_display_number (GdmDisplay *display,
                                    int        *number,
                                    GError    **error)
{
    g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);

    if (number != NULL) {
        *number = display->priv->x11_display_number;
    }

    return TRUE;
}
Exemplo n.º 12
0
gboolean
gdm_display_get_id (GdmDisplay         *display,
                    char              **id,
                    GError            **error)
{
    g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);

    if (id != NULL) {
        *id = g_strdup (display->priv->id);
    }

    return TRUE;
}
Exemplo n.º 13
0
gboolean
gdm_display_get_remote_hostname (GdmDisplay *display,
                                 char      **hostname,
                                 GError    **error)
{
    g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);

    if (hostname != NULL) {
        *hostname = g_strdup (display->priv->remote_hostname);
    }

    return TRUE;
}
Exemplo n.º 14
0
gboolean
gdm_display_unmanage (GdmDisplay *display)
{
    gboolean ret;

    g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);

    g_debug ("GdmDisplay: Unmanaging display");

    g_object_ref (display);
    ret = GDM_DISPLAY_GET_CLASS (display)->unmanage (display);
    g_object_unref (display);

    return ret;
}
Exemplo n.º 15
0
gboolean
gdm_display_finish (GdmDisplay *display)
{
    gboolean ret;

    g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);

    g_debug ("GdmDisplay: Finishing display: %s", display->priv->id);

    g_object_ref (display);
    ret = GDM_DISPLAY_GET_CLASS (display)->finish (display);
    g_object_unref (display);

    return ret;
}
Exemplo n.º 16
0
gboolean
gdm_display_get_x11_authority_file (GdmDisplay *display,
                                    char      **filename,
                                    GError    **error)
{
    g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
    g_return_val_if_fail (filename != NULL, FALSE);

    if (display->priv->access_file != NULL) {
        *filename = gdm_display_access_file_get_path (display->priv->access_file);
    } else {
        *filename = NULL;
    }

    return TRUE;
}
Exemplo n.º 17
0
gboolean
gdm_display_get_x11_cookie (GdmDisplay *display,
                            GArray    **x11_cookie,
                            GError    **error)
{
    g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);

    if (x11_cookie != NULL) {
        *x11_cookie = g_array_new (TRUE, FALSE, sizeof (char));
        g_array_append_vals (*x11_cookie,
                             display->priv->x11_cookie,
                             display->priv->x11_cookie_size);
    }

    return TRUE;
}
Exemplo n.º 18
0
static gboolean
gdm_display_real_add_user_authorization (GdmDisplay *display,
        const char *username,
        char      **filename,
        GError    **error)
{
    GdmDisplayAccessFile *access_file;
    GError               *access_file_error;
    gboolean              res;

    g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
    g_return_val_if_fail (display->priv->access_file != NULL, FALSE);

    g_debug ("GdmDisplay: Adding user authorization for %s", username);

    access_file_error = NULL;
    access_file = _create_access_file_for_user (display,
                  username,
                  &access_file_error);

    if (access_file == NULL) {
        g_propagate_error (error, access_file_error);
        return FALSE;
    }

    res = gdm_display_access_file_add_display_with_cookie (access_file,
            display,
            display->priv->x11_cookie,
            display->priv->x11_cookie_size,
            &access_file_error);
    if (! res) {
        g_debug ("GdmDisplay: Unable to add user authorization for %s: %s",
                 username,
                 access_file_error->message);
        g_propagate_error (error, access_file_error);
        gdm_display_access_file_close (access_file);
        g_object_unref (access_file);
        return FALSE;
    }

    *filename = gdm_display_access_file_get_path (access_file);
    display->priv->user_access_file = access_file;

    g_debug ("GdmDisplay: Added user authorization for %s: %s", username, *filename);

    return TRUE;
}
Exemplo n.º 19
0
gboolean
gdm_display_set_slave_bus_name (GdmDisplay *display,
                                const char *name,
                                GError    **error)
{
    gboolean ret;

    g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);

    g_debug ("GdmDisplay: Setting slave bus name:%s on display %s", name, display->priv->x11_display_name);

    g_object_ref (display);
    ret = GDM_DISPLAY_GET_CLASS (display)->set_slave_bus_name (display, name, error);
    g_object_unref (display);

    return ret;
}
Exemplo n.º 20
0
gboolean
gdm_display_remove_user_authorization (GdmDisplay *display,
                                       const char *username,
                                       GError    **error)
{
    gboolean ret;

    g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);

    g_debug ("GdmDisplay: Removing authorization for user:%s on display %s", username, display->priv->x11_display_name);

    g_object_ref (display);
    ret = GDM_DISPLAY_GET_CLASS (display)->remove_user_authorization (display, username, error);
    g_object_unref (display);

    return ret;
}
Exemplo n.º 21
0
static gboolean
gdm_display_real_unmanage (GdmDisplay *display)
{
    gdouble elapsed;

    g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);

    g_debug ("GdmDisplay: unmanage display");

    g_timer_stop (display->priv->slave_timer);

    if (display->priv->slave_proxy != NULL) {
        gdm_slave_proxy_stop (display->priv->slave_proxy);

        g_object_unref (display->priv->slave_proxy);
        display->priv->slave_proxy = NULL;
    }

    if (display->priv->user_access_file != NULL) {
        gdm_display_access_file_close (display->priv->user_access_file);
        g_object_unref (display->priv->user_access_file);
        display->priv->user_access_file = NULL;
    }

    if (display->priv->access_file != NULL) {
        gdm_display_access_file_close (display->priv->access_file);
        g_object_unref (display->priv->access_file);
        display->priv->access_file = NULL;
    }

    elapsed = g_timer_elapsed (display->priv->slave_timer, NULL);
    if (elapsed < 3) {
        g_warning ("GdmDisplay: display lasted %lf seconds", elapsed);
        _gdm_display_set_status (display, GDM_DISPLAY_FAILED);
    } else {
        _gdm_display_set_status (display, GDM_DISPLAY_UNMANAGED);
    }

    if (display->priv->slave_name_id > 0) {
        g_bus_unwatch_name (display->priv->slave_name_id);
        display->priv->slave_name_id = 0;
    }

    return TRUE;
}
Exemplo n.º 22
0
static gboolean
gdm_display_real_prepare (GdmDisplay *display)
{
    char *command;
    char *log_file;
    char *log_path;

    g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);

    g_debug ("GdmDisplay: prepare display");

    g_assert (display->priv->slave_proxy == NULL);

    if (!gdm_display_create_authority (display)) {
        g_warning ("Unable to set up access control for display %d",
                   display->priv->x11_display_number);
        return FALSE;
    }

    _gdm_display_set_status (display, GDM_DISPLAY_PREPARED);

    display->priv->slave_proxy = gdm_slave_proxy_new ();
    g_signal_connect (display->priv->slave_proxy,
                      "exited",
                      G_CALLBACK (slave_exited),
                      display);
    g_signal_connect (display->priv->slave_proxy,
                      "died",
                      G_CALLBACK (slave_died),
                      display);

    log_file = g_strdup_printf ("%s-slave.log", display->priv->x11_display_name);
    log_path = g_build_filename (LOGDIR, log_file, NULL);
    g_free (log_file);
    gdm_slave_proxy_set_log_path (display->priv->slave_proxy, log_path);
    g_free (log_path);

    command = g_strdup_printf ("%s --display-id %s",
                               display->priv->slave_command,
                               display->priv->id);
    gdm_slave_proxy_set_command (display->priv->slave_proxy, command);
    g_free (command);

    return TRUE;
}
Exemplo n.º 23
0
gboolean
gdm_display_get_timed_login_details (GdmDisplay *display,
                                     gboolean   *enabled,
                                     char      **username,
                                     int        *delay,
                                     GError    **error)
{
    g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);

    GDM_DISPLAY_GET_CLASS (display)->get_timed_login_details (display, enabled, username, delay);

    g_debug ("GdmSlave: Got timed login details for display %s: %d '%s' %d",
             display->priv->x11_display_name,
             *enabled,
             *username ? *username : "******",
             *delay);

    return TRUE;
}
Exemplo n.º 24
0
static gboolean
gdm_display_real_create_authority (GdmDisplay *display)
{
    GdmDisplayAccessFile *access_file;
    GError               *error;
    gboolean              res;

    g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
    g_return_val_if_fail (display->priv->access_file == NULL, FALSE);

    error = NULL;
    access_file = _create_access_file_for_user (display, GDM_USERNAME, &error);

    if (access_file == NULL) {
        g_critical ("could not create display access file: %s", error->message);
        g_error_free (error);
        return FALSE;
    }

    g_free (display->priv->x11_cookie);
    display->priv->x11_cookie = NULL;
    res = gdm_display_access_file_add_display (access_file,
            display,
            &display->priv->x11_cookie,
            &display->priv->x11_cookie_size,
            &error);

    if (! res) {

        g_critical ("could not add display to access file: %s", error->message);
        g_error_free (error);
        gdm_display_access_file_close (access_file);
        g_object_unref (access_file);
        return FALSE;
    }

    display->priv->access_file = access_file;

    return TRUE;
}