Docker multi-arch build with sudo support - #6736
Open
axelfontaine wants to merge 2 commits into
Open
Conversation
qemu-user-static-binfmt ships FP flags by default. Docker cross-arch builds run emulated-architecture containers via QEMU, and setuid binaries like sudo only keep their privilege escalation under binfmt_misc emulation when the C (credentials) flag is set; O (open-binary) lets the interpreter run against a container whose rootfs differs from the host's. Override with OCF, derived from the package's own registrations, and add a migration for existing installs. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds QEMU binfmt overrides to support sudo in cross-architecture Docker containers.
Changes:
- Generates binfmt overrides with credential/open-binary flags.
- Applies configuration during installation.
- Migrates existing installations and reloads binfmt registrations.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
install/config/binfmt.sh |
Generates QEMU binfmt overrides. |
install/config/all.sh |
Runs binfmt configuration during installation. |
migrations/1786521494.sh |
Repairs existing installations and restarts binfmt. |
Suppressed comments (1)
install/config/binfmt.sh:9
- Replacing the entire suffix drops the package's existing
Pflag from itsFPregistrations.Ppreserves the emulated program's originalargv[0]; removing it changes execution semantics for every QEMU-launched binary, beyond the intended credential fix. Preserve the package-supplied flags and addO/Cinstead, then make the migration's completion check accept the resulting flag set.
sed -E 's/:[A-Za-z]*$/:OCF/' "$conf" >"/etc/binfmt.d/$(basename "$conf")"
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…t aarch64 Add OMARCHY_BINFMT_SOURCE_DIR/OMARCHY_BINFMT_DIR overrides to the config script and migration so both can be tested without touching /etc or /usr/lib. Writing the test surfaced a real gap: the migration's already-fixed check only grepped qemu-aarch64-static.conf, so a partially-fixed install or an architecture qemu-user-static-binfmt adds later would be missed. It now checks every qemu-*-static.conf the package registers. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
Suppressed comments (1)
test/shell.d/binfmt-multiarch-test.sh:34
- These expectations encode the unintended removal of the source registration's
Pflag. Assert an output that addsOandCwhile retainingFandP, so the test catches regressions in the package's argv0-preservation behavior.
grep -qFx ':qemu-aarch64:M::magic:mask:/usr/bin/qemu-aarch64-static:OCF' "$dest_dir/qemu-aarch64-static.conf" ||
fail "binfmt config overrides aarch64 flags with OCF"
grep -qFx ':qemu-arm:M::magic:mask:/usr/bin/qemu-arm-static:OCF' "$dest_dir/qemu-arm-static.conf" ||
fail "binfmt config overrides arm flags with OCF"
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.
qemu-user-static-binfmt ships FP flags by default. Docker cross-arch builds run emulated-architecture containers via QEMU, and setuid binaries like sudo only keep their privilege escalation under binfmt_misc emulation when the C (credentials) flag is set; O (open-binary) lets the interpreter run against a container whose rootfs differs from the host's. Override with OCF, derived from the package's own registrations, and add a migration for existing installs.
Reproducer
Run a cross-arch Docker image build with a
Dockerfilecontaining aUSERdirective andsudo:using the following command:
Before
It fails with:
After
It succeeds as expected and prints:
Notes
Supercedes #6074 and targets quattro