fix: write output-schema temp file as the unprivileged user#106
Open
adityasingh2400 wants to merge 1 commit into
Open
fix: write output-schema temp file as the unprivileged user#106adityasingh2400 wants to merge 1 commit into
adityasingh2400 wants to merge 1 commit into
Conversation
When safety-strategy is unprivileged-user, the output-schema temp directory is created via mktemp run as the codex user, so it is owned by that user with 0700 permissions. The action process then tried to write schema.json into it with fs.writeFile, which runs as the action user and fails with EACCES. Write the schema file as the codex user by piping the contents to tee under sudo -u, and remove the temp directory with sudo rm -rf during cleanup. This mirrors how the final-message file written by the Codex process is read back with sudo -u <user> cat.
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
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.
When
output-schemais passed andsafety-strategyisunprivileged-user, the action fails withEACCES: permission deniedwhile writing the temporaryschema.json. The root cause is an ownership mismatch inresolveOutputSchema. The temp directory is created by runningmktempundersudo -u <codex-user>, so it is owned by the Codex user with the default0700permissions. The action then writes the schema into that directory withfs.writeFile, which runs as the action user (the runner). Because the directory grants nothing to its group, the runner cannot write into it and the run aborts beforecodex execstarts.This change writes the schema file as the Codex user by piping the contents to
teeundersudo -u, so the file is created and owned by the same user who later reads it viacodex exec --output-schema. It mirrors the existing pattern where the final-message file written by the Codex process is read back withsudo -u <user> cat. Cleanup is updated to remove the Codex-user-owned temp directory withsudo rm -rfin the unprivileged path, matching how the temporary output file directory is already cleaned up; previously cleanup unconditionally usedfs.rmas the runner, which would also have failed on that directory. The default (non-privileged) path is unchanged and still usesfs.writeFileplusfs.rm.Validation:
pnpm run check,pnpm test, andpnpm run buildall pass, and the regenerateddist/main.jsis committed so the CI dist-sync check stays green. The failure only manifests undersudo -uon a Linux runner with a separate Codex user, which the existing CLI-level test harness cannot exercise without that environment, so this follows the same no-unit-test pattern as priorrunCodexExec/sandbox fixes in this repo.Closes #103