pub struct SandboxConfig {
pub allow_network_access: bool,
pub writable_dirs: Option<Vec<PathBuf>>,
pub override_home_dirs: Option<Vec<OverrideHomeDir>>,
pub passthrough_home_dirs: Option<Vec<PathBuf>>,
}Expand description
The main configuration struct for the sandbox.
If at least one override or passthrough home directory is specified, the sandbox will use a temporary directory for the home directory instead of the user’s actual one. The original home directory can still be accessed via absolute paths (and will be read-only by default like any other directory not explicitly specified as writable).
Fields§
§allow_network_access: boolWhether network access is allowed for the sandbox.
writable_dirs: Option<Vec<PathBuf>>The directories to mounted as writable for the sandbox.
override_home_dirs: Option<Vec<OverrideHomeDir>>Directories to recursively copy into the sandbox under a temporary directory rather than mapping the real ones.
Overriden home directories are mounted as writable for the sandbox.
passthrough_home_dirs: Option<Vec<PathBuf>>Directories to directly mount from the user’s home directory under the override home directory.
Passthrough directories are mounted as writable for the sandbox.
Implementations§
Source§impl SandboxConfig
impl SandboxConfig
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a new configuration with no network access, no writable directories, and no fake home directory
Sourcepub const fn with_network_access(&mut self) -> &mut Self
pub const fn with_network_access(&mut self) -> &mut Self
Enables network access for the sandbox.
Sourcepub fn with_writable_dir(&mut self, dir: impl Into<PathBuf>) -> &mut Self
pub fn with_writable_dir(&mut self, dir: impl Into<PathBuf>) -> &mut Self
Marks a directory as writable for the sandbox.
Sourcepub fn with_override_home_dir(
&mut self,
override_home_dir: OverrideHomeDir,
) -> &mut Self
pub fn with_override_home_dir( &mut self, override_home_dir: OverrideHomeDir, ) -> &mut Self
Marks a subdirectory of the user’s home as an override.
Sourcepub fn with_passthrough_home_dir(
&mut self,
segments: impl IntoIterator<Item = impl AsRef<Path>>,
) -> &mut Self
pub fn with_passthrough_home_dir( &mut self, segments: impl IntoIterator<Item = impl AsRef<Path>>, ) -> &mut Self
Marks a subdirectory of the user’s home as passthrough.
Sourcepub const fn build_sandbox(&mut self, sandbox_type: SandboxType) -> Sandbox
pub const fn build_sandbox(&mut self, sandbox_type: SandboxType) -> Sandbox
Builds a sandbox with the given type.