summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2019-08-29 09:34:04 -0400
committerRay Strode <rstrode@redhat.com>2021-04-12 16:57:53 -0400
commit690f43762c28300ce17751c4423b2451f6a2b6f8 (patch)
tree9c3bbe59af91ce6e74d098c818a062ae2126d1c8
parentd7d328bbea4bd41c64e88ca38507acfe87e36b78 (diff)
downloadgdm-690f43762c28300ce17751c4423b2451f6a2b6f8.tar.gz
daemon: run PostSession script from mnager not worker
After a user logs out, the session worker baby sitting the session, may optionally run admin provided PostSession scripts. Those scripts aren't getting reliably run on reboots, because systemd kills the worker prematurely. There's no easy way to prevent this... the worker is part of the user session and user sessions are terminated immediately at shutdown time. This commit moves PostSession handling to the daemon process, where it can happen unimpeded by session bring down. This also makes the scripts more reliable in other potential cases where the worker is killed explicitly.
-rw-r--r--daemon/gdm-manager.c40
-rw-r--r--daemon/gdm-session-worker.c3
2 files changed, 40 insertions, 3 deletions
diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c
index 779b716b..d31c9d71 100644
--- a/daemon/gdm-manager.c
+++ b/daemon/gdm-manager.c
@@ -1961,6 +1961,41 @@ on_user_session_started (GdmSession *session,
}
static void
+run_post_session_script (GdmSession *session)
+{
+ GPid pid;
+ GdmDisplay *display;
+ gboolean display_is_local = FALSE;
+ const char *username;
+ g_autofree char *display_name = NULL, *remote_hostname = NULL, *display_auth_file = NULL;
+
+ display = get_display_for_user_session (session);
+
+ if (display == NULL)
+ return;
+
+ pid = gdm_session_get_pid (session);
+
+ if (pid <= 0)
+ return;
+
+ username = gdm_session_get_username (session);
+
+ g_object_get (G_OBJECT (display),
+ "x11-display-name", &display_name,
+ "is-local", &display_is_local,
+ "remote-hostname", &remote_hostname,
+ "x11-authority-file", &display_auth_file,
+ NULL);
+
+ gdm_run_script (GDMCONFDIR "/PostSession",
+ username,
+ display_name,
+ display_is_local? NULL : remote_hostname,
+ display_auth_file);
+}
+
+static void
remove_user_session (GdmManager *manager,
GdmSession *session)
{
@@ -1970,6 +2005,8 @@ remove_user_session (GdmManager *manager,
display = get_display_for_user_session (session);
if (display != NULL) {
+ run_post_session_script (session);
+
gdm_display_unmanage (display);
gdm_display_finish (display);
}
@@ -2781,6 +2818,9 @@ gdm_manager_dispose (GObject *object)
g_hash_table_unref);
g_list_foreach (manager->priv->user_sessions,
+ (GFunc) run_post_session_script,
+ NULL);
+ g_list_foreach (manager->priv->user_sessions,
(GFunc) gdm_session_close,
NULL);
g_list_free_full (manager->priv->user_sessions, (GDestroyNotify) g_object_unref);
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
index 07117d85..b0861b97 100644
--- a/daemon/gdm-session-worker.c
+++ b/daemon/gdm-session-worker.c
@@ -1770,18 +1770,15 @@ session_worker_child_watch (GPid pid,
: WIFSIGNALED (status) ? WTERMSIG (status)
: -1);
-
gdm_session_worker_uninitialize_pam (worker, PAM_SUCCESS);
gdm_dbus_worker_emit_session_exited (GDM_DBUS_WORKER (worker),
worker->priv->service,
status);
-
killpg (pid, SIGHUP);
worker->priv->child_pid = -1;
worker->priv->child_watch_id = 0;
- run_script (worker, GDMCONFDIR "/PostSession");
}
static void