Skip to content

fix: postinst never restarts the console's getty on an upgrade - #37

Merged
marcos-mendez merged 1 commit into
masterfrom
fix/postinst-keeps-the-console-session
Oct 3, 2026
Merged

marcos-mendez merged 1 commit into
masterfrom
fix/postinst-keeps-the-console-session

Conversation

@marcos-mendez

Copy link
Copy Markdown
Collaborator

What. On an upgrade where inithooks.service was not active, debian/postinst ran systemctl restart getty@tty1.service container-getty@1.service "to make sure" a login prompt was there. The restart ends the session on that tty: the maintainer ran apt upgrade from the container console (pct console, tty1) and was logged out mid-upgrade (2026-10-03).

Fix. A getty is now only ever started, never restarted: only when it is inactive (systemctl is-active --quiet), only a unit the machine has (systemctl cat; a container has no getty@tty1), and only once the first boot is over, inithooks.service neither running nor queued, asked the way libinithooks/init_lock.py asks (is-active states, then a start job in list-jobs --no-legend). The branch for an inithooks that was running before the upgrade (/run/inithooks-was-active) is unchanged.

Tested. tests/test-packaging.bats (+8 tests) runs the packaged postinst, built by the real debhelper over a copy of debian/, with systemctl a stub answering from the environment and recording its calls: both gettys running (no start, no restart), a container with container-getty@1 alone and inactive (started), one of two inactive (that one started), the first boot running or queued (nothing touched), the was-active branch (inithooks restarted, no getty touched), a fresh install, and no restart.*getty left in the packaged script. 309 bats in all, shell gate unchanged (debian/ is not under kcov).

When inithooks.service was not running, postinst restarted
getty@tty1.service and container-getty@1.service "to make sure" a login
prompt was there, and the restart ended the session on that tty: the
maintainer ran apt upgrade from the container console (pct console,
tty1) and was logged out mid-upgrade.

A getty is now only ever started, only when it is inactive, only one the
machine has (systemctl cat; a container has no getty@tty1), and only
once the first boot is over, inithooks.service neither running nor
queued, asked the way libinithooks/init_lock.py asks (is-active, then a
start job in list-jobs). The branch for an inithooks that was running
before the upgrade is unchanged. tests/test-packaging.bats runs the
packaged postinst with systemctl answering from the environment.
@marcos-mendez
marcos-mendez merged commit d091be9 into master Oct 3, 2026
3 checks passed
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