[gdm] Allow session scripts to bypass Xsession launcher



commit b01a179507aa08d65a57109e5418a7c240ff324f
Author: Niall Power <niall power sun com>
Date:   Wed Nov 18 17:07:37 2009 -0500

    Allow session scripts to bypass Xsession launcher
    
    It is occasionally useful to launch sessions that aren't
    run through Xsession.  This is good, for starting a bare xterm
    session for instance.
    
    We now allow a session to specify that it shouldn't be run through
    the Xsession script with the key file entry:
    
    X-GDM-BypassXsession=true

 daemon/gdm-session-direct.c |   57 ++++++++++++++++++++++++++++++++++++++++++-
 daemon/gdm-session-direct.h |    1 +
 daemon/gdm-simple-slave.c   |    6 ++++-
 3 files changed, 62 insertions(+), 2 deletions(-)
---
diff --git a/daemon/gdm-session-direct.c b/daemon/gdm-session-direct.c
index 8eadf4d..e758c5d 100644
--- a/daemon/gdm-session-direct.c
+++ b/daemon/gdm-session-direct.c
@@ -1972,7 +1972,13 @@ gdm_session_direct_start_session (GdmSession *session)
         g_return_if_fail (impl->priv->is_running == FALSE);
 
         command = get_session_command (impl);
-        program = g_strdup_printf (GDMCONFDIR "/Xsession \"%s\"", command);
+
+        if (gdm_session_direct_bypasses_xsession (impl)) {
+                program = g_strdup (command);
+        } else {
+                program = g_strdup_printf (GDMCONFDIR "/Xsession \"%s\"", command);
+        }
+
         g_free (command);
 
         setup_session_environment (impl);
@@ -2062,6 +2068,55 @@ gdm_session_direct_get_username (GdmSessionDirect *session)
         return g_strdup (session->priv->selected_user);
 }
 
+gboolean
+gdm_session_direct_bypasses_xsession (GdmSessionDirect *session_direct)
+{
+        GError     *error;
+        GKeyFile   *key_file;
+        gboolean    res;
+        gboolean    bypasses_xsession = FALSE;
+        char       *filename;
+        char       *full_path;
+
+        g_return_val_if_fail (session_direct != NULL, FALSE);
+        g_return_val_if_fail (GDM_IS_SESSION_DIRECT (session_direct), FALSE);
+
+        filename = g_strdup_printf ("%s.desktop", get_session_name (session_direct));
+
+        key_file = g_key_file_new ();
+        error = NULL;
+        res = g_key_file_load_from_dirs (key_file,
+                                         filename,
+                                         get_system_session_dirs (),
+                                         &full_path,
+                                         G_KEY_FILE_NONE,
+                                         &error);
+        if (! res) {
+                g_debug ("GdmSessionDirect: File '%s' not found: %s", filename, error->message);
+                goto out;
+        }
+
+        error = NULL;
+        res = g_key_file_has_key (key_file, G_KEY_FILE_DESKTOP_GROUP, "X-GDM-BypassXsession", NULL);
+        if (!res) {
+                goto out;
+        } else {
+                bypasses_xsession = g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, "X-GDM-BypassXSession", &error);
+                if (error) {
+                        bypasses_xsession = FALSE;
+                        g_error_free (error);
+                        goto out;
+                }
+                if (bypasses_xsession) {
+                        g_debug ("GdmSessionDirect: Session %s bypasses Xsession wrapper script", filename);
+                }
+        }
+
+out:
+        g_free (filename);
+        return bypasses_xsession;
+}
+
 static void
 gdm_session_direct_select_session (GdmSession *session,
                                    const char *text)
diff --git a/daemon/gdm-session-direct.h b/daemon/gdm-session-direct.h
index 284d902..4982230 100644
--- a/daemon/gdm-session-direct.h
+++ b/daemon/gdm-session-direct.h
@@ -56,6 +56,7 @@ GdmSessionDirect * gdm_session_direct_new                      (const char *disp
                                                                 gboolean    display_is_local) G_GNUC_MALLOC;
 
 char             * gdm_session_direct_get_username             (GdmSessionDirect     *session_direct);
+gboolean           gdm_session_direct_bypasses_xsession        (GdmSessionDirect     *session_direct);
 
 /* Exported methods */
 gboolean           gdm_session_direct_restart                  (GdmSessionDirect     *session_direct,
diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c
index 8b161bb..2cbb568 100644
--- a/daemon/gdm-simple-slave.c
+++ b/daemon/gdm-simple-slave.c
@@ -112,7 +112,11 @@ on_session_started (GdmSession       *session,
         username = gdm_session_direct_get_username (slave->priv->session);
         gdm_slave_run_script (GDM_SLAVE (slave), GDMCONFDIR "/PreSession", username);
 
-        /* FIXME: should we do something here? */
+        /* FIXME: should we do something here?
+         * Note that error return status from PreSession script should
+         * be ignored in the case of a X-GDM-BypassXSession session, which can be checked
+         * by calling: gdm_session_direct_bypasses_xsession (session)
+         */
 }
 
 static void



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