[gdm/wip/wayland-for-merge: 7/19] session-worker: Move PostLogin / PreSession / PostSession here



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

    session-worker: Move PostLogin / PreSession / PostSession here
    
    Pushing these up to the session worker dramatically simplifies the
    interface for the slave, which will allow us to kill the slaves as
    separate binaries.
    
    Ideally, in the long-term, these scripts should go away.

 daemon/gdm-session-worker.c |   28 +++++++++++++++
 daemon/gdm-simple-slave.c   |   82 -------------------------------------------
 2 files changed, 28 insertions(+), 82 deletions(-)
---
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
index 5adc015..cfbc2dd 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,14 @@ 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)
+         */
+        run_script (worker, GDMCONFDIR "/PreSession");
+
 #ifdef WITH_CONSOLE_KIT
         register_ck_session (worker);
 
diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c
index f9ecc33..02f4dc9 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
@@ -475,36 +433,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));
 }
 
@@ -1706,16 +1634,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]