Commit 9e6df451 authored by intrigeri's avatar intrigeri
Browse files

Terminate GDM's GNOME session after the amnesia user logs in, in order to free...

Terminate GDM's GNOME session after the amnesia user logs in, in order to free memory (refs: #12092)

I've heard rumors that we can drop this hack when we switch to Wayland (#12213).
We'll see :)

We kill it as part of, i.e. during the "Applications" phase of
the initialization of the GNOME session. We cannot do this earlier reliably:

 - is started by "systemd --user" for almost every command run as
   the amnesia user and may thus be triggered too early, at a time when we still
   need GDM's processes.

 - If we do this as part of, it sometimes happens before amnesia's
   X.Org has started, and sometimes after that, which causes racy behaviour,
   weird bugs, and amnesia's $DISPLAY can be either :0 or :1, which breaks our
   code that relies on that value to be always the same.

We're in no rush to kill GDM's GNOME session super early anyway.

Note that we keep GDM running while we kill its GNOME session,
otherwise, the amnesia user can't unlock the screen:

  Failed to open reauthentication channel: Gio:DBusError:
  GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name
  org.gnome.DisplayManager was not provided by any .service files

Also, we ensure gdm-session-worker does not start new sessions once the amnesia
user has logged in, which should hopefully prevent GDM from activating
such a session while we want the amnesia's user session to remain active.
parent 02ea848c
......@@ -27,6 +27,7 @@ systemctl --global enable tails-add-GNOME-bookmarks.service
systemctl --global enable tails-additional-software-install.service
systemctl --global enable tails-configure-keyboard.service
systemctl --global enable tails-create-tor-browser-directories.service
systemctl --global enable tails-kill-gdm-session.service
systemctl --global enable tails-security-check.service
systemctl --global enable tails-upgrade-frontend.service
systemctl --global enable tails-virt-notify-user.service
amnesia ALL = NOPASSWD: /usr/local/lib/tails-kill-gdm-session ""
Description=Terminate the GDM session to free the corresponding memory
ExecStart=/usr/bin/sudo /usr/local/lib/tails-kill-gdm-session
# Terminate GDM's GNOME session, in order to free a few hundreds of MB
# of memory. This script is run by the tails-kill-gdm-session.service
# under "systemd --user", during the "Applications" phase of the
# initialization of the amnesia user's GNOME session.
set -e
set -u
set -x
# Ensure gdm-session-worker won't start new sessions.
cp -a /bin/true /usr/lib/gdm3/gdm-session-worker
# Kill GDM's gdm-session-worker: it's the parent process for all
# Debian-gdm processes, such as gdm-x-session; it would otherwise
# respawn another gdm-x-session after we've killed the first one.
pkill -u root --full --exact 'gdm-session-worker \[pam/gdm-launch-environment\]'
# Forcibly kill the Debian-gdm GNOME session,
# in case the former command was not enough.
loginctl --signal SIGKILL kill-user Debian-gdm || true
loginctl terminate-user Debian-gdm || true
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment