[gdm] Fix bug #594818 so that each GDM session has separate GConf settings. This way when a user enables o



commit 8227511c753eb44033703bfa8e0f41ca9b2cc767
Author: Brian Cameron <Brian Cameron sun com>
Date:   Tue May 11 17:52:47 2010 -0500

    Fix bug #594818 so that each GDM session has separate GConf settings.
    This way when a user enables or kills at AT program it will only start or
    exit on the display where the user made the request, and not on all
    displays.

 configure.ac                 |    5 ++++-
 daemon/gdm-welcome-session.c |   42 +++++++++++++++++++++++++++++++++++++++---
 data/gconf.path              |    4 ++++
 3 files changed, 47 insertions(+), 4 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 617c05b..0674a92 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,7 +44,7 @@ GLIB_REQUIRED_VERSION=2.22.0
 GTK_REQUIRED_VERSION=2.20.0
 PANGO_REQUIRED_VERSION=1.3.0
 SCROLLKEEPER_REQUIRED_VERSION=0.1.4
-GCONF_REQUIRED_VERSION=2.6.1
+GCONF_REQUIRED_VERSION=2.31.3
 GNOME_PANEL_REQUIRED_VERSION=2.0.0
 LIBXKLAVIER_REQUIRED_VERSION=4.0
 LIBCANBERRA_GTK_REQUIRED_VERSION=0.4
@@ -103,6 +103,9 @@ PKG_CHECK_MODULES(GCONF,
 AC_SUBST(GCONF_CFLAGS)
 AC_SUBST(GCONF_LIBS)
 
+gconf_defaultpath=`pkg-config gconf-2.0 --variable=gconf_defaultpath`
+AC_DEFINE_UNQUOTED([GCONF_DEFAULTPATH], "$gconf_defaultpath", [GConf Default Path])
+
 PKG_CHECK_MODULES(DEVKIT_POWER,
         devkit-power-gobject >= $DEVKIT_POWER_REQUIRED_VERSION,
         have_devicekit_power=yes,
diff --git a/daemon/gdm-welcome-session.c b/daemon/gdm-welcome-session.c
index 0a6487a..0ef5c5a 100644
--- a/daemon/gdm-welcome-session.c
+++ b/daemon/gdm-welcome-session.c
@@ -341,7 +341,7 @@ next_line:
 }
 
 static GPtrArray *
-get_welcome_environment (GdmWelcomeSession *welcome_session)
+get_welcome_environment (GdmWelcomeSession *welcome_session, gboolean start_session)
 {
         GPtrArray     *env;
         GHashTable    *hash;
@@ -420,6 +420,15 @@ get_welcome_environment (GdmWelcomeSession *welcome_session)
                 g_hash_table_insert (hash, g_strdup ("SHELL"), g_strdup (pwent->pw_shell));
         }
 
+        if (start_session && welcome_session->priv->x11_display_seat_id != NULL) {
+                char *seat_id;
+
+                seat_id = welcome_session->priv->x11_display_seat_id +
+                        strlen ("/org/freedesktop/ConsoleKit/");
+
+                g_hash_table_insert (hash, g_strdup ("GCONF_DEFAULT_SOURCE_PATH"), g_strdup (GCONF_DEFAULTPATH));
+                g_hash_table_insert (hash, g_strdup ("GDM_SEAT_ID"), g_strdup (seat_id));
+        }
 
         g_hash_table_insert (hash, g_strdup ("PATH"), g_strdup (g_getenv ("PATH")));
         g_hash_table_insert (hash, g_strdup ("WINDOWPATH"), g_strdup (g_getenv ("WINDOWPATH")));
@@ -515,6 +524,7 @@ typedef struct {
         const char *group_name;
         const char *runtime_dir;
         const char *log_file;
+        const char *seat_id;
 } SpawnChildData;
 
 static void
@@ -541,6 +551,26 @@ spawn_child_setup (SpawnChildData *data)
                 _exit (1);
         }
 
