Repository navigation
fix: postinst never restarts the console's getty on an upgrade - #37
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What. On an upgrade where inithooks.service was not active,
debian/postinstransystemctl 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 ranapt upgradefrom 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 nogetty@tty1), and only once the first boot is over, inithooks.service neither running nor queued, asked the waylibinithooks/init_lock.pyasks (is-activestates, then a start job inlist-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 ofdebian/, withsystemctla stub answering from the environment and recording its calls: both gettys running (no start, no restart), a container withcontainer-getty@1alone 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 norestart.*gettyleft in the packaged script. 309 bats in all, shell gate unchanged (debian/is not under kcov).