Struct tabox::configuration::SandboxConfiguration
source · pub struct SandboxConfiguration {Show 18 fields
pub time_limit: Option<u64>,
pub memory_limit: Option<u64>,
pub stack_limit: Option<u64>,
pub executable: PathBuf,
pub args: Vec<String>,
pub env: Vec<(String, String)>,
pub mount_paths: Vec<DirectoryMount>,
pub working_directory: PathBuf,
pub stdin: Option<PathBuf>,
pub stdout: Option<PathBuf>,
pub stderr: Option<PathBuf>,
pub syscall_filter: Option<SyscallFilter>,
pub mount_tmpfs: bool,
pub wall_time_limit: Option<u64>,
pub cpu_core: Option<usize>,
pub uid: usize,
pub gid: usize,
pub mount_proc: bool,
}
Expand description
struct that represents the configuration parameters of a sandbox
Fields§
§time_limit: Option<u64>
Time limit for the execution in seconds
memory_limit: Option<u64>
Memory limit for the execution in bytes
stack_limit: Option<u64>
Stack limit for the execution in bytes
executable: PathBuf
Absolute path of the executable
args: Vec<String>
Arguments to pass to the executable
env: Vec<(String, String)>
Environment to pass to the sandbox
mount_paths: Vec<DirectoryMount>
Allowed paths inside the sandbox
working_directory: PathBuf
Working directory
stdin: Option<PathBuf>
Redirect stdin from this file
stdout: Option<PathBuf>
Redirect stdout from this file
stderr: Option<PathBuf>
Redirect stderr from this file
syscall_filter: Option<SyscallFilter>
Allow only these system calls in the sandbox
mount_tmpfs: bool
Mount a r/w tmpfs in /tmp and /dev/shm
wall_time_limit: Option<u64>
Wall time limit
cpu_core: Option<usize>
Set on which CPU core to run the sandbox
uid: usize
UID of the user inside the sandbox
gid: usize
GID of the user inside the sandbox
mount_proc: bool
Mount /proc
Implementations§
source§impl SandboxConfiguration
impl SandboxConfiguration
sourcepub fn build(&self) -> SandboxConfiguration
pub fn build(&self) -> SandboxConfiguration
Build the sandbox configuration
sourcepub fn time_limit(&mut self, time_limit: u64) -> &mut Self
pub fn time_limit(&mut self, time_limit: u64) -> &mut Self
Set the time limit in seconds
sourcepub fn memory_limit(&mut self, memory_limit: u64) -> &mut Self
pub fn memory_limit(&mut self, memory_limit: u64) -> &mut Self
Set the memory limit, in bytes
sourcepub fn stack_limit(&mut self, stack_limit: u64) -> &mut Self
pub fn stack_limit(&mut self, stack_limit: u64) -> &mut Self
Set the stack limit, in bytes
sourcepub fn stdin<P: Into<PathBuf>>(&mut self, stdin: P) -> &mut Self
pub fn stdin<P: Into<PathBuf>>(&mut self, stdin: P) -> &mut Self
Set the standard input file path
sourcepub fn stdout<P: Into<PathBuf>>(&mut self, stdout: P) -> &mut Self
pub fn stdout<P: Into<PathBuf>>(&mut self, stdout: P) -> &mut Self
Set the standard output file path
sourcepub fn stderr<P: Into<PathBuf>>(&mut self, stderr: P) -> &mut Self
pub fn stderr<P: Into<PathBuf>>(&mut self, stderr: P) -> &mut Self
Set the standard error file path
sourcepub fn executable<P: Into<PathBuf>>(&mut self, executable: P) -> &mut Self
pub fn executable<P: Into<PathBuf>>(&mut self, executable: P) -> &mut Self
Set the executable file path
sourcepub fn working_directory<P: Into<PathBuf>>(
&mut self,
working_directory: P
) -> &mut Self
pub fn working_directory<P: Into<PathBuf>>( &mut self, working_directory: P ) -> &mut Self
Set the working directory
sourcepub fn env<S: Into<String>, T: Into<String>>(
&mut self,
variable: S,
value: T
) -> &mut Self
pub fn env<S: Into<String>, T: Into<String>>( &mut self, variable: S, value: T ) -> &mut Self
Add an argument to the environment
sourcepub fn mount<P, Q>(&mut self, source: P, target: Q, writable: bool) -> &mut Selfwhere
P: Into<PathBuf>,
Q: Into<PathBuf>,
pub fn mount<P, Q>(&mut self, source: P, target: Q, writable: bool) -> &mut Selfwhere P: Into<PathBuf>, Q: Into<PathBuf>,
Add a mount point into the sandbox
sourcepub fn syscall_filter(&mut self, filter: SyscallFilter) -> &mut Self
pub fn syscall_filter(&mut self, filter: SyscallFilter) -> &mut Self
Install the syscall filter
sourcepub fn mount_tmpfs(&mut self, value: bool) -> &mut Self
pub fn mount_tmpfs(&mut self, value: bool) -> &mut Self
Mount a r/w tmpfs in /tmp and /dev/shm
sourcepub fn wall_time_limit(&mut self, value: u64) -> &mut Self
pub fn wall_time_limit(&mut self, value: u64) -> &mut Self
Set wall time limit
sourcepub fn run_on_core(&mut self, value: usize) -> &mut Self
pub fn run_on_core(&mut self, value: usize) -> &mut Self
Run the sandbox on the specified cpu core
sourcepub fn mount_proc(&mut self, mount_proc: bool) -> &mut Self
pub fn mount_proc(&mut self, mount_proc: bool) -> &mut Self
Set mount /proc
Trait Implementations§
source§impl Clone for SandboxConfiguration
impl Clone for SandboxConfiguration
source§fn clone(&self) -> SandboxConfiguration
fn clone(&self) -> SandboxConfiguration
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more