@@ -4,6 +4,7 @@ import type { ParseEntry } from "shell-quote";
4
4
5
5
import { process_patch } from "./apply-patch.js" ;
6
6
import { SandboxType } from "./sandbox/interface.js" ;
7
+ import { execWithLandlock } from "./sandbox/landlock.js" ;
7
8
import { execWithSeatbelt } from "./sandbox/macos-seatbelt.js" ;
8
9
import { exec as rawExec } from "./sandbox/raw-exec.js" ;
9
10
import { formatCommandForDisplay } from "../../format-command.js" ;
@@ -42,26 +43,30 @@ export function exec(
42
43
sandbox : SandboxType ,
43
44
abortSignal ?: AbortSignal ,
44
45
) : Promise < ExecResult > {
45
- // This is a temporary measure to understand what are the common base commands
46
- // until we start persisting and uploading rollouts
47
-
48
46
const opts : SpawnOptions = {
49
47
timeout : timeoutInMillis || DEFAULT_TIMEOUT_MS ,
50
48
...( requiresShell ( cmd ) ? { shell : true } : { } ) ,
51
49
...( workdir ? { cwd : workdir } : { } ) ,
52
50
} ;
53
- // Merge default writable roots with any user-specified ones.
54
- const writableRoots = [
55
- process . cwd ( ) ,
56
- os . tmpdir ( ) ,
57
- ...additionalWritableRoots ,
58
- ] ;
59
- if ( sandbox === SandboxType . MACOS_SEATBELT ) {
60
- return execWithSeatbelt ( cmd , opts , writableRoots , abortSignal ) ;
61
- }
62
51
63
- // SandboxType.NONE (or any other) falls back to the raw exec implementation
64
- return rawExec ( cmd , opts , abortSignal ) ;
52
+ switch ( sandbox ) {
53
+ case SandboxType . NONE : {
54
+ // SandboxType.NONE uses the raw exec implementation.
55
+ return rawExec ( cmd , opts , abortSignal ) ;
56
+ }
57
+ case SandboxType . MACOS_SEATBELT : {
58
+ // Merge default writable roots with any user-specified ones.
59
+ const writableRoots = [
60
+ process . cwd ( ) ,
61
+ os . tmpdir ( ) ,
62
+ ...additionalWritableRoots ,
63
+ ] ;
64
+ return execWithSeatbelt ( cmd , opts , writableRoots , abortSignal ) ;
65
+ }
66
+ case SandboxType . LINUX_LANDLOCK : {
67
+ return execWithLandlock ( cmd , opts , additionalWritableRoots , abortSignal ) ;
68
+ }
69
+ }
65
70
}
66
71
67
72
export function execApplyPatch (
0 commit comments