Skip to content

Fix first-boot autologin race (update_lightdm_conf vs userconf-pi) + commit machine-id at build - #277

Merged
guysoft merged 4 commits into
develfrom
bugfix/708-first-boot-autologin-race
Sep 2, 2026
Merged

Fix first-boot autologin race (update_lightdm_conf vs userconf-pi) + commit machine-id at build#277
guysoft merged 4 commits into
develfrom
bugfix/708-first-boot-autologin-race

Conversation

@guysoft

@guysoft guysoft commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the first-boot boot-target/autologin regressions seen on FullPageOS 1.0.0-rc1 (guysoft/FullPageOS#708), verified on a Pi 5 test rig with HDMI capture.

  1. TTY autologin re-appears after the GUI autologin fixupdate_lightdm_conf.service (wanted by lightdm) raced userconfig.service (multi-user). Inside userconfig, userconf-pi's cancel-rename applies do_boot_behaviour B3/B4, which re-creates /etc/systemd/system/getty@tty1.service.d/autologin.conf and re-enables getty@tty1. On RC1 the race is lost: the TTY autologin drop-in ships enabled (FullPageOS #639 security issue is back). Fix: order the fixup After=userconfig.service and always remove the drop-in.

  2. update_lightdm_conf hardeningid -nu 1000 + set -e aborted the unit when uid 1000 didn't exist yet; now falls back to pi and doesn't fail the unit. raspi-config nonint do_autologin 2 (bitmask 2=GUI) kept for new raspi-config; manual lightdm.conf fallback still applied for older versions.

  3. Commit machine-id at build (base module end script) — with an "uninitialized" machine-id, systemd activates the First Boot Wizard on first boot (Starting systemd-firstboot.service - First Boot Wizard... observed in the RC1 boot log on the rig). Committing the machine-id and touching /var/lib/systemd/first-boot-done at build skips it headlessly.

Evidence (Pi 5 rig, RC1 image)

  • RC1 first boot (stock): /etc/systemd/system/getty@tty1.service.d/autologin.conf present with --autologin pi and getty@tty1 active — TTY autologin survived the GUI-only intent; lightdm.conf was correct but applied too early.
  • X crash-loop black screen (separate fix, PR Fix Xorg modesetting on vc4 + skip enable_gpu on Pi 4+ (FullPageOS #708) #276) was reproduced and fixed live with HDMI evidence.

Notes

  • The base module machine-id fix applies to all CustomPiOS distros; first-boot-done is created only if not already managed elsewhere.
  • No E2E/QEMU changes.

Prevents systemd-firstboot (First Boot Wizard) from activating on first
boot of a flashed image. With an uninitialized machine-id, systemd runs
the first-boot wizard, which in headless rigs (no keyboard) can block
boot waiting for console input (observed as 'First Boot Wizard' in the
FullPageOS 1.0.0-rc1 boot log on Raspberry Pi 5, part of #708).

systemd-machine-id-setup commits a real machine-id at build time and
/var/lib/systemd/first-boot-done marks first boot as completed.
update_lightdm_conf.service is wanted by lightdm.service, so its start
job is queued in parallel with multi-user.target — it raced (and on
FullPageOS 1.0.0-rc1 lost against) userconfig.service, whose
cancel-rename applies do_boot_behaviour B3/B4: re-creating the
getty@tty1 autologin drop-in and re-enabling getty@tty1. GUI distros
ended up with a TTY autologin shell, the exact issue
guysoft/FullPageOS#639 set out to fix.

- Order update_lightdm_conf.service After=userconfig.service so the
  cleanup lands last on first boot.
- Always remove the getty@tty1 autologin drop-in (cancel-rename may have
  just re-created it); do_autologin 2 is kept for newer raspi-config
  bitmask semantics, with the manual lightdm.conf fallback still applied.
- Do not abort (set -e) when uid 1000 does not exist yet or raspi-config
  is missing; fall back to BASE_USER pi.

Verified on hardware (Pi 5 rig, FullPageOS RC1): first boot with these
changes leaves autologin-user=pi/autologin-session=guisession in
lightdm.conf and NO /etc/systemd/system/getty@tty1.service.d/autologin.conf.
systemd-machine-id-setup refuses to overwrite the 'uninitialized'
placeholder (r--r--r--), so first boot still triggered the wizard. rm the
file first, then regenerate, then mark first-boot-done.
Comment thread src/modules/base/end_chroot_script Outdated
# /etc/machine-id is "uninitialized" in a fresh image, which makes systemd
# detect first boot and prompt for locale/keymap/timezone/root password on tty1.
# The wizard is not reachable headlessly (no HDMI/KVM on the test jig), so mark
# first boot as done and commit a real machine-id here.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does nto make sense, why did this initially break - give it a good plan why it break or look along fullpageos build log to explain why its needed now

@guysoft

guysoft commented Sep 2, 2026

Copy link
Copy Markdown
Owner Author

Investigated this against the FullPageOS build log and hardware evidence. The machine-id/first-boot block was not justified: it ran during image construction (FullPageOS src/build-708-fix.log:5424-5430), converted the image out of first-boot state, and suppressed ConditionFirstBoot services. On the Pi 5 this suppressed regenerate_ssh_host_keys, leaving sshd without host keys; the failure and recovery are recorded in FullPageOS PROGRESS_2026-09-01-fullpageos-e2e.md:37-40. There was no captured systemd-firstboot prompt requiring this workaround; the reported first-boot problem was the LightDM/userconf-pi ordering race. I removed the machine-id/first-boot-done block in b00992f, preserving first-boot service behavior. PR #277 now addresses only the evidence-backed update_lightdm_conf ordering and userconf-pi autologin cleanup, plus the separate machine-id placeholder removal needed before build-time machine-id generation.

@guysoft
guysoft merged commit ddfcdad into devel Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant