Commit 7f1d753b authored by intrigeri's avatar intrigeri
Browse files

Also display a hopefully useful message with plymouth when GDM has failed to...

Also display a hopefully useful message with plymouth when GDM has failed to start Xorg 5 times (refs: #14521)

This ugly hack is needed because we have to keep count of the failures and kill
GDM ourselves, otherwise the gdm3 process is still running and the service is in
"active (running)" state, so OnFailure=tails-gdm-failed-to-start.service does
not take effect.
parent 2d669b71
#!/bin/sh
set -eu
echo "Wrapping gdm-x-session to limit the number of allowed failures"
dpkg-divert --add --rename --divert \
/usr/lib/gdm3/gdm-x-session.real \
/usr/lib/gdm3/gdm-x-session
ln -s /usr/lib/gdm3/gdm-x-session.tails /usr/lib/gdm3/gdm-x-session
# Allow our gdm-x-session wrapper to kill the GDM service
Debian-gdm ALL = NOPASSWD: /bin/systemctl kill --signal=9 gdm
[Unit]
Description=Guide the user when GDM fails to start
# GDM's OnFailure will also start plymouth-quit.service. Let it do its job
# and then we'll start plymouthd again, to avoid race conditions. Ideally
# we would simply remove plymouth-quit.service from that OnFailure but
# GDM itself will run "plymouth --quit" when it fails to start the X server
# GDM normally runs "plymouth --quit" when it fails to start the X server
# (see on_display_status_changed that calls plymouth_quit_without_transition).
# But when this happens we kill -9 GDM in our gdm-x-session wrapper, so it
# might not have time to quit plymouth yet. Therefore we ensure plymouth
# has quit before we start: we run after plymouth-quit.service (which is started
# by gdm.service's default OnFailure=), we have plymouth-quit-wait.service start,
# and we wait for it to complete.
After=plymouth-quit.service
Requires=plymouth-quit-wait.service
After=plymouth-quit-wait.service
[Service]
Type=oneshot
# Use VT5 that is clean of boot messages and does not get a getty started
# We use VT5 that is clean of boot messages and does not get a getty started
# when we switch there, thanks to our custom NAutoVTs=4 logind.conf setting
ExecStart=/sbin/plymouthd --mode=shutdown --tty=tty5
#
# There are queued udev events when we run plymouthd so on Stretch, so
# watch_for_coldplug_completion will set up a watcher and return before
# there's any place where plymouthd can create a seat to display its
# splash and messages on. So we tell plymouthd to ignore udev which makes
# it create a fallback seat.
# XXX:Buster: check if plymouth.ignore-udev is still necessary (this code path
# has changed in plymouth 0.9.3)
ExecStart=/bin/sh -c \
'/sbin/plymouthd --mode=shutdown --tty=tty5 \
--kernel-command-line="plymouth.ignore-udev $(cat /proc/cmdline)"'
ExecStart=/bin/chvt 5
ExecStart=/bin/plymouth show-splash
ExecStart=/bin/sh -c \
"/bin/plymouth display-message \
--text=\"Report a bug (https://deb.li/TailsNoX): GDM fails to start with $(lspci -d::0300 -nn)\" \
"
'VIDEO_CARD=$(lspci -d::0300 -nn | sed -E "s,.* VGA compatible controller \[0300\]:\s*,,") ; \
/bin/plymouth display-message \
--text="Report a bug (https://deb.li/TailsNoX): GDM fails to start with $VIDEO_CARD" \
'
#!/bin/sh
# No "set -e" because we need to capture the exit status of gdm-x-session.real
set -u
FAILURES_COUNT_FILE=/var/lib/gdm3/gdm-x-session_failures
MAX_FAILURES=5
get_failures () {
local failures=0
if [ -f "$FAILURES_COUNT_FILE" ] ; then
failures=$(cat "$FAILURES_COUNT_FILE")
fi
echo -n "$failures"
}
increment_failures () {
failures=$(($(get_failures) + 1))
echo -n "$failures" > "$FAILURES_COUNT_FILE"
}
/usr/lib/gdm3/gdm-x-session.real "$@"
RET=$?
if [ $RET -ne 0 ] ; then
increment_failures
if [ $(get_failures) -ge "$MAX_FAILURES" ] ; then
# Trigger OnFailure=tails-gdm-failed-to-start.service
echo "gdm-x-session failed too many times, stopping GDM"
sudo -n /bin/systemctl kill --signal=9 gdm
fi
fi
exit $RET
Supports Markdown
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