Skip to content

Probe unshare capability once instead of failing a daemon launch per mode - #8

Open
davidoj wants to merge 1 commit into
mainfrom
fix/unshare-capability-probe
Open

Probe unshare capability once instead of failing a daemon launch per mode#8
davidoj wants to merge 1 commit into
mainfrom
fix/unshare-capability-probe

Conversation

@davidoj

@davidoj davidoj commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Salvaged from #2. The rest of that PR landed via #5 (e2b import) and #6 (env-var marker fix, byte-identical). The Problem defaults from #2 are deliberately not carried over: #6 decided to keep exploit_type and insecure_verifier_info required, and this branch leaves that as is.

Problem

Without CAP_SYS_ADMIN (typical in unprivileged containers and pods) every external daemon launch fails identically, appending unshare: unshare failed: Operation not permitted to /tmp/djinn_daemon_bridge_{mode}.log on every attempt. Verification still works via the in-process forkserver fallback, but the log reads like a hard error, and the fallback was inferred from proc.poll() after a 50 ms sleep — which could mistake a slow-exiting unshare for a healthy daemon.

Fix

_unshare_supported() probes unshare -Urmp --mount-proc --fork true once per process (lock-guarded, cached), prints one line either way, and _ensure_daemon skips the doomed launch entirely when the probe fails. The per-mode _unshare_failed cache is kept for the case where the probe passes but a real launch still fails.

Testing

Daemon-backed stall tests plus djinn/tests/test_marker_isolation.py, 17 tests, pass on main and on this branch. Bridge log after the run:

/tmp/djinn_daemon_bridge_*.log
main (unprivileged python:3.12-slim) 10 × unshare: unshare failed: Operation not permitted
this branch (same container) empty; one stdout line: [djinn] namespace isolation unavailable (unshare: unshare failed: Operation not permitted); using in-process forkserver daemon instead. Verification results are unaffected; isolation is weaker.
this branch (macOS, no unshare binary) empty; one stdout line reporting `unshare` binary not found

🤖 Generated with Claude Code

https://claude.ai/code/session_014rSFHpdtkVYpGAEafamz5R

Without CAP_SYS_ADMIN every external daemon launch failed identically and
appended "unshare: unshare failed: Operation not permitted" to
djinn_daemon_bridge_{mode}.log on every attempt. Probe once per process,
log a single line, and skip the doomed launch. This also removes the 50 ms
poll() race that could mistake a slow-exiting unshare for a live daemon.

Salvaged from #2; the rest of that PR landed via #5 and #6.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014rSFHpdtkVYpGAEafamz5R
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.

1 participant