Skip to content

Commit a864d7e

Browse files
committed
Avoid spurious autologinchange error when /etc/lightdm doesn't exist, take greetd configuration into account when looking for autologin users, simplify convoluted printf statement
1 parent 1c174df commit a864d7e

1 file changed

Lines changed: 29 additions & 12 deletions

File tree

usr/sbin/autologinchange

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -462,16 +462,21 @@ fi
462462
## safely manage those
463463
## TODO: consider cases with leading spaces
464464
## TODO: ignore comments
465-
if grep --quiet --recursive --ignore-case -- '^\[Seat:[^*]' /etc/lightdm; then
466-
printf '%s\n' "ERROR: Multi-seat lightdm configuration detected, cannot proceed!" >&2
467-
exit 1
465+
if [ -d /etc/lightdm ]; then
466+
if grep --quiet --recursive --ignore-case -- '^\[Seat:[^*]' /etc/lightdm; then
467+
printf '%s\n' "ERROR: Multi-seat lightdm configuration detected, cannot proceed!" >&2
468+
exit 1
469+
fi
468470
fi
469471

470-
readarray -t autologin_users_lightdm < <(
471-
grep --recursive --ignore-case -- '^autologin-user=' /etc/lightdm \
472-
| filter_out_sysmaint_maybe \
473-
| awk -F'=' '{ print $NF }' || true
474-
) || true
472+
autologin_users_lightdm=()
473+
if [ -d /etc/lightdm ]; then
474+
readarray -t autologin_users_lightdm < <(
475+
grep --recursive --ignore-case -- '^autologin-user=' /etc/lightdm \
476+
| filter_out_sysmaint_maybe \
477+
| awk -F'=' '{ print $NF }' || true
478+
) || true
479+
fi
475480
true "INFO: Collected list of users with lightdm autologin enabled."
476481

477482
readarray -t autologin_users_sddm < <(
@@ -487,11 +492,23 @@ readarray -t autologin_users_sddm < <(
487492
) || true
488493
true "INFO: Collected list of users with sddm autologin enabled."
489494

495+
readarray -t autologin_users_greetd < <(
496+
for file_name in /etc/greetd/config.toml.d/*; do
497+
if ! [ -f "${file_name}" ]; then
498+
continue
499+
fi
500+
get_config_section "${file_name}" 'initial_session' \
501+
| grep -- '^user\s*=\s*"[^"]*"$' \
502+
| filter_out_sysmaint_maybe \
503+
| sed 's/^.*"\([^"]*\)"$/\1/' || true
504+
done
505+
) || true
506+
490507
readarray -t autologin_users < <(
491-
IFS=$'\n'
492-
printf '%s\n%s\n' \
493-
"${autologin_users_lightdm[*]}" \
494-
"${autologin_users_sddm[*]}" \
508+
printf '%s\n' \
509+
"${autologin_users_lightdm[@]}" \
510+
"${autologin_users_sddm[@]}" \
511+
"${autologin_users_greetd[@]}" \
495512
| sed '/^$/d' \
496513
| sort -u
497514
)

0 commit comments

Comments
 (0)