Bad profile scripts can prevent login to X session and are difficult to troubleshoot
A recent bug in flatpak caused GDM to be unable to login to an Xorg session. This caused fairly widespread breakage of Arch Linux systems, as users of GDM that had flatpak installed were unable to login to X sessions.
Flatpak's issue was that a script it adds to /etc/profile.d/
which is run by /etc/gdm/Xsession
, had a syntax error (well, it used shell-specific syntax that was a syntax error for a number of shells). This caused GDM to fail to login, resulting in a blank screen for a moment and then a return to the login screen. There was no indication of the cause of the problem, and it was tricky to troubleshoot as it is hard to know which log files to check. The person on reddit who figured out that it was flatpak to blame only did so by downgrading recently-updated packages one-at-a-time and trying to log in each time, resulting in success after downgrading flatpak.
To reproduce:
echo -e '#!/bin/sh\n<' | sudo tee -a /etc/profile.d/syntax_error.sh
Then log out and in again (to an Xorg session). Login will fail. Switch to a tty and login, and you will see:
bash: /etc/profile.d/syntax_error.sh: line 2: syntax error near unexpected token `newline'
bash: /etc/profile.d/syntax_error.sh: line 2: `<'
but login will otherwise succeed. You can then sudo rm /etc/profile.d/syntax_error.sh
and switch back to GDM to login successfully.
Logging in to a session on a TTY is not prevented if there is a syntax error in a profile script. You still get logged in, but you will see the error at the top of your session and clearly any setup the profile script did will not work correctly. So perhaps GDM should continue to login even if there are errors in executing profile scripts, after all, it is difficult to fix errors if you cannot login, and it is pretty unappealing that a misconfigured optional application that is not crucial for basic system usage can prevent login. Login should not be that fragile.
Logging in despite errors would be more palatable if the error were visible. Perhaps a popup box in GDM showing an error message would be appropriate, that has to be dismissed before logging in, i.e. "There was an error executing your profile. Your session may be misconfigured. Details are below <output of running /etc/[x]profile or $HOME/.[x]profile>. Click OK to proceed with login."