fix: Landlock probe environment and autofallback to BW#252
Conversation
SafeDep Report SummaryNo dependency changes detected. Nothing to scan. This report is generated by SafeDep Github App |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #252 +/- ##
==========================================
- Coverage 46.18% 46.05% -0.13%
==========================================
Files 112 114 +2
Lines 8103 8155 +52
==========================================
+ Hits 3742 3756 +14
- Misses 4040 4076 +36
- Partials 321 323 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR improves Linux sandbox driver selection by adding an environment probe for Landlock’s “no-NNP seccomp shim” requirements and automatically falling back to Bubblewrap when that probe fails, plus adds unit tests and documentation updates to reflect the new behavior.
Changes:
- Add a self-reexec Landlock shim probe used during Landlock sandbox initialization to validate required user-namespace + seccomp-notify behavior.
- Refactor Linux sandbox selection to use injectable factories (enabling deterministic tests) and add coverage for fallback/forced-driver behavior.
- Document the updated Landlock requirements and fallback conditions; wire a hidden
__landlock_probecommand into the CLI.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| sandbox/platform/platform_linux.go | Adds factory indirection and safer Landlock logging in driver selection + fallback logic. |
| sandbox/platform/platform_linux_test.go | New tests validating default fallback, default Landlock selection, and forced-driver behavior. |
| sandbox/platform/landlock_probe_linux.go | Implements the Landlock shim probe (self-reexec + seccomp install) and probe entrypoint. |
| sandbox/platform/landlock_linux.go | Calls the probe as part of Landlock sandbox construction to gate driver availability. |
| main.go | Registers the hidden __landlock_probe command in the root CLI. |
| cmd/landlock/landlock_probe_linux.go | Adds the hidden Cobra command that runs the platform probe on Linux. |
| cmd/landlock/landlock_probe_other.go | Returns nil for the probe command on non-Linux platforms. |
| docs/sandbox.md | Updates Linux Landlock requirements and fallback explanation to include the shim probe. |
| docs/sandbox-landlock.md | Updates Landlock limitations to note probing and fallback behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // newLandlockSandbox creates a new Landlock sandbox instance after verifying | ||
| // that both Landlock and seccomp user notification are available on the system. | ||
| // that Landlock and the no-NNP seccomp shim path are available on the system. | ||
| func newLandlockSandbox() (sandbox.Sandbox, error) { | ||
| abi, err := landlockDetectABI() | ||
| if err != nil { | ||
| return nil, fmt.Errorf("landlock not available: %w", err) | ||
| } | ||
|
|
||
| if err := landlockShimProbe(); err != nil { | ||
| return nil, fmt.Errorf("landlock shim not available: %w", err) | ||
| } |
| cmd.AddCommand(subcmd) | ||
| } | ||
| if subcmd := landlockCmd.NewLandlockProbeCommand(); subcmd != nil { | ||
| cmd.AddCommand(subcmd) | ||
| } |
| PersistentPreRun: func(cmd *cobra.Command, args []string) { | ||
| }, |



No description provided.