Repository navigation
feat: report nsjail failures as errors and self-check nsjail at startup - #95
Merged
Merged
Conversation
When nsjail could not set up the jail or launch the program, it exits 255 and that status was returned as the program's exit code with status OK. Tell nsjail's own failure apart from its log and return it as an error (HTTP 500, with nsjail's error lines in the server log), and run a small bash program through nsjail at startup so that a host where nsjail cannot run programs refuses to serve. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Before: When nsjail itself fails (for example, it cannot set up the jail), it exits 255 and the API returns that as the program's result:
{"run":{"exit_code":255,"status":"OK",...}}with HTTP 200, and no error is logged. On a host where nsjail cannot run programs, the server starts and/healthzstaysokwhile every run fails this way.After: Such a request, in the compile or the run step, returns HTTP 500
{"code":"INTERNAL_ERROR","message":"internal server error"}, and the server logssandbox execution failedwith nsjail's error lines. On startup the server runs a one-line bash script through nsjail; if it does not print the expected output and exit 0, the server logssandbox self-check failedwith the reason and exits.A program that exits 255 itself is still returned as a result with
exit_code: 255.How: nsjail's own output tells the two apart. When launching the program fails, nsjail logs
Couldn't launch the child process(and still logs the child as exited or killed afterwards); when nsjail fails before launching it, or is killed from outside, its log has noexited with statusorterminated with signalline. The error lines are taken from the log and from nsjail's stderr, where it writes until it has read its config.flowchart LR A[nsjail exits non-zero] --> B{"log has<br/>Couldn't launch the child process?"} B -- yes --> E[error → HTTP 500] B -- no --> C{"log has exited with status<br/>or terminated with signal?"} C -- no --> E C -- yes --> R[program's result]Generated by Claude Code