SystemIO

Struct SystemIO 

Source
pub struct SystemIO { /* private fields */ }
Expand description

A RuleSet representing syscalls that perform IO - open/close/read/write/seek/stat.

Configurable to allow subsets of IO syscalls and specific fds.

Implementations§

Source§

impl SystemIO

Source

pub fn nothing() -> SystemIO

By default, allow no IO syscalls.

Source

pub fn everything() -> SystemIO

Allow all IO syscalls.

Source

pub fn allow_read(self) -> SystemIO

Allow read syscalls.

Source

pub fn allow_write(self) -> SystemIO

Allow write syscalls.

Allow unlink syscalls.

Source

pub fn allow_open(self) -> YesReally<SystemIO>

Allow open syscalls.

§Security

The reason this function returns a YesReally is because it’s easy to accidentally combine it with another ruleset that allows write - for example the Network ruleset - even if you only want to read files. Consider using allow_open_directory() or allow_open_file().

Source

pub fn allow_open_readonly(self) -> SystemIO

Allow open syscalls but not with write flags.

Note that the openat2 syscall (which is not exposed by glibc anyway according to the syscall manpage, and so probably isn’t very common) is not supported here because it has a separate configuration struct instead of a flag bitset.

Source

pub fn allow_metadata(self) -> SystemIO

Allow stat syscalls.

Source

pub fn allow_ioctl(self) -> SystemIO

Allow ioctl and fcntl syscalls.

Source

pub fn allow_close(self) -> SystemIO

Allow close syscalls.

Source

pub fn allow_stdin(self) -> SystemIO

Allow reading from stdin

Source

pub fn allow_stdout(self) -> SystemIO

Allow writing to stdout

Source

pub fn allow_stderr(self) -> SystemIO

Allow writing to stderr

Source

pub fn allow_file_read(self, file: &File) -> SystemIO

Allow reading a given open File. Note that with just this function, you will not be able to close the file under this context.

§Security considerations

If another file or socket is opened after the file provided to this function is closed, it’s possible that the fd will be reused and therefore may be read from.

Source

pub fn allow_file_write(self, file: &File) -> SystemIO

Allow writing to a given open File. Note that with just this, you will not be able to close the file under this context.

§Security considerations

If another file or socket is opened after the file provided to this function is closed, it’s possible that the fd will be reused and therefore may be written to.

Trait Implementations§

Source§

impl RuleSet for SystemIO

Source§

fn simple_rules(&self) -> Vec<Sysno>

A simple rule is a seccomp rule that just allows the syscall without restriction.
Source§

fn conditional_rules(&self) -> HashMap<Sysno, Vec<SeccompRule>>

A conditional rule is a seccomp rule that uses a condition to restrict the syscall, e.g. only specific flags as parameters.
Source§

fn name(&self) -> &'static str

The name of the profile.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.