Skip to content

file.enterSandbox

JoeStrout edited this page Sep 11, 2026 · 1 revision

Enter sandbox mode (one-way; there is no way back)

Parameters

None.

Return value

None.

Notes

Restricts every path in the program to the mounted disks. Once sandboxed, a path that names no mounted disk simply does not exist: file.exists is false for it, opening it fails, and there is no distinguishable "permission denied" that would let a program map the host file system by probing.

This cannot be undone. There is deliberately no intrinsic to leave sandbox mode, because a program that could leave it would not be sandboxed. A host application calls this once, at the end of its startup script, after it has finished any setup that needs real host paths.

Disks are mounted by the host before your script runs: a hw and a sys subdirectory beside the startup script become /hw and /sys, both read-only. Anything else next to them stays unreachable, including the startup script itself.

Rejected paths are logged to the console as [fs] rejected ..., which is where to look when a path unexpectedly fails.

Example

import "file"
print file.readLines("/etc/hosts") != null   // 1

file.enterSandbox

print file.readLines("/etc/hosts") != null   // 0
print file.readLines("/sys/startup.ms") != null   // 1

Clone this wiki locally