Fix Debian postinst hang in preseed late_command chroot (#68269)#69427
Open
dwoz wants to merge 1 commit into
Open
Fix Debian postinst hang in preseed late_command chroot (#68269)#69427dwoz wants to merge 1 commit into
dwoz wants to merge 1 commit into
Conversation
The salt-minion (and salt-api, salt-cloud, salt-master, salt-syndic) postinst scripts source /usr/share/debconf/confmodule in their configure branch but never tear down the debconf protocol before the auto-generated #DEBHELPER# section runs. confmodule sets up fd 3 as the debconf passthrough (exec 3>&1). Without a matching db_stop + exec 3>&- pair, fd 3 leaks into the debhelper-added deb-systemd-helper invocations. In a normal interactive apt-get install this is mostly invisible, but in a non-interactive Debian preseed late_command chroot (where the parent debconf frontend is not reachable) it produces "Bad file descriptor" errors and can hang the install entirely. Add the standard debconf teardown after the case block in all five salt-*.postinst scripts. Only run it on the configure branch, since that's the only path that sources confmodule. Regression test in tests/pytests/unit/pkg/ stubs confmodule and substitutes the #DEBHELPER# token with an fd-3-leak probe; the test exercises all five postinst scripts and confirms fd 3 is closed and db_stop is called before #DEBHELPER# runs. Fixes saltstack#68269
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 does this PR do?
The Debian salt-minion (and salt-api, salt-cloud, salt-master,
salt-syndic) postinst scripts source
/usr/share/debconf/confmodulein their configure branch but never tear down the debconf protocol
before the auto-generated
#DEBHELPER#section runs.confmoduleopens fd 3 as the debconf passthrough; without a matching
db_stopand
exec 3>&-, fd 3 leaks into the debhelper-addeddeb-systemd-helperinvocations. In non-interactive Debian preseedlate_commandchroots (no reachable parent debconf frontend) thatleak produces "Bad file descriptor" errors and can hang the install
entirely.
This PR adds the canonical debconf teardown (
db_stop+exec 3>&-) on the configure branch of all five salt-*.postinst scripts,and adds a regression test that stubs
confmoduleand replaces the#DEBHELPER#token with an fd-3 leak probe.What issues does this PR fix or reference?
Fixes #68269
Previous Behavior
apt-get install salt-minioninvoked from a Debian preseedlate_commandchroot hangs and reports/var/lib/dpkg/info/salt-minion.postinst: 66: 3: Bad file descriptor,breaking unattended Debian provisioning that installs the salt-minion
package.
New Behavior
The configure branch terminates the debconf protocol cleanly with
db_stopand explicitly closes fd 3 withexec 3>&-before thedebhelper-generated section runs.
deb-systemd-helperno longerinherits a stale fd 3, and the postinst completes whether or not the
parent debconf frontend is reachable.
Merge requirements satisfied?
Commits signed with GPG?
No (matches base branch tip)