Skip to content

openrc: 10_accounting.yaml deletes the live-media serial autologin that 25_autologin.yaml just installed #4741

Closed

Description

@ci-robbot

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/inittab

kairos-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/inittab

agent/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.

Activity

  1. added
    bugSomething isn't working
    area/cloud-configThis is for enhancement to the yip library
    on Sep 18, 2026
  2. moved this to Under review 🔍 in 🧙Issue tracking boardon Sep 18, 2026
  3. self-assigned this
    on Sep 21, 2026
  4. itxaka-agent commented on Sep 21, 2026

    @itxaka-agent
    Collaborator

    Automated triage agent (kairos-triage-agent) running as @itxaka-agent.
    This comment was generated by software. A human maintainer can override
    any action taken here.

    Picking this up: writing a regression test for the OpenRC serial-autologin race (10_accounting.yaml blanking the line 25_autologin.yaml just wrote), then fixing it with the complementary live_mode guard you suggested.

  5. itxaka-agent commented on Sep 21, 2026

    @itxaka-agent
    Collaborator

    Automated triage agent (kairos-triage-agent) running as @itxaka-agent.
    This comment was generated by software. A human maintainer can override any
    action taken here.

    Audit summary — round 0

    • Tester (phase 1): wrote a spec replaying 25_autologin.yaml's and 10_accounting.yaml's OpenRC live-mode commands against a fixture /etc/inittab, confirming the reported asymmetry (ttyS0 loses its autologin line, tty1 keeps it). Committed as test: reproduce kairos-io/kairos#4741.
    • Coder (phase 2): added if: '[ ! -f /run/cos/live_mode ]' to 10_accounting.yaml's serial-login step — the exact complement of 25_autologin.yaml's own guard. Committed as fix(cloudconfigs): keep the openrc live-mode serial autologin.
    • Coder (phase 3): found the phase-1 spec replayed raw commands without evaluating the 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 on ttyS0, in both live and non-live mode). Committed as test: guard against kairos-io/kairos#4741 regression.
    • Tester (verify): independently re-derived the fix rather than trusting the journal — confirmed the guard is a true negation with no leftover unguarded systemd path, reverse-applied the fix commit and confirmed the live-mode spec goes red at the exact ttyS0 assertion, then restored it. Full kairos-init suite green, no coverage gap found.
    • Reviewer (round 0): verdict approve. Re-checked the runstage.go stage-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

  6. removed their assignment
    on Oct 1, 2026
  7. itxaka-agent commented on Oct 1, 2026

    @itxaka-agent
    Collaborator

    Closing #4862 — the Second Foundation picked this up without noticing #4742 was already open. Backing off so that PR can proceed.

  8. itxaka-agent commented on Oct 8, 2026

    @itxaka-agent
    Collaborator

    Automated triage agent (kairos-triage-agent) running as @itxaka-agent.
    This comment was generated by software. A human maintainer can override
    any action taken here.

    QA verification

    Tested #4742 at 9857cbea against its merge base 3dd0f1f9. I built Alpine 3.21 (OpenRC) live ISOs of both and booted them in QEMU/KVM with a serial console.

    • Before (3dd0f1f9): ttyS0 stops at kairos- login: and asks for a password. No autologin.
    • PR build (9857cbea): ttyS0 logs in as root automatically and gives a shell. /etc/inittab has ttyS0::respawn:/sbin/agetty --autologin root -i --noclear ttyS0 and /run/cos/live_mode exists.
    • Installed boot of the PR build: login prompt on serial, ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100, no live_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

  9. added a commit that references this issue on Oct 12, 2026
    8ec6b30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    QA: passarea/cloud-configThis is for enhancement to the yip librarybugSomething isn't working

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions