Skip to content

fix(drop-sudo): invoke the privileged phase through process.execPath - #181

Open
RainieLLM wants to merge 1 commit into
openai:mainfrom
RainieLLM:fix/drop-sudo-absolute-node-path
Open

RainieLLM wants to merge 1 commit into
openai:mainfrom
RainieLLM:fix/drop-sudo-absolute-node-path

Conversation

@RainieLLM

@RainieLLM RainieLLM commented Sep 19, 2026 •

Copy link
Copy Markdown

Fixes #180

Summary

On Linux and macOS, the “Drop sudo privilege” step runs drop-sudo again under sudo. The command used node as the interpreter name. When sudo replaces PATH with its own secure_path, that path may not contain the Node.js installation used by the action. On a self-hosted runner, the step can then fail with:

sudo: node: command not found

The action now passes process.execPath to sudo. This is the full path of the Node.js binary that already runs the action, so the second process uses the same interpreter. The rest of the command stays unchanged. The runner already has passwordless sudo at this point, so the change does not add or remove any privilege.

Tests

The new test runs drop-sudo with a Node.js path outside the secure_path configured for sudo. It checks that the privileged phase uses that path and keeps the remaining arguments unchanged.

  • pnpm run check
  • node --test test/*.test.mjs — 146 tests, 143 pass, 3 skip, 0 fail
  • Rebuilt dist/main.js

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@RainieLLM

Copy link
Copy Markdown
Author

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

github-actions Bot added a commit that referenced this pull request Sep 19, 2026
The drop-sudo strategy runs this action again under sudo. It named the
interpreter as a bare "node", but sudo resets PATH to its own secure_path.
That path does not always hold the Node.js install that runs the action. On
a self-hosted runner the step then stops at once with:

    sudo: node: command not found

Use process.execPath instead. It is the full path of the Node binary that
runs the action. The repository already does this in runCodexExec, and the
existing tests use it to launch the bundle.

This code is reachable from the "Drop sudo privilege, if appropriate" step
in action.yml. The Linux and macOS branches call drop-sudo without
--root-phase, so they enter this path.

No privilege boundary changes. The runner user already has sudo without a
password at this point, and ensurePasswordlessSudo asserts it.

Test:
- pnpm run check
- node --test test/*.test.mjs -- 146 tests, 143 pass, 0 fail
- test/dropSudoInterpreterPath.test.mjs is new. It fails on the old code.
- Rebuilt dist/main.js.
@RainieLLM
RainieLLM force-pushed the fix/drop-sudo-absolute-node-path branch from 8776ac0 to 2145dc7 Compare September 19, 2026 01:36
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.

[BUG] drop-sudo fails when Node is outside sudo's PATH

1 participant