[gdm] If the user's .dmrc file specifies the "custom" session, then accept it even if there is no correspo



commit 9d895d874b815d800df32da6e7fde4fe31fc7fd3
Author: Brian Cameron <Brian Cameron sun com>
Date:   Wed Jun 9 15:36:33 2010 -0500

    If the user's .dmrc file specifies the "custom" session, then accept it
    even if there is no corresponding desktop file since it has special meaning
    to the /etc/gdm/Xsession script for launching $HOME/.xsession.  Fixes bug
    619129.

 common/gdm-common.h                    |    2 ++
 daemon/gdm-session-direct.c            |   24 +++++++++++++++---------
 gui/simple-greeter/gdm-greeter-panel.c |   13 +++++++++++--
 3 files changed, 28 insertions(+), 11 deletions(-)
---
diff --git a/common/gdm-common.h b/common/gdm-common.h
index 191bd70..1983cff 100644
--- a/common/gdm-common.h
+++ b/common/gdm-common.h
@@ -25,6 +25,8 @@
 
 #include "gdm-common-unknown-origin.h"
 
+#define GDM_CUSTOM_SESSION  "custom"
+
 G_BEGIN_DECLS
 
 gboolean       gdm_is_version_unstable            (void);
diff --git a/daemon/gdm-session-direct.c b/daemon/gdm-session-direct.c
index 7d5b560..eb0fce6 100644
--- a/daemon/gdm-session-direct.c
+++ b/daemon/gdm-session-direct.c
@@ -583,11 +583,22 @@ get_session_command_for_name (const char *name,
         char    *filename;
 
         filename = g_strdup_printf ("%s.desktop", name);
-
-        command = NULL;
         res = get_session_command_for_file (filename, command);
         g_free (filename);
 
+        /*
+         * The GDM Xsession script honors "custom" as a valid session.  If the
+         * session is one of these, no file is needed, then just run the
+         * command as "custom".
+         */
+        if (!res && strcmp (name, GDM_CUSTOM_SESSION) == 0) {
+                g_debug ("No custom desktop file, but accepting it anyway.");
+                if (command != NULL) {
+                        *command = g_strdup (GDM_CUSTOM_SESSION);
+                }
+                res = TRUE;
+        }
+
         return res;
 }
 
@@ -1998,18 +2009,13 @@ get_session_command (GdmSessionDirect *session)
 {
         gboolean res;
         char    *command;
-        char    *filename;
-
-        filename = g_strdup_printf ("%s.desktop", get_session_name (session));
 
         command = NULL;
-        res = get_session_command_for_file (filename, &command);
+        res = get_session_command_for_name (get_session_name (session), &command);
         if (! res) {
-                g_critical ("Cannot read specified session file: %s", filename);
-                g_free (filename);
+                g_critical ("Cannot read specified session file: %s.desktop", session);
                 exit (1);
         }
-        g_free (filename);
 
         return command;
 }
diff --git a/gui/simple-greeter/gdm-greeter-panel.c b/gui/simple-greeter/gdm-greeter-panel.c
index b46378d..89f2cb5 100644
--- a/gui/simple-greeter/gdm-greeter-panel.c
+++ b/gui/simple-greeter/gdm-greeter-panel.c
@@ -53,6 +53,7 @@
 #include "gdm-session-option-widget.h"
 #include "gdm-timer.h"
 #include "gdm-profile.h"
+#include "gdm-common.h"
 
 #include "na-tray.h"
 
@@ -1120,8 +1121,16 @@ gdm_greeter_panel_set_default_session_name (GdmGreeterPanel *panel,
         if (session_name != NULL &&
             !gdm_option_widget_lookup_item (GDM_OPTION_WIDGET (panel->priv->session_option_widget),
                                             session_name, NULL, NULL, NULL)) {
-                g_warning ("Default session is not available");
-                return;
+                if (strcmp (session_name, GDM_CUSTOM_SESSION) == 0) {
+                        gdm_option_widget_add_item (GDM_OPTION_WIDGET (panel->priv->session_option_widget),
+                                                    GDM_CUSTOM_SESSION,
+                                                    C_("customsession", "Custom"),
+                                                    _("Custom session"),
+                                                    GDM_OPTION_WIDGET_POSITION_TOP);
+                } else {
+                        g_warning ("Default session is not available");
+                        return;
+                }
         }
 
         gdm_option_widget_set_default_item (GDM_OPTION_WIDGET (panel->priv->session_option_widget),



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