Repository navigation
Docker multi-arch build with sudo support - #6736
axelfontaine wants to merge 5 commits into
Conversation
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.
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"
|
Reviewed at a0730ad and run on a disposable Omarchy worker (x86_64, qemu-user-static-binfmt 11.1.1, Docker 29.7.2), with a second opinion from Codex Medium. The bug is real, and this fixes it. With the package's Dropping
Further points from Codex that I checked against the source:
Setting Nothing was pushed to your branch, because keeping or dropping |
The config script replaced each registration's entire flags field with the literal string OCF, silently dropping the package's P flag (preserve-argv0) and any other flag a later package update might add. That's a system-wide side effect -- this writes to /etc/binfmt.d/, not something Docker-scoped -- beyond what fixing sudo under QEMU needs. Only C is required for that; O lets the interpreter work against a differing rootfs. Measured by @omarchybot on PR omacom#6736: FP alone fails sudo, OCF fixes sudo but changes argv[0] system-wide, POCF fixes sudo and keeps argv[0] correct. Add O and C to whatever flags are already there instead, and update the migration's completion check and the test's expectations to match. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
[Critical impact] The PR appears safe to merge with the documented companion packaging change. SummaryAdds
|
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>
…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>
The config script replaced each registration's entire flags field with the literal string OCF, silently dropping the package's P flag (preserve-argv0) and any other flag a later package update might add. That's a system-wide side effect -- this writes to /etc/binfmt.d/, not something Docker-scoped -- beyond what fixing sudo under QEMU needs. Only C is required for that; O lets the interpreter work against a differing rootfs. Measured by @omarchybot on PR omacom#6736: FP alone fails sudo, OCF fixes sudo but changes argv[0] system-wide, POCF fixes sudo and keeps argv[0] correct. Add O and C to whatever flags are already there instead, and update the migration's completion check and the test's expectations to match. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Replace the one-time copy into /etc/binfmt.d with omarchy-apply-binfmt, run from a post-transaction hook on the qemu registrations, from system setup and once from the migration. It follows changed, added and removed registrations, only touches overrides it marked as managed, and restarts systemd-binfmt whenever the running registrations still differ. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6f91fa4 to
8b1ec1f
Compare
|
@greptile-apps Update your confidence score now that you have reviewed and agreed to the replies to your latest concerns. |
|
Looked again at 8b1ec1f. The branch was rewritten since the review at a0730ad, so the The classification is unsettled, so this waits on the maintainer. Two models classified this head separately. I read it as a bug fix: Earlier findings, read against this head but not run:
Two things are still for the maintainer. |
|
@omarchybot consider switching from docker to podman |
…-sudo # Conflicts: # install/config/all.sh
qemu-user-static-binfmt registers its QEMU interpreters with flags
FP. Setuid binaries such assudoin an emulated-architecture Docker container only keep their credentials under binfmt_misc emulation when the registration carriesC, which impliesO. This addsOandCto the package's own flags, soFPbecomesFPOC/POCFandP(argv[0] preserved) is kept.How
omarchy-apply-binfmt(hidden, root) rebuilds/etc/binfmt.d/qemu-*-static.conffrom the package's registrations in/usr/lib/binfmt.d, addingOandC.systemd-binfmtwhen it changed a file, or when the live flags in/proc/sys/fs/binfmt_miscstill differ. It skips the restart when binfmt_misc isn't mounted, as in the installer's chroot; the overrides load at first boot.--checkexits 1 when anything would change, without changing it or needing root.30-omarchy-binfmt.hookruns it after any transaction that installs, upgrades or removes a qemu binfmt registration, so overrides follow interpreter/magic/mask changes and added or dropped architectures. It sorts after systemd's25-systemd-binfmt.hook. Packaged by Install the omarchy binfmt pacman hook omarchy-pkgs#820.install/config/binfmt.sh) calls it.omarchy-apply-binfmt --check || sudo omarchy-apply-binfmt, so only users with pending changes get a sudo prompt, and a failure stays pending.Setting
Cis machine-wide: QEMU then runs a root-owned setuid foreign-architecture binary with root's credentials anywhere on the host, not only inside Docker.Reproducer
sudo whoamish -c 'echo $0'PF(package default)sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set…POCF(afteromarchy-apply-binfmt)rootshTests
test/shell.d/binfmt-multiarch-test.shcovers adding flags without dropping existing ones, idempotency and--check, following changed/added/dropped registrations, leaving administrator overrides alone, the restart conditions, and the migration only escalating when changes are pending.config-test.shchecks the PKGBUILD installs the hook.Not yet exercised: the hook firing on a real qemu upgrade, since it only installs once the package ships it.
Merge order
Merge this first, then omacom/omarchy-pkgs#820 (see its notes on the release PKGBUILD's pinned tag).
Supersedes #6074 and targets quattro.
🤖 Generated with Claude Code