pub struct Profile { /* private fields */ }Expand description
An opaque, immutable sandbox policy.
Sandbox policies, such as those in profiles, build
a Profile from Profile::deny_all by adding additional permissions,
and are compiled into the program (the worker on Linux; the control
process and the worker on Windows).
Implementations§
Source§impl Profile
impl Profile
Sourcepub fn deny_all() -> Builder
pub fn deny_all() -> Builder
Start a policy with no explicit filesystem grants and Network::None.
Syscall filtering is independently opt-in: the default is
Syscalls::Unfiltered. The Linux backend still provides implicit
scratch storage and a best-effort proc view; see Builder.
Sourcepub fn edit(&self) -> Builder
pub fn edit(&self) -> Builder
Reopen a finished profile as a Builder to derive a new profile.
The builder starts from a clone of this profile’s grants, so the
original is left intact and any number of variants can be derived from a
single base. Filesystem grants and capabilities can only grow, syscall
denials can only be added, and the scalar dimensions (name and
network) are replaced by a later call.
Prefer exposing a reusable base as a fn() -> Builder — see
profiles — and reach for edit only when you
already hold a built Profile, e.g. one handed to you by another
crate.
use sandbox::Profile;
let base = Profile::deny_all().name("base").read_exec("/usr/lib").build();
let worker = base.edit().name("worker").read_write("/run/worker").build();
assert_eq!(worker.name(), "worker");