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

source

pub fn build(&self) -> SandboxConfiguration

Build the sandbox configuration

source

pub fn time_limit(&mut self, time_limit: u64) -> &mut Self

Set the time limit in seconds

source

pub fn memory_limit(&mut self, memory_limit: u64) -> &mut Self

Set the memory limit, in bytes

source

pub fn stack_limit(&mut self, stack_limit: u64) -> &mut Self

Set the stack limit, in bytes

source

pub fn stdin<P: Into<PathBuf>>(&mut self, stdin: P) -> &mut Self

Set the standard input file path

source

pub fn stdout<P: Into<PathBuf>>(&mut self, stdout: P) -> &mut Self

Set the standard output file path

source

pub fn stderr<P: Into<PathBuf>>(&mut self, stderr: P) -> &mut Self

Set the standard error file path

source

pub fn executable<P: Into<PathBuf>>(&mut self, executable: P) -> &mut Self

Set the executable file path

source

pub fn working_directory<P: Into<PathBuf>>( &mut self, working_directory: P ) -> &mut Self

Set the working directory

source

pub fn arg<S: Into<String>>(&mut self, arg: S) -> &mut Self

Add an argument to the program

source

pub fn env<S: Into<String>, T: Into<String>>( &mut self, variable: S, value: T ) -> &mut Self

Add an argument to the environment

source

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

source

pub fn syscall_filter(&mut self, filter: SyscallFilter) -> &mut Self

Install the syscall filter

source

pub fn mount_tmpfs(&mut self, value: bool) -> &mut Self

Mount a r/w tmpfs in /tmp and /dev/shm

source

pub fn wall_time_limit(&mut self, value: u64) -> &mut Self

Set wall time limit

source

pub fn run_on_core(&mut self, value: usize) -> &mut Self

Run the sandbox on the specified cpu core

source

pub fn uid(&mut self, uid: usize) -> &mut Self

Set the UID of the user inside the sandbox

source

pub fn gid(&mut self, gid: usize) -> &mut Self

Set the GID of the user inside the sandbox

source

pub fn mount_proc(&mut self, mount_proc: bool) -> &mut Self

Set mount /proc

Trait Implementations§

source§

impl Clone for SandboxConfiguration

source§

fn clone(&self) -> SandboxConfiguration

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SandboxConfiguration

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for SandboxConfiguration

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for SandboxConfiguration

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for SandboxConfiguration

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,