one more time...
This commit is contained in:
parent
fd9fad4e24
commit
e2510ce68e
@ -1,4 +1,6 @@
|
||||
--- common/gdm-common.c (revision 5497)
|
||||
Index: common/gdm-common.c
|
||||
===================================================================
|
||||
--- common/gdm-common.c (revision 5498)
|
||||
+++ common/gdm-common.c (working copy)
|
||||
@@ -32,7 +32,6 @@
|
||||
#include <glib/gstdio.h>
|
||||
@ -214,7 +216,7 @@
|
||||
-}
|
||||
Index: common/gdm-common.h
|
||||
===================================================================
|
||||
--- common/gdm-common.h (revision 5497)
|
||||
--- common/gdm-common.h (revision 5498)
|
||||
+++ common/gdm-common.h (working copy)
|
||||
@@ -32,9 +32,6 @@ void gdm_set_fatal_warnings_if
|
||||
int gdm_signal_pid (int pid,
|
||||
@ -236,7 +238,7 @@ Index: common/gdm-common.h
|
||||
|
||||
Index: daemon/gdm-local-display-factory.c
|
||||
===================================================================
|
||||
--- daemon/gdm-local-display-factory.c (revision 5497)
|
||||
--- daemon/gdm-local-display-factory.c (revision 5498)
|
||||
+++ daemon/gdm-local-display-factory.c (working copy)
|
||||
@@ -89,6 +89,12 @@ create_display_for_device (GdmLocalDispl
|
||||
return;
|
||||
@ -253,7 +255,7 @@ Index: daemon/gdm-local-display-factory.c
|
||||
g_object_unref (display);
|
||||
Index: daemon/gdm-server.c
|
||||
===================================================================
|
||||
--- daemon/gdm-server.c (revision 5497)
|
||||
--- daemon/gdm-server.c (revision 5498)
|
||||
+++ daemon/gdm-server.c (working copy)
|
||||
@@ -743,6 +743,14 @@ _gdm_server_set_display_name (GdmServer
|
||||
}
|
||||
@ -322,7 +324,7 @@ Index: daemon/gdm-server.c
|
||||
return GDM_SERVER (object);
|
||||
Index: daemon/gdm-server.h
|
||||
===================================================================
|
||||
--- daemon/gdm-server.h (revision 5497)
|
||||
--- daemon/gdm-server.h (revision 5498)
|
||||
+++ daemon/gdm-server.h (working copy)
|
||||
@@ -49,7 +49,8 @@ typedef struct
|
||||
} GdmServerClass;
|
||||
@ -336,7 +338,7 @@ Index: daemon/gdm-server.h
|
||||
char * gdm_server_get_display_device (GdmServer *server);
|
||||
Index: daemon/gdm-xdmcp-display.c
|
||||
===================================================================
|
||||
--- daemon/gdm-xdmcp-display.c (revision 5497)
|
||||
--- daemon/gdm-xdmcp-display.c (revision 5498)
|
||||
+++ daemon/gdm-xdmcp-display.c (working copy)
|
||||
@@ -42,8 +42,6 @@
|
||||
#include "gdm-common.h"
|
||||
@ -472,7 +474,7 @@ Index: daemon/gdm-xdmcp-display.c
|
||||
|
||||
Index: daemon/gdm-product-slave.c
|
||||
===================================================================
|
||||
--- daemon/gdm-product-slave.c (revision 5497)
|
||||
--- daemon/gdm-product-slave.c (revision 5498)
|
||||
+++ daemon/gdm-product-slave.c (working copy)
|
||||
@@ -335,11 +335,13 @@ static gboolean
|
||||
gdm_product_slave_create_server (GdmProductSlave *slave)
|
||||
@ -507,7 +509,7 @@ Index: daemon/gdm-product-slave.c
|
||||
}
|
||||
Index: daemon/auth.c
|
||||
===================================================================
|
||||
--- daemon/auth.c (revision 5497)
|
||||
--- daemon/auth.c (revision 5498)
|
||||
+++ daemon/auth.c (working copy)
|
||||
@@ -1,240 +0,0 @@
|
||||
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||
@ -752,7 +754,7 @@ Index: daemon/auth.c
|
||||
-}
|
||||
Index: daemon/auth.h
|
||||
===================================================================
|
||||
--- daemon/auth.h (revision 5497)
|
||||
--- daemon/auth.h (revision 5498)
|
||||
+++ daemon/auth.h (working copy)
|
||||
@@ -1,49 +0,0 @@
|
||||
-/* GDM - The GNOME Display Manager
|
||||
@ -806,7 +808,7 @@ Index: daemon/auth.h
|
||||
-#endif /* GDM_AUTH_H */
|
||||
Index: daemon/gdm-slave.c
|
||||
===================================================================
|
||||
--- daemon/gdm-slave.c (revision 5497)
|
||||
--- daemon/gdm-slave.c (revision 5498)
|
||||
+++ daemon/gdm-slave.c (working copy)
|
||||
@@ -75,7 +75,6 @@ struct GdmSlavePrivate
|
||||
gboolean display_is_local;
|
||||
@ -949,9 +951,609 @@ Index: daemon/gdm-slave.c
|
||||
PROP_DISPLAY_IS_LOCAL,
|
||||
g_param_spec_boolean ("display-is-local",
|
||||
"display is local",
|
||||
Index: daemon/gdm-display-access-file.c
|
||||
===================================================================
|
||||
--- daemon/gdm-display-access-file.c (revision 0)
|
||||
+++ daemon/gdm-display-access-file.c (revision 0)
|
||||
@@ -0,0 +1,504 @@
|
||||
+/* gdm-display-access-file.c - Abstraction around xauth cookies
|
||||
+ *
|
||||
+ * Copyright (C) 2007 Ray Strode <rstrode@redhat.com>
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License as published by
|
||||
+ * the Free Software Foundation; either version 2, or (at your option)
|
||||
+ * any later version.
|
||||
+ *
|
||||
+ * This program is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+ * GNU General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU General Public License
|
||||
+ * along with this program; if not, write to the Free Software
|
||||
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
+ * 02111-1307, USA.
|
||||
+ */
|
||||
+#include "config.h"
|
||||
+#include "gdm-display-access-file.h"
|
||||
+
|
||||
+#include <errno.h>
|
||||
+#include <pwd.h>
|
||||
+#include <string.h>
|
||||
+#include <sys/types.h>
|
||||
+#include <unistd.h>
|
||||
+
|
||||
+#include <glib.h>
|
||||
+#include <glib-object.h>
|
||||
+#include <glib/gstdio.h>
|
||||
+#include <glib/gi18n.h>
|
||||
+
|
||||
+#include <X11/Xauth.h>
|
||||
+
|
||||
+struct _GdmDisplayAccessFilePrivate
|
||||
+{
|
||||
+ char *username;
|
||||
+ FILE *fp;
|
||||
+ char *path;
|
||||
+};
|
||||
+
|
||||
+#ifndef GDM_DISPLAY_ACCESS_COOKIE_SIZE
|
||||
+#define GDM_DISPLAY_ACCESS_COOKIE_SIZE 16
|
||||
+#endif
|
||||
+
|
||||
+static void gdm_display_access_file_finalize (GObject * object);
|
||||
+
|
||||
+enum
|
||||
+{
|
||||
+ PROP_0 = 0,
|
||||
+ PROP_USERNAME,
|
||||
+ PROP_PATH
|
||||
+};
|
||||
+
|
||||
+G_DEFINE_TYPE (GdmDisplayAccessFile, gdm_display_access_file, G_TYPE_OBJECT);
|
||||
+
|
||||
+static void
|
||||
+gdm_display_access_file_get_property (GObject *object,
|
||||
+ guint prop_id,
|
||||
+ GValue *value,
|
||||
+ GParamSpec *pspec)
|
||||
+{
|
||||
+ GdmDisplayAccessFile *access_file;
|
||||
+
|
||||
+ access_file = GDM_DISPLAY_ACCESS_FILE (object);
|
||||
+
|
||||
+ switch (prop_id) {
|
||||
+ case PROP_USERNAME:
|
||||
+ g_value_set_string (value, access_file->priv->username);
|
||||
+ break;
|
||||
+
|
||||
+ case PROP_PATH:
|
||||
+ g_value_set_string (value, access_file->priv->path);
|
||||
+ break;
|
||||
+
|
||||
+ default:
|
||||
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+gdm_display_access_file_set_property (GObject *object,
|
||||
+ guint prop_id,
|
||||
+ const GValue *value,
|
||||
+ GParamSpec *pspec)
|
||||
+{
|
||||
+ GdmDisplayAccessFile *access_file;
|
||||
+
|
||||
+ access_file = GDM_DISPLAY_ACCESS_FILE (object);
|
||||
+
|
||||
+ switch (prop_id) {
|
||||
+ case PROP_USERNAME:
|
||||
+ g_assert (access_file->priv->username == NULL);
|
||||
+ access_file->priv->username = g_value_dup_string (value);
|
||||
+ break;
|
||||
+
|
||||
+ default:
|
||||
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+gdm_display_access_file_class_init (GdmDisplayAccessFileClass *access_file_class)
|
||||
+{
|
||||
+ GObjectClass *object_class;
|
||||
+ GParamSpec *param_spec;
|
||||
+
|
||||
+ object_class = G_OBJECT_CLASS (access_file_class);
|
||||
+
|
||||
+ object_class->finalize = gdm_display_access_file_finalize;
|
||||
+ object_class->get_property = gdm_display_access_file_get_property;
|
||||
+ object_class->set_property = gdm_display_access_file_set_property;
|
||||
+
|
||||
+ param_spec = g_param_spec_string ("username", "Username",
|
||||
+ "Owner of Xauthority file",
|
||||
+ NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
+ g_object_class_install_property (object_class, PROP_USERNAME, param_spec);
|
||||
+ param_spec = g_param_spec_string ("path", "Path",
|
||||
+ "Path to Xauthority file",
|
||||
+ NULL, G_PARAM_READABLE);
|
||||
+ g_object_class_install_property (object_class, PROP_PATH, param_spec);
|
||||
+ g_type_class_add_private (access_file_class, sizeof (GdmDisplayAccessFilePrivate));
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+gdm_display_access_file_init (GdmDisplayAccessFile *access_file)
|
||||
+{
|
||||
+ access_file->priv = G_TYPE_INSTANCE_GET_PRIVATE (access_file,
|
||||
+ GDM_TYPE_DISPLAY_ACCESS_FILE,
|
||||
+ GdmDisplayAccessFilePrivate);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+gdm_display_access_file_finalize (GObject *object)
|
||||
+{
|
||||
+ GdmDisplayAccessFile *file;
|
||||
+ GObjectClass *parent_class;
|
||||
+
|
||||
+ file = GDM_DISPLAY_ACCESS_FILE (object);
|
||||
+ parent_class = G_OBJECT_CLASS (gdm_display_access_file_parent_class);
|
||||
+
|
||||
+ if (file->priv->fp != NULL) {
|
||||
+ gdm_display_access_file_close (file);
|
||||
+ }
|
||||
+ g_assert (file->priv->path == NULL);
|
||||
+
|
||||
+ if (file->priv->username != NULL) {
|
||||
+ g_free (file->priv->username);
|
||||
+ file->priv->username = NULL;
|
||||
+ g_object_notify (object, "username");
|
||||
+ }
|
||||
+
|
||||
+ if (parent_class->finalize != NULL) {
|
||||
+ parent_class->finalize (object);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+GQuark
|
||||
+gdm_display_access_file_error_quark (void)
|
||||
+{
|
||||
+ static GQuark error_quark = 0;
|
||||
+
|
||||
+ if (error_quark == 0) {
|
||||
+ error_quark = g_quark_from_static_string ("gdm-display-access-file");
|
||||
+ }
|
||||
+
|
||||
+ return error_quark;
|
||||
+}
|
||||
+
|
||||
+GdmDisplayAccessFile *
|
||||
+gdm_display_access_file_new (const char *username)
|
||||
+{
|
||||
+ GdmDisplayAccessFile *access_file;
|
||||
+ g_return_val_if_fail (username != NULL, NULL);
|
||||
+
|
||||
+ access_file = g_object_new (GDM_TYPE_DISPLAY_ACCESS_FILE,
|
||||
+ "username", username, NULL);
|
||||
+
|
||||
+ return access_file;
|
||||
+}
|
||||
+
|
||||
+static gboolean
|
||||
+_get_uid_and_gid_for_user (const char *username,
|
||||
+ uid_t *uid,
|
||||
+ gid_t *gid)
|
||||
+{
|
||||
+ struct passwd *passwd_entry;
|
||||
+
|
||||
+ g_assert (username != NULL);
|
||||
+ g_assert (uid != NULL);
|
||||
+ g_assert (gid != NULL);
|
||||
+
|
||||
+ errno = 0;
|
||||
+ passwd_entry = getpwnam (username);
|
||||
+
|
||||
+ if (passwd_entry == NULL) {
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
+ *uid = passwd_entry->pw_uid;
|
||||
+ *gid = passwd_entry->pw_gid;
|
||||
+
|
||||
+ return TRUE;
|
||||
+}
|
||||
+
|
||||
+static FILE *
|
||||
+_create_xauth_file_for_user (const char *username,
|
||||
+ char **filename,
|
||||
+ GError **error)
|
||||
+{
|
||||
+ char *template;
|
||||
+ GError *open_error;
|
||||
+ int fd;
|
||||
+ FILE *fp;
|
||||
+ uid_t uid;
|
||||
+ gid_t gid;
|
||||
+
|
||||
+ template = g_strdup_printf (".gdm-xauth-%s.XXXXXX", username);
|
||||
+
|
||||
+ open_error = NULL;
|
||||
+ fd = g_file_open_tmp (template, filename, &open_error);
|
||||
+ g_free (template);
|
||||
+
|
||||
+ if (fd < 0) {
|
||||
+ g_propagate_error (error, open_error);
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ if (!_get_uid_and_gid_for_user (username, &uid, &gid)) {
|
||||
+ g_set_error (error,
|
||||
+ GDM_DISPLAY_ERROR,
|
||||
+ GDM_DISPLAY_ERROR_GETTING_USER_INFO,
|
||||
+ _("could not find user \"%s\" on system"),
|
||||
+ username);
|
||||
+ close (fd);
|
||||
+ fd = -1;
|
||||
+ goto out;
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ if (fchown (fd, uid, gid) < 0) {
|
||||
+ g_set_error (error,
|
||||
+ G_FILE_ERROR,
|
||||
+ g_file_error_from_errno (errno),
|
||||
+ "%s", g_strerror (errno));
|
||||
+ close (fd);
|
||||
+ fd = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ fp = fdopen (fd, "w");
|
||||
+
|
||||
+ if (fp == NULL) {
|
||||
+ g_set_error (error,
|
||||
+ G_FILE_ERROR,
|
||||
+ g_file_error_from_errno (errno),
|
||||
+ "%s", g_strerror (errno));
|
||||
+ close (fd);
|
||||
+ fd = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
+out:
|
||||
+ return fp;
|
||||
+}
|
||||
+
|
||||
+gboolean
|
||||
+gdm_display_access_file_open (GdmDisplayAccessFile *file,
|
||||
+ GError **error)
|
||||
+{
|
||||
+ GError *create_error;
|
||||
+
|
||||
+ g_return_val_if_fail (file != NULL, FALSE);
|
||||
+ g_return_val_if_fail (file->priv->fp == NULL, FALSE);
|
||||
+ g_return_val_if_fail (file->priv->path == NULL, FALSE);
|
||||
+
|
||||
+ create_error = NULL;
|
||||
+ file->priv->fp = _create_xauth_file_for_user (file->priv->username,
|
||||
+ &file->priv->path,
|
||||
+ &create_error);
|
||||
+
|
||||
+ if (file->priv->fp == NULL) {
|
||||
+ g_propagate_error (error, create_error);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
+ return TRUE;
|
||||
+}
|
||||
+
|
||||
+static char *
|
||||
+_generate_random_bytes (gsize size)
|
||||
+{
|
||||
+ char *bytes;
|
||||
+ int i;
|
||||
+
|
||||
+ bytes = g_malloc (size);
|
||||
+
|
||||
+ for (i = 0; i < size; i++) {
|
||||
+ guint8 byte;
|
||||
+
|
||||
+ byte = (guint8) g_random_int_range (0, G_MAXUINT8);
|
||||
+
|
||||
+ bytes[i] = (char) byte;
|
||||
+ }
|
||||
+
|
||||
+ return bytes;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+_get_auth_info_for_display (GdmDisplayAccessFile *file,
|
||||
+ GdmDisplay *display,
|
||||
+ unsigned short *family,
|
||||
+ unsigned short *address_length,
|
||||
+ char **address,
|
||||
+ unsigned short *number_length,
|
||||
+ char **number,
|
||||
+ unsigned short *name_length,
|
||||
+ char **name)
|
||||
+{
|
||||
+ int display_number;
|
||||
+ gboolean is_local;
|
||||
+
|
||||
+ gdm_display_is_local (display, &is_local, NULL);
|
||||
+
|
||||
+ if (is_local) {
|
||||
+ *family = FamilyLocal;
|
||||
+ *address = g_strdup (g_get_host_name ());
|
||||
+ } else {
|
||||
+ *family = FamilyWild;
|
||||
+ gdm_display_get_remote_hostname (display, address, NULL);
|
||||
+ }
|
||||
+ *address_length = strlen (*address);
|
||||
+
|
||||
+ gdm_display_get_x11_display_number (display, &display_number, NULL);
|
||||
+ *number = g_strdup_printf ("%d", display_number);
|
||||
+ *number_length = strlen (*number);
|
||||
+
|
||||
+ *name = g_strdup ("MIT-MAGIC-COOKIE-1");
|
||||
+ *name_length = strlen (*name);
|
||||
+}
|
||||
+
|
||||
+gboolean
|
||||
+gdm_display_access_file_add_display (GdmDisplayAccessFile *file,
|
||||
+ GdmDisplay *display,
|
||||
+ char **cookie,
|
||||
+ gsize *cookie_size,
|
||||
+ GError **error)
|
||||
+{
|
||||
+ GError *add_error;
|
||||
+ gboolean display_added;
|
||||
+
|
||||
+ g_return_val_if_fail (file != NULL, FALSE);
|
||||
+ g_return_val_if_fail (file->priv->path != NULL, FALSE);
|
||||
+ g_return_val_if_fail (cookie != NULL, FALSE);
|
||||
+
|
||||
+ *cookie = _generate_random_bytes (GDM_DISPLAY_ACCESS_COOKIE_SIZE);
|
||||
+ *cookie_size = GDM_DISPLAY_ACCESS_COOKIE_SIZE;
|
||||
+
|
||||
+ add_error = NULL;
|
||||
+ display_added =
|
||||
+ gdm_display_access_file_add_display_with_cookie (file, display,
|
||||
+ *cookie,
|
||||
+ *cookie_size,
|
||||
+ &add_error);
|
||||
+ if (!display_added) {
|
||||
+ g_free (*cookie);
|
||||
+ *cookie = NULL;
|
||||
+ g_propagate_error (error, add_error);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
+ return TRUE;
|
||||
+}
|
||||
+
|
||||
+gboolean
|
||||
+gdm_display_access_file_add_display_with_cookie (GdmDisplayAccessFile *file,
|
||||
+ GdmDisplay *display,
|
||||
+ const char *cookie,
|
||||
+ gsize cookie_size,
|
||||
+ GError **error)
|
||||
+{
|
||||
+ Xauth auth_entry;
|
||||
+ gboolean display_added;
|
||||
+
|
||||
+ g_return_val_if_fail (file != NULL, FALSE);
|
||||
+ g_return_val_if_fail (file->priv->path != NULL, FALSE);
|
||||
+ g_return_val_if_fail (cookie != NULL, FALSE);
|
||||
+
|
||||
+ _get_auth_info_for_display (file, display,
|
||||
+ &auth_entry.family,
|
||||
+ &auth_entry.address_length,
|
||||
+ &auth_entry.address,
|
||||
+ &auth_entry.number_length,
|
||||
+ &auth_entry.number,
|
||||
+ &auth_entry.name_length,
|
||||
+ &auth_entry.name);
|
||||
+
|
||||
+ auth_entry.data = (char *) cookie;
|
||||
+ auth_entry.data_length = cookie_size;
|
||||
+
|
||||
+ /* FIXME: We should lock the file in case the X server is
|
||||
+ * trying to use it, too.
|
||||
+ */
|
||||
+ if (!XauWriteAuth (file->priv->fp, &auth_entry)
|
||||
+ || fflush (file->priv->fp) == EOF) {
|
||||
+ g_set_error (error,
|
||||
+ G_FILE_ERROR,
|
||||
+ g_file_error_from_errno (errno),
|
||||
+ "%s", g_strerror (errno));
|
||||
+ display_added = FALSE;
|
||||
+ } else {
|
||||
+ display_added = TRUE;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ g_free (auth_entry.address);
|
||||
+ g_free (auth_entry.number);
|
||||
+ g_free (auth_entry.name);
|
||||
+
|
||||
+ return display_added;
|
||||
+}
|
||||
+
|
||||
+gboolean
|
||||
+gdm_display_access_file_remove_display (GdmDisplayAccessFile *file,
|
||||
+ GdmDisplay *display,
|
||||
+ GError **error)
|
||||
+{
|
||||
+ Xauth *auth_entry;
|
||||
+ unsigned short family;
|
||||
+ unsigned short address_length;
|
||||
+ char *address;
|
||||
+ unsigned short number_length;
|
||||
+ char *number;
|
||||
+ unsigned short name_length;
|
||||
+ char *name;
|
||||
+
|
||||
+
|
||||
+ g_return_val_if_fail (file != NULL, FALSE);
|
||||
+ g_return_val_if_fail (file->priv->path != NULL, FALSE);
|
||||
+
|
||||
+ _get_auth_info_for_display (file, display,
|
||||
+ &family,
|
||||
+ &address_length,
|
||||
+ &address,
|
||||
+ &number_length,
|
||||
+ &number,
|
||||
+ &name_length,
|
||||
+ &name);
|
||||
+
|
||||
+ auth_entry = XauGetAuthByAddr (family,
|
||||
+ address_length,
|
||||
+ address,
|
||||
+ number_length,
|
||||
+ number,
|
||||
+ name_length,
|
||||
+ name);
|
||||
+ g_free (address);
|
||||
+ g_free (number);
|
||||
+ g_free (name);
|
||||
+
|
||||
+ if (auth_entry == NULL) {
|
||||
+ g_set_error (error,
|
||||
+ GDM_DISPLAY_ACCESS_FILE_ERROR,
|
||||
+ GDM_DISPLAY_ACCESS_FILE_ERROR_FINDING_AUTH_ENTRY,
|
||||
+ "could not find authorization entry");
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
+ XauDisposeAuth (auth_entry);
|
||||
+
|
||||
+ if (fflush (file->priv->fp) == EOF) {
|
||||
+ g_set_error (error,
|
||||
+ G_FILE_ERROR,
|
||||
+ g_file_error_from_errno (errno),
|
||||
+ "%s", g_strerror (errno));
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
+ return TRUE;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+gdm_display_access_file_close (GdmDisplayAccessFile *file)
|
||||
+{
|
||||
+ g_return_if_fail (file != NULL);
|
||||
+ g_return_if_fail (file->priv->fp != NULL);
|
||||
+ g_return_if_fail (file->priv->path != NULL);
|
||||
+
|
||||
+ g_unlink (file->priv->path);
|
||||
+ if (file->priv->path != NULL) {
|
||||
+ g_free (file->priv->path);
|
||||
+ file->priv->path = NULL;
|
||||
+ g_object_notify (G_OBJECT (file), "path");
|
||||
+ }
|
||||
+
|
||||
+ fclose (file->priv->fp);
|
||||
+ file->priv->fp = NULL;
|
||||
+}
|
||||
+
|
||||
+char *
|
||||
+gdm_display_access_file_get_path (GdmDisplayAccessFile *access_file)
|
||||
+{
|
||||
+ return g_strdup (access_file->priv->path);
|
||||
+}
|
||||
Index: daemon/gdm-display-access-file.h
|
||||
===================================================================
|
||||
--- daemon/gdm-display-access-file.h (revision 0)
|
||||
+++ daemon/gdm-display-access-file.h (revision 0)
|
||||
@@ -0,0 +1,86 @@
|
||||
+/* gdm-display-access-file.h - Abstraction around xauth cookies
|
||||
+ *
|
||||
+ * Copyright (C) 2007 Ray Strode <rstrode@redhat.com>
|
||||
+ *
|
||||
+ * Written by Ray Strode <rstrode@redhat.com>
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License as published by
|
||||
+ * the Free Software Foundation; either version 2, or (at your option)
|
||||
+ * any later version.
|
||||
+ *
|
||||
+ * This program is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+ * GNU General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU General Public License
|
||||
+ * along with this program; if not, write to the Free Software
|
||||
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
+ * 02111-1307, USA.
|
||||
+ */
|
||||
+#ifndef __GDM_DISPLAY_ACCESS_FILE_H__
|
||||
+#define __GDM_DISPLAY_ACCESS_FILE_H__
|
||||
+
|
||||
+#include <glib.h>
|
||||
+#include <glib-object.h>
|
||||
+
|
||||
+#include "gdm-display.h"
|
||||
+
|
||||
+G_BEGIN_DECLS
|
||||
+#define GDM_TYPE_DISPLAY_ACCESS_FILE (gdm_display_access_file_get_type ())
|
||||
+#define GDM_DISPLAY_ACCESS_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDM_TYPE_DISPLAY_ACCESS_FILE, GdmDisplayAccessFile))
|
||||
+#define GDM_DISPLAY_ACCESS_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDM_TYPE_DISPLAY_ACCESS_FILE, GdmDisplayAccessFileClass))
|
||||
+#define GDM_IS_DISPLAY_ACCESS_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDM_TYPE_DISPLAY_ACCESS_FILE))
|
||||
+#define GDM_IS_DISPLAY_ACCESS_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDM_TYPE_DISPLAY_ACCESS_FILE))
|
||||
+#define GDM_DISPLAY_ACCESS_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GDM_TYPE_DISPLAY_ACCESS_FILE, GdmDisplayAccessFileClass))
|
||||
+#define GDM_DISPLAY_ACCESS_FILE_ERROR (gdm_display_access_file_error_quark ())
|
||||
+
|
||||
+typedef struct _GdmDisplayAccessFile GdmDisplayAccessFile;
|
||||
+typedef struct _GdmDisplayAccessFileClass GdmDisplayAccessFileClass;
|
||||
+typedef struct _GdmDisplayAccessFilePrivate GdmDisplayAccessFilePrivate;
|
||||
+typedef enum _GdmDisplayAccessFileError GdmDisplayAccessFileError;
|
||||
+
|
||||
+struct _GdmDisplayAccessFile
|
||||
+{
|
||||
+ GObject parent;
|
||||
+
|
||||
+ GdmDisplayAccessFilePrivate *priv;
|
||||
+};
|
||||
+
|
||||
+struct _GdmDisplayAccessFileClass
|
||||
+{
|
||||
+ GObjectClass parent_class;
|
||||
+};
|
||||
+
|
||||
+enum _GdmDisplayAccessFileError
|
||||
+{
|
||||
+ GDM_DISPLAY_ACCESS_FILE_ERROR_GENERAL = 0,
|
||||
+ GDM_DISPLAY_ACCESS_FILE_ERROR_FINDING_AUTH_ENTRY
|
||||
+};
|
||||
+
|
||||
+GQuark gdm_display_access_file_error_quark (void);
|
||||
+GType gdm_display_access_file_get_type (void);
|
||||
+
|
||||
+GdmDisplayAccessFile *gdm_display_access_file_new (const char *username);
|
||||
+gboolean gdm_display_access_file_open (GdmDisplayAccessFile *file,
|
||||
+ GError **error);
|
||||
+gboolean gdm_display_access_file_add_display (GdmDisplayAccessFile *file,
|
||||
+ GdmDisplay *display,
|
||||
+ char **cookie,
|
||||
+ gsize *cookie_size,
|
||||
+ GError **error);
|
||||
+gboolean gdm_display_access_file_add_display_with_cookie (GdmDisplayAccessFile *file,
|
||||
+ GdmDisplay *display,
|
||||
+ const char *cookie,
|
||||
+ gsize cookie_size,
|
||||
+ GError **error);
|
||||
+gboolean gdm_display_access_file_remove_display (GdmDisplayAccessFile *file,
|
||||
+ GdmDisplay *display,
|
||||
+ GError **error);
|
||||
+
|
||||
+void gdm_display_access_file_close (GdmDisplayAccessFile *file);
|
||||
+char *gdm_display_access_file_get_path (GdmDisplayAccessFile *file);
|
||||
+
|
||||
+G_END_DECLS
|
||||
+#endif /* __GDM_DISPLAY_ACCESS_FILE_H__ */
|
||||
Index: daemon/gdm-display.c
|
||||
===================================================================
|
||||
--- daemon/gdm-display.c (revision 5497)
|
||||
--- daemon/gdm-display.c (revision 5498)
|
||||
+++ daemon/gdm-display.c (working copy)
|
||||
@@ -35,11 +35,10 @@
|
||||
|
||||
@ -1208,9 +1810,31 @@ Index: daemon/gdm-display.c
|
||||
+
|
||||
G_OBJECT_CLASS (gdm_display_parent_class)->finalize (object);
|
||||
}
|
||||
Index: daemon/gdm-display.h
|
||||
===================================================================
|
||||
--- daemon/gdm-display.h (revision 5498)
|
||||
+++ daemon/gdm-display.h (working copy)
|
||||
@@ -69,7 +69,8 @@ typedef struct
|
||||
|
||||
typedef enum
|
||||
{
|
||||
- GDM_DISPLAY_ERROR_GENERAL
|
||||
+ GDM_DISPLAY_ERROR_GENERAL,
|
||||
+ GDM_DISPLAY_ERROR_GETTING_USER_INFO
|
||||
} GdmDisplayError;
|
||||
|
||||
#define GDM_DISPLAY_ERROR gdm_display_error_quark ()
|
||||
@@ -107,6 +108,7 @@ gboolean gdm_display_is_local
|
||||
/* exported but protected */
|
||||
gboolean gdm_display_get_x11_cookie (GdmDisplay *display,
|
||||
char **x11_cookie,
|
||||
+ gsize *cookie_size,
|
||||
GError **error);
|
||||
gboolean gdm_display_get_x11_authority_file (GdmDisplay *display,
|
||||
char **filename,
|
||||
Index: daemon/gdm-manager.c
|
||||
===================================================================
|
||||
--- daemon/gdm-manager.c (revision 5497)
|
||||
--- daemon/gdm-manager.c (revision 5498)
|
||||
+++ daemon/gdm-manager.c (working copy)
|
||||
@@ -60,7 +60,6 @@ struct GdmManagerPrivate
|
||||
|
||||
@ -1279,31 +1903,9 @@ Index: daemon/gdm-manager.c
|
||||
G_OBJECT_CLASS (gdm_manager_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
Index: daemon/gdm-display.h
|
||||
===================================================================
|
||||
--- daemon/gdm-display.h (revision 5497)
|
||||
+++ daemon/gdm-display.h (working copy)
|
||||
@@ -69,7 +69,8 @@ typedef struct
|
||||
|
||||
typedef enum
|
||||
{
|
||||
- GDM_DISPLAY_ERROR_GENERAL
|
||||
+ GDM_DISPLAY_ERROR_GENERAL,
|
||||
+ GDM_DISPLAY_ERROR_GETTING_USER_INFO
|
||||
} GdmDisplayError;
|
||||
|
||||
#define GDM_DISPLAY_ERROR gdm_display_error_quark ()
|
||||
@@ -107,6 +108,7 @@ gboolean gdm_display_is_local
|
||||
/* exported but protected */
|
||||
gboolean gdm_display_get_x11_cookie (GdmDisplay *display,
|
||||
char **x11_cookie,
|
||||
+ gsize *cookie_size,
|
||||
GError **error);
|
||||
gboolean gdm_display_get_x11_authority_file (GdmDisplay *display,
|
||||
char **filename,
|
||||
Index: daemon/gdm-factory-slave.c
|
||||
===================================================================
|
||||
--- daemon/gdm-factory-slave.c (revision 5497)
|
||||
--- daemon/gdm-factory-slave.c (revision 5498)
|
||||
+++ daemon/gdm-factory-slave.c (working copy)
|
||||
@@ -565,11 +565,13 @@ static gboolean
|
||||
gdm_factory_slave_run (GdmFactorySlave *slave)
|
||||
@ -1338,7 +1940,7 @@ Index: daemon/gdm-factory-slave.c
|
||||
}
|
||||
Index: daemon/gdm-static-display.c
|
||||
===================================================================
|
||||
--- daemon/gdm-static-display.c (revision 5497)
|
||||
--- daemon/gdm-static-display.c (revision 5498)
|
||||
+++ daemon/gdm-static-display.c (working copy)
|
||||
@@ -20,9 +20,11 @@
|
||||
|
||||
@ -1380,7 +1982,7 @@ Index: daemon/gdm-static-display.c
|
||||
static gboolean
|
||||
Index: daemon/gdm-simple-slave.c
|
||||
===================================================================
|
||||
--- daemon/gdm-simple-slave.c (revision 5497)
|
||||
--- daemon/gdm-simple-slave.c (revision 5498)
|
||||
+++ daemon/gdm-simple-slave.c (working copy)
|
||||
@@ -680,11 +680,13 @@ static gboolean
|
||||
gdm_simple_slave_run (GdmSimpleSlave *slave)
|
||||
@ -1415,7 +2017,7 @@ Index: daemon/gdm-simple-slave.c
|
||||
}
|
||||
Index: daemon/gdm-xdmcp-display-factory.c
|
||||
===================================================================
|
||||
--- daemon/gdm-xdmcp-display-factory.c (revision 5497)
|
||||
--- daemon/gdm-xdmcp-display-factory.c (revision 5498)
|
||||
+++ daemon/gdm-xdmcp-display-factory.c (working copy)
|
||||
@@ -57,8 +57,6 @@
|
||||
#include "gdm-xdmcp-display-factory.h"
|
||||
@ -1523,7 +2125,7 @@ Index: daemon/gdm-xdmcp-display-factory.c
|
||||
} else {
|
||||
Index: daemon/Makefile.am
|
||||
===================================================================
|
||||
--- daemon/Makefile.am (revision 5497)
|
||||
--- daemon/Makefile.am (revision 5498)
|
||||
+++ daemon/Makefile.am (working copy)
|
||||
@@ -125,8 +125,6 @@ gdm_simple_slave_SOURCES = \
|
||||
gdm-slave.h \
|
||||
|
Loading…
Reference in New Issue
Block a user