+        if (pwent->pw_dir != NULL) {
+                struct stat statbuf;
+                const char *seat_id;
+                char       *gconf_dir;
+                int         r;
+
+                seat_id = data->seat_id + strlen ("/org/freedesktop/ConsoleKit/");
+                gconf_dir = g_strdup_printf ("%s/%s", pwent->pw_dir, seat_id);
+
+                /* Verify per-seat gconf directory exists, create if needed */
+                r = g_stat (gconf_dir, &statbuf);
+                if (r < 0) {
+                        g_debug ("Making per-seat gconf directory %s", gconf_dir);
+                        g_mkdir (gconf_dir, S_IRWXU | S_IXGRP | S_IRGRP);
+                        g_chmod (gconf_dir, S_IRWXU | S_IXGRP | S_IRGRP);
+                        chown (gconf_dir, pwent->pw_uid, grent->gr_gid);
+                }
+                g_free (gconf_dir);
+        }
+
         g_debug ("GdmWelcomeSession: Setting up run time dir %s", data->runtime_dir);
         g_mkdir (data->runtime_dir, 0755);
         chown (data->runtime_dir, pwent->pw_uid, pwent->pw_gid);
@@ -606,6 +636,7 @@ static gboolean
 spawn_command_line_sync_as_user (const char *command_line,
                                  const char *user_name,
                                  const char *group_name,
+                                 const char *seat_id,
                                  const char *runtime_dir,
                                  const char *log_file,
                                  char       **env,
@@ -634,6 +665,7 @@ spawn_command_line_sync_as_user (const char *command_line,
         data.group_name = group_name;
         data.runtime_dir = runtime_dir;
         data.log_file = log_file;
+        data.seat_id = seat_id;
 
         local_error = NULL;
         res = g_spawn_sync (NULL,
@@ -664,6 +696,7 @@ static gboolean
 spawn_command_line_async_as_user (const char *command_line,
                                   const char *user_name,
                                   const char *group_name,
+                                  const char *seat_id,
                                   const char *runtime_dir,
                                   const char *log_file,
                                   char      **env,
@@ -690,6 +723,7 @@ spawn_command_line_async_as_user (const char *command_line,
         data.group_name = group_name;
         data.runtime_dir = runtime_dir;
         data.log_file = log_file;
+        data.seat_id = seat_id;
 
         local_error = NULL;
         res = g_spawn_async (NULL,
@@ -802,12 +836,13 @@ start_dbus_daemon (GdmWelcomeSession *welcome_session)
 
         g_debug ("GdmWelcomeSession: Starting D-Bus daemon");
 
-        env = get_welcome_environment (welcome_session);
+        env = get_welcome_environment (welcome_session, FALSE);
 
         error = NULL;
         res = spawn_command_line_sync_as_user (DBUS_LAUNCH_COMMAND,
                                                welcome_session->priv->user_name,
                                                welcome_session->priv->group_name,
+                                               welcome_session->priv->x11_display_seat_id,
                                                welcome_session->priv->runtime_dir,
                                                NULL, /* log file */
                                                (char **)env->pdata,
@@ -860,7 +895,7 @@ gdm_welcome_session_spawn (GdmWelcomeSession *welcome_session)
                 /* FIXME: */
         }
 
-        env = get_welcome_environment (welcome_session);
+        env = get_welcome_environment (welcome_session, TRUE);
 
         error = NULL;
 
@@ -871,6 +906,7 @@ gdm_welcome_session_spawn (GdmWelcomeSession *welcome_session)
         ret = spawn_command_line_async_as_user (welcome_session->priv->command,
                                                 welcome_session->priv->user_name,
                                                 welcome_session->priv->group_name,
+                                                welcome_session->priv->x11_display_seat_id,
                                                 welcome_session->priv->runtime_dir,
                                                 log_path,
                                                 (char **)env->pdata,
diff --git a/data/gconf.path b/data/gconf.path
index beaa55a..b195a3a 100644
--- a/data/gconf.path
+++ b/data/gconf.path
@@ -6,3 +6,7 @@ xml:readonly:/etc/gconf/gconf.xml.system
 # owned by GDM.  Sysadmins should create
 # another source if they wish to override them.
 xml:readonly:$(HOME)/.gconf.mandatory
+
+# Set per-seat configuration directory
+xml:readwrite:$(HOME)/$(ENV_GDM_SEAT_ID)/.gconf
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]