Documentation
¶
Overview ¶
Package hostsandbox is what the host does to itself before it loads a core. The server's part (job objects, namespaces, sandbox profiles) is in the stream package, and docs/GAMING.md lists what each platform gets.
Index ¶
Constants ¶
PrivateSharedMemoryEnv is set by whoever starts a runner in a mount namespace of its own, and only then: without one, this would mount over the whole machine's /dev/shm.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
Apply boxes the process in: resource limits, no new privileges, a syscall filter that refuses networking and starting programs, and Landlock limiting writes. Failures in the layers a kernel or container doesn't offer are returned together, and the layers that worked stay on.
Call it from the thread that will run the core and keep to that thread: on Linux the priority belongs to the calling thread and what it starts, and so does Landlock on kernels before it could synchronise, unless Confine came first. The syscall filter covers every thread.
func ClaimStdout ¶ added in v0.3.3
ClaimStdout moves the protocol pipe to a descriptor of its own and points stdout at stderr. Cores print to stdout, and one printf on the pipe would end the game.
func Confine ¶ added in v0.3.3
Confine limits writing for every thread this process will ever have. Landlock belongs to the thread that asks for it and what that thread starts, and Go is already running others. So one thread asks, then becomes this same program again: that leaves only it, and every later thread descends from it.
Call it first, before reading stdin or moving a descriptor, as the program runs from the top again, and before Apply, whose filter refuses starting a program. A system without Landlock has nothing to carry over, and Apply reports that.
Types ¶
type Limits ¶
type Limits struct {
SaveDir string // the only folder it may write to
MemoryMB int64 // memory it may use; 0 for no limit
GPU bool // a graphics driver will load: docs/GAMING.md says what that opens
Normal bool // keep normal priority: a demanding game can't play at low priority
// twice has no other way of doing. Only for a core known to, as they're shared with
// whatever else runs under this account. docs/GAMING.md says what that opens.
SharedMemory bool
// LargeAddressSpace is for a core that reserves far more address space than it ever uses.
// It's a reservation, with nothing behind it until it's touched, so the data limit still
// holds what it really uses to MemoryMB.
LargeAddressSpace bool
}
Limits are the boundaries a host sets for itself.