Skip to content

fix(drop-sudo): use the shell test builtin for the socket ACL check - #191

Closed
zachsplat wants to merge 1 commit into
openai:mainfrom
zachsplat:drop-sudo-shell-test-builtin
Closed

zachsplat wants to merge 1 commit into
openai:mainfrom
zachsplat:drop-sudo-shell-test-builtin

Conversation

@zachsplat

Copy link
Copy Markdown

Fixes #188.

On Ubuntu 26.04 runners, drop-sudo stops before Codex starts:

Error: Could not restrict access to /run/dbus/system_bus_socket.

For example AgentMeter/agentmeter-action run 40688459476 (image ubuntu-26.04 20261012.163.1, 28 October): https://github.com/AgentMeter/agentmeter-action/actions/runs/40688459476/job/122816823703. ubuntu-latest moves to 26.04 by 19 November (actions/runner-images#14748), and the projects linked from #188 have been pinning their jobs to ubuntu-24.04 to get past it.

The ACL is applied; the check is what fails. As the runner-images team found in actions/runner-images#15004, /usr/bin/test on 26.04 is the uutils one (rust-coreutils 0.10.0), and its -w reads only the mode bits (in my strace it makes a single statx call), so after setfacl -m u:runner:--- it still says the socket is writable. This change runs the same check as /bin/sh -c 'test -w "$1"' sh /proc/self/fd/3 instead. The dash builtin calls faccessat2(..., W_OK, AT_EACCESS), which applies the ACL. setpriv still sets the same UID and groups, /proc/self/fd/3 is still the last argument, and a denied check still exits 1 with empty stderr, so the rest of isSocketWritable and its unit test in test/dropSudoSocketAcl.test.mjs need no change. /bin/sh is what the launcher script already uses.

test/dropSudo.test.mjs made the same test -w checks in its setup and its final assertions, so on 26.04 it fails before the action even runs. A small testWritable() helper gives those checks the same shell form. dist/main.js is rebuilt with the build script's esbuild command (esbuild 0.23.0 from the lockfile); rebuilding 13e9c17 that way gives a file identical to the committed one, so the dist diff is only this change and its inline source map.

What I ran, all in throwaway containers from the official ubuntu:24.04 and ubuntu:26.04 images with no network at run time:

  • A root-owned 0666 socket with setfacl -n -m u:runner:---, the socket opened O_PATH on fd 3, then setpriv to the runner UID: /usr/bin/test -w /proc/self/fd/3 exits 0 on 26.04 and 1 on 24.04; the sh -c form exits 1 on both; a real connect() gets EACCES on both. Without the ACL every form exits 0.
  • This repo's tsc --noEmit, the esbuild build and node --test test/*.test.mjs at 13e9c17, as a runner-like user (passwordless sudo, in the docker group, a root-owned /var/run/docker.sock):
    • 24.04: 182 of 182 pass, before and after this change.
    • 26.04 with only the test helper change: the drop-sudo subtests fail with Could not restrict access to /run/codex-action-...sock, the same error as drop-sudo fails on Ubuntu 26.04 #188. With this whole change that error is gone.

I have not run the action itself on a GitHub-hosted runner.

On 26.04, 12 drop-sudo subtests still fail after this change, for a separate reason this PR does not touch: sudo there is sudo-rs, which ignores -E (sudo: preserving the entire environment is not supported, '-E' is ignored, which also appears in the AgentMeter log above), so the Codex stub never sees CODEX_CAPTURE_PATH. On a runner that means the step's environment, for example a custom CODEX_HOME, does not reach Codex; HOME, PATH, NODE_OPTIONS and TMPDIR still arrive because the launcher passes them as arguments.

Would you like me to handle the -E part in this PR too, or would you rather do that one separately?

On Ubuntu 26.04 /usr/bin/test is the uutils one, whose -w reads only the
mode bits, so after setfacl -m u:runner:--- it still reported the socket
as writable and drop-sudo stopped with "Could not restrict access to
/run/dbus/system_bus_socket". The dash builtin asks the kernel
(faccessat), which applies the ACL. The test helpers that made the same
check get the same change, and dist/main.js is rebuilt.

Fixes openai#188.
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@zachsplat

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Stephan202 pushed a commit to PicnicSupermarket/error-prone-support that referenced this pull request Nov 11, 2026
On `ubuntu-26.04` the `openai/codex-action` `drop-sudo` step fails, as
that image's `/usr/bin/test -w` ignores the ACL the action applies to
`/run/dbus/system_bus_socket`. Revert to `ubuntu-24.04` until a fixed
release is available.

See:
- openai/codex-action#188
- openai/codex-action#191

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stephan202 pushed a commit to PicnicSupermarket/error-prone-support that referenced this pull request Nov 11, 2026
On `ubuntu-26.04` the `openai/codex-action` `drop-sudo` step fails, as
that image's `/usr/bin/test -w` ignores the ACL the action applies to
`/run/dbus/system_bus_socket`. Revert to `ubuntu-24.04` until a fixed
release is available.

See:
- openai/codex-action#188
- openai/codex-action#191
@ww-oai

ww-oai commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the PR @zachsplat but we'll likely go with #192 because the Node API semantics are easier for us to consistently assert.

@ww-oai ww-oai closed this Nov 13, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

drop-sudo fails on Ubuntu 26.04

2 participants