[gdm/wip/wayland-for-merge: 4/17] session-worker: Move PostLogin / PreSession / PostSession script running here



commit 774a2379ab5cea10b9aa758a4657c264d3e025f4
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Mar 6 15:08:29 2014 -0500

    session-worker: Move PostLogin / PreSession / PostSession script running here

 daemon/gdm-session-worker.c |   33 ++++++++++++++++
 daemon/gdm-simple-slave.c   |   89 -------------------------------------------
 2 files changed, 33 insertions(+), 89 deletions(-)
---
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
index 5adc015..59f1e32 100644
--- a/daemon/gdm-session-worker.c
+++ b/daemon/gdm-session-worker.c
@@ -1554,6 +1554,17 @@ register_ck_session (GdmSessionWorker *worker)
 #endif
 }
 
+static gboolean
+run_script (GdmSessionWorker *worker,
+            const char       *dir)
+{
+        return gdm_run_script (dir,
+                               worker->priv->username,
+                               worker->priv->x11_display_name,
+                               worker->priv->hostname,
+                               worker->priv->x11_authority_file);
+}
+
 static void
 session_worker_child_watch (GPid              pid,
                             int               status,
@@ -1579,6 +1590,8 @@ session_worker_child_watch (GPid              pid,
                                              status);
 
         worker->priv->child_pid = -1;
+
+        run_script (worker, GDMCONFDIR "/PostSession");
 }
 
 static void
@@ -1999,6 +2012,13 @@ gdm_session_worker_open_session (GdmSessionWorker  *worker,
                 flags |= PAM_SILENT;
         }
 
+        if (!run_script (worker, GDMCONFDIR "/PostLogin")) {
+                g_set_error (error,
+                             GDM_SESSION_WORKER_ERROR,
+                             GDM_SESSION_WORKER_ERROR_OPENING_SESSION,
+                             "Failed to execute PostLogin script");
+        }
+
         error_code = pam_open_session (worker->priv->pam_handle, flags);
 
         if (error_code != PAM_SUCCESS) {
@@ -2016,6 +2036,19 @@ gdm_session_worker_open_session (GdmSessionWorker  *worker,
         session_id = gdm_session_worker_get_environment_variable (worker, "XDG_SESSION_ID");
 #endif
 
+        /* 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_bypasses_xsession (session)
+         */
+        if (!run_script (worker, GDMCONFDIR "/PreSession")) {
+                g_set_error (error,
+                             GDM_SESSION_WORKER_ERROR,
+                             GDM_SESSION_WORKER_ERROR_OPENING_SESSION,
+                             "Failed to execute PreSession script");
+        }
+
 #ifdef WITH_CONSOLE_KIT
         register_ck_session (worker);
 
diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c
index f9ecc33..d1408ec 100644
--- a/daemon/gdm-simple-slave.c
+++ b/daemon/gdm-simple-slave.c
@@ -246,41 +246,12 @@ out:
         g_free (gis_dir_path);
 }
 
-static gboolean
-run_script (GdmSimpleSlave *slave,
-            const char     *dir,
-            const char     *username)
-{
-        char *display_name;
-        char *display_hostname;
-        char *display_x11_authority_file;
-        gboolean ret;
-
-        g_object_get (slave,
-                      "display-name", &display_name,
-                      "display-hostname", &display_hostname,
-                      "display-x11-authority-file", &display_x11_authority_file,
-                      NULL);
-
-        ret = gdm_run_script (dir, username,
-                              display_name,
-                              display_hostname,
-                              display_x11_authority_file);
-
-        g_free (display_name);
-        g_free (display_hostname);
-        g_free (display_x11_authority_file);
-
-        return ret;
-}
-
 static void
 on_session_started (GdmSession       *session,
                     const char       *service_name,
                     int               pid,
                     GdmSimpleSlave   *slave)
 {
-        const char *username;
         const char *session_id;
 
         g_debug ("GdmSimpleSlave: session started %d", pid);
@@ -289,19 +260,6 @@ on_session_started (GdmSession       *session,
 
         session_id = gdm_session_get_session_id (session);
         g_object_set (GDM_SLAVE (slave), "session-id", session_id, NULL);
-
-        /* Run the PreSession script. gdmslave suspends until script has terminated */
-        username = gdm_session_get_username (slave->priv->session);
-        if (username != NULL) {
-                run_script (slave, GDMCONFDIR "/PreSession", username);
-        }
-
-        /* 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_bypasses_xsession (session)
-         */
 }
 
 #ifdef  HAVE_LOGINDEVPERM
@@ -473,42 +431,6 @@ switch_to_and_unlock_session (GdmSimpleSlave  *slave,
 }
 
 static void
-stop_greeter (GdmSimpleSlave *slave)
-{
-        const char *username;
-        gboolean script_successful;
-
-        g_debug ("GdmSimpleSlave: Stopping greeter");
-
-        if (slave->priv->greeter_environment == NULL) {
-                g_debug ("GdmSimpleSlave: No greeter running");
-                return;
-        }
-
-        /* Run the PostLogin script. gdmslave suspends until script has terminated */
-        username = NULL;
-        if (slave->priv->session != NULL) {
-                username = gdm_session_get_username (slave->priv->session);
-        }
-
-        if (username != NULL) {
-                script_successful = run_script (slave, GDMCONFDIR "/PostLogin", username);
-        } else {
-                script_successful = TRUE;
-        }
-
-        if (!script_successful) {
-                g_debug ("GdmSimpleSlave: PostLogin script unsuccessful");
-
-                slave->priv->start_session_id = 0;
-                queue_greeter_reset (slave);
-                return;
-        }
-
-        gdm_launch_environment_stop (GDM_LAUNCH_ENVIRONMENT (slave->priv->greeter_environment));
-}
-
-static void
 start_session (GdmSimpleSlave  *slave)
 {
         char           *auth_file;
@@ -569,7 +491,6 @@ start_session_timeout (GdmSimpleSlave  *slave)
                         start_session (slave);
                 } else {
                         /* Session actually gets started from on_greeter_environment_session_stop */
-                        stop_greeter (slave);
                 }
         }
 
@@ -1706,16 +1627,6 @@ gdm_simple_slave_stop (GdmSlave *slave)
                          (GDestroyNotify) g_free);
 
         if (self->priv->session_is_running) {
-                const char *username;
-
-                /* Run the PostSession script. gdmslave suspends until script
-                 * has terminated
-                 */
-                username = gdm_session_get_username (self->priv->session);
-                if (username != NULL) {
-                        run_script (self, GDMCONFDIR "/PostSession", username);
-                }
-
 #ifdef  HAVE_LOGINDEVPERM
                 gdm_simple_slave_revoke_console_permissions (self);
 #endif


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