fix: restore linux interactive PTY and runtime-dir behavior#84
Merged
Conversation
There was a problem hiding this comment.
2 issues found across 14 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="cmd/fence/main.go">
<violation number="1" location="cmd/fence/main.go:222">
P1: Guard `cfg` before assigning `ForceNewSession`; `config.Load` can return nil for missing/empty files, which makes this new assignment panic.</violation>
</file>
<file name="internal/sandbox/linux.go">
<violation number="1" location="internal/sandbox/linux.go:428">
P2: TOCTOU race between `mkdir -p` and `chmod 700`: the directory is briefly world-readable. Replace with `install -d -m 0700 "$dir"` which sets permissions atomically at creation and returns a meaningful exit status on failure.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/sandbox/integration_linux_test.go">
<violation number="1" location="internal/sandbox/integration_linux_test.go:788">
P3: The TMPDIR fallback assertion is too permissive: `strings.Contains(..., "TMP=/tmp")` can pass for incorrect TMPDIR values (for example `/tmp-custom`), weakening this regression test.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
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.
Summary
Restore Linux interactive sessions so PTY-launched shells start reliably, keep job control by default, and always get a usable runtime directory. The default Linux PTY path now skips
bwrap --new-session, relies on a targetedioctl(TIOCSTI)seccomp rule, and falls back to a private/tmp/fence-runtime-<uid>-<pid>directory when the inherited runtime dir is not usable inside the sandbox.Resolves #61.
Changes
bwrap --new-sessionfor interactive Linux PTY sessions by defaultforceNewSessionconfig and--force-new-sessionCLI override so strict session isolation is still available when desiredfork/exec ... operation not permittedXDG_RUNTIME_DIRandTMPDIRonly when they are actually usable in the sandbox; otherwise create a private0700runtime dir under/tmpioctl(TIOCSTI)explicitly using a narrow ioctl-argument ruleValidation
go test ./..../fence -t code -- bashstarts without job-control warnings after rebuild./fence -t code --force-new-session -- bashstill reproduces the old job-control tradeoff intentionally./fence -t code -c 'echo "XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR"; touch "$XDG_RUNTIME_DIR/fence-repro"'uses a private writable runtime dir