From 323cc092a50c0bc3987cf99f689427ba85737ecf Mon Sep 17 00:00:00 2001 From: axtloss Date: Mon, 20 Nov 2023 19:34:06 +0100 Subject: [PATCH 1/2] fix: Reset user session once first-setup completes Resets the default session of a user to gnome once first-setup completes this stops users from being trapped in an endless loop of always logging into the restricted first-setup session --- __first_setup_reset_session | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/__first_setup_reset_session b/__first_setup_reset_session index c15de4af..2840ec45 100755 --- a/__first_setup_reset_session +++ b/__first_setup_reset_session @@ -6,3 +6,29 @@ if [ "$(echo "${LOGIN_USERS}" | wc -l)" -gt 1 ]; then fi echo '[daemon]' > /etc/gdm3/daemon.conf + + +export highest_uid=$(grep -E "^UID_MIN " /etc/login.defs | sed 's/UID_MIN //') +export REAL_USER="" + +# Gets the latest added user from /etc/passwd +# It gets the minimum UID for users using /etc/login.defs +# and loops over all the entries in /etc/passwd +# checking if the uid of the selected user is higher than the minimum uid +# if it is, then this uid gets set as the new minimum uid +# and it gets repeated until the last line of passwd is processed +# NOTE: This assumes that new users always have a higher uid than the previously added user and that no system user has a higher UID than the users +# it generally is a safe assumption to make, but should still be noted in case something goes wrong. +while read entry; do + uid=$(echo "$entry" | awk 'BEGIN {FS=":"}; {print $3}') + name=$(echo "$entry" | awk 'BEGIN {FS=":"}; {print $1}') + if [[ $((uid)) -gt $((highest_uid)) && $name != "nobody" ]]; then + echo "$name" + export highest_uid=$uid + export REAL_USER=$name + fi +done < <(getent passwd) + +if [ -e "/var/lib/AccountsService/users/$REAL_USER" ]; then + sed 's/Session=firstsetup/Session=gnome/g' -i "/var/lib/AccountsService/users/$REAL_USER" +fi From 7455a985d26a8b161821d4fb976af857a2bb74c6 Mon Sep 17 00:00:00 2001 From: axtloss Date: Mon, 20 Nov 2023 19:37:10 +0100 Subject: [PATCH 2/2] Remove stray echo --- __first_setup_reset_session | 1 - 1 file changed, 1 deletion(-) diff --git a/__first_setup_reset_session b/__first_setup_reset_session index 2840ec45..7a68ce5f 100755 --- a/__first_setup_reset_session +++ b/__first_setup_reset_session @@ -23,7 +23,6 @@ while read entry; do uid=$(echo "$entry" | awk 'BEGIN {FS=":"}; {print $3}') name=$(echo "$entry" | awk 'BEGIN {FS=":"}; {print $1}') if [[ $((uid)) -gt $((highest_uid)) && $name != "nobody" ]]; then - echo "$name" export highest_uid=$uid export REAL_USER=$name fi