Skip to content

Dockerfile: drop cap_sys_nice file caps — they break exec on unprivileged-LXC hosts (lab net-sim crash-looped) - #20

Merged
M0LTE merged 1 commit into
mainfrom
fix/no-setcap-breaks-restricted-hosts
Jun 12, 2026
Merged

Dockerfile: drop cap_sys_nice file caps — they break exec on unprivileged-LXC hosts (lab net-sim crash-looped)#20
M0LTE merged 1 commit into
mainfrom
fix/no-setcap-breaks-restricted-hosts

Conversation

@M0LTE

@M0LTE M0LTE commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

#17 added setcap cap_sys_nice+ep to sim-web/sim-router so -rt-priority could renice as the non-root sim user. That was the wrong mechanism: a file capability with the effective bit set makes the kernel refuse to exec the binary (operation not permitted / EPERM) on any host whose capability bounding set lacks CAP_SYS_NICE — e.g. an unprivileged LXC. So the new :main broke the image for every run on such hosts, including the vast majority that never pass -rt-priority.

Impact: the production lab net-sim (an unprivileged systemd LXC) crash-looped Restarting (255) with exec /usr/local/bin/sim-web: operation not permitted the instant it pulled the post-#17 :main.

-rt-priority needs CAP_SYS_NICE granted at runtime (--cap-add SYS_NICE, running as root or with the cap in the user namespace) — which the README already documents — and it already degrades gracefully (logs one line, runs at normal priority) where the platform won't grant it. So the binaries must stay capability-free.

This change: remove both setcap lines + the libcap2-bin install they required; README now states the cap is runtime-granted by design and explains the exec-EPERM trap; new internal/dockerfile guard test fails if a setcap line is ever reintroduced on the binaries.

Verified: docker run --rm --cap-drop SYS_NICE --entrypoint /usr/local/bin/sim-web <old-:main> --helpoperation not permitted; the corrected image under the same --cap-drop SYS_NICE → prints usage and runs. make test green.

🤖 Generated with Claude Code

…ricted hosts

The setcap cap_sys_nice+ep on sim-web/sim-router (added with -rt-priority in #17) makes the binaries refuse to exec — "operation not permitted" / EPERM — on any host whose capability bounding set lacks CAP_SYS_NICE, e.g. an unprivileged LXC. That broke the image for EVERY run on such hosts, including the overwhelming majority that never pass -rt-priority: the production lab net-sim crash-looped (Restarting 255) the moment it pulled the new :main.

File capabilities were the wrong mechanism. -rt-priority needs CAP_SYS_NICE granted at RUNTIME (--cap-add SYS_NICE, running as root or with the cap in the userns), which the README already documents; and it already degrades gracefully (one-line warning, normal priority) where the platform won't grant it. So the binaries must stay capability-free: remove both setcap lines and the libcap2-bin install they needed.

Reproduced and verified locally: `docker run --cap-drop SYS_NICE --entrypoint sim-web <old:main> --help` → "operation not permitted"; same on the corrected image → prints usage. New internal/dockerfile guard test fails if a setcap line is ever reintroduced on the binaries. make test green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@M0LTE
M0LTE merged commit 5934970 into main Jun 12, 2026
1 check 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