Repository navigation
Description
Summary
On an OpenRC (Alpine family) live boot, 25_autologin.yaml installs a root
autologin on tty1 and ttyS0, and then 10_accounting.yaml deletes the
ttyS0 one and replaces it with a plain getty. So the serial console of an
OpenRC live medium never gets the autologin it is supposed to get, while
tty1 does. On systemd both consoles get it.
Why the ordering works out that way
kairos-init/pkg/bundled/cloudconfigs/25_autologin.yaml, stage initramfs:
- name: "Autologin on livecd for OpenRC"
if: |
[ -f /run/cos/live_mode ]
only_service_manager: "openrc"
commands:
- sed -i -e 's/tty1.*//g' /etc/inittab
- sed -i -e 's/ttyS0.*//g' /etc/inittab
- echo "tty1::respawn:/sbin/agetty --autologin root -i --noclear tty1" >> /etc/inittab
- echo "ttyS0::respawn:/sbin/agetty --autologin root -i --noclear ttyS0" >> /etc/inittabkairos-init/pkg/bundled/cloudconfigs/10_accounting.yaml, stage
initramfs.after, with no if: guard at all:
- name: "Enable serial login for alpine"
only_service_manager: "openrc"
commands:
- sed -i -e 's/ttyS0.*//g' /etc/inittab
- echo "ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100" >> /etc/inittabagent/pkg/utils/runstage.go runs for _, s := range []string{stageBefore, stage, stageAfter}, so the whole initramfs stage of every file completes
before any initramfs.after step runs. 10_accounting.yaml therefore always
runs last here, whatever the lexicographic order of the two filenames, and its
unguarded sed 's/ttyS0.*//g' blanks the autologin line the earlier stage just
appended.
The comment above that step says it sits in initramfs.after "so it doesnt
collide with other initramfs changes to the /etc/inittab". The placement is
what creates the collision: it does not avoid the race, it wins it.
Reproduction
Replaying the two command lists in the order runstage.go runs them, against
the real /etc/inittab of quay.io/kairos/alpine:3.18-core-amd64-generic-v2.4.3:
--- after the initramfs pass (25_autologin has run) ---
tty1::respawn:/sbin/agetty --autologin root -i --noclear tty1
ttyS0::respawn:/sbin/agetty --autologin root -i --noclear ttyS0
--- after the initramfs.after pass (10_accounting has run) ---
tty1::respawn:/sbin/agetty --autologin root -i --noclear tty1
ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100
Impact
10_accounting.yaml also runs passwd -l root in the same stage, so root has
no password on a live medium. With the autologin gone, the serial console
presents a login prompt that root cannot answer. The kairos user is set to
kairos in live mode and still works, so the console is not dead, but the
documented and intended behaviour of a live medium, a root shell on the
console, is only available on tty1.
That matters exactly where serial is the only console. It is the same setup
described in #1004 for Equinix Metal, where the physical server exposes nothing
but the serial port.
25_autologin.yaml's own comment states the intent the current code defeats:
"the ttyS0 one is the only way to reach a machine whose console is serial".
On systemd the equivalent works, because 25_autologin.yaml writes a
serial-getty@ttyS0.service.d/override.conf drop-in, which overrides the
distro unit rather than competing for a line in a shared file.
Suggested fix
The two steps are about the same console in two different situations, so give
10_accounting.yaml's step the complement of the guard 25_autologin.yaml
already has, [ ! -f /run/cos/live_mode ]. Exactly one of the two then applies
on any boot, ttyS0 always ends up with a line, and the ordering stops
mattering.
Notes
Found by diffing the OpenRC and systemd halves of the bundled cloud-configs,
the same way as #4709 and #4713. The OpenRC path is not covered by CI
(git grep -i alpine .github/workflows/ finds nothing), which is why this
survived.
Reported with AI assistance.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone ✅
Activity
itxaka-agent commentedon Sep 21, 2026
Picking this up: writing a regression test for the OpenRC serial-autologin race (
10_accounting.yamlblanking the line25_autologin.yamljust wrote), then fixing it with the complementarylive_modeguard you suggested.itxaka-agent commentedon Sep 21, 2026
Audit summary — round 0
25_autologin.yaml's and10_accounting.yaml's OpenRC live-mode commands against a fixture/etc/inittab, confirming the reported asymmetry (ttyS0loses its autologin line,tty1keeps it). Committed astest: reproduce kairos-io/kairos#4741.if: '[ ! -f /run/cos/live_mode ]'to10_accounting.yaml's serial-login step — the exact complement of25_autologin.yaml's own guard. Committed asfix(cloudconfigs): keep the openrc live-mode serial autologin.if:guards, so it could never have gone red from the fix alone. Rewrote it to evaluate each step's guard first and assert the ticket's actual claim (which line wins onttyS0, in both live and non-live mode). Committed astest: guard against kairos-io/kairos#4741 regression.ttyS0assertion, then restored it. Fullkairos-initsuite green, no coverage gap found.runstage.gostage-ordering claim the whole fix rests on, confirmed the guard matches the established negated-guard convention in this directory, confirmed commit hygiene (three commits in capture/fix/flip order, correct sign-off, no forbidden trailers). One note carried into the PR body: the capture commit's test passed both before and after the fix for the reason above; the red-then-green signal came from the flip commit instead.PR: #4862
itxaka-agent commentedon Oct 1, 2026
Closing #4862 — the Second Foundation picked this up without noticing #4742 was already open. Backing off so that PR can proceed.
itxaka-agent commentedon Oct 8, 2026
QA verification
Tested #4742 at
9857cbeaagainst its merge base3dd0f1f9. I built Alpine 3.21 (OpenRC) live ISOs of both and booted them in QEMU/KVM with a serial console.3dd0f1f9): ttyS0 stops atkairos- login:and asks for a password. No autologin.9857cbea): ttyS0 logs in as root automatically and gives a shell./etc/inittabhasttyS0::respawn:/sbin/agetty --autologin root -i --noclear ttyS0and/run/cos/live_modeexists.ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100, nolive_mode. The non-live path still gets the plain getty.Not shown: tty1 autologin. The default ISO cmdline is install-mode, so tty1 runs the installer on both builds (screens are identical). I did not read the before build's inittab either, since that needs a login; the login prompt is the evidence there.
Proof: before serial log, PR serial log, installed boot log.
QA: pass
fix(openrc): keep the live-media serial autologin (#4742)