Struct syscallz::Context

source ·
pub struct Context { /* private fields */ }
Expand description

The context to configure and enforce seccomp rules

Implementations§

source§

impl Context

source

pub fn init() -> Result<Context>

Create a new seccomp context and use DEFAULT_KILL as the default action.

source

pub fn init_with_action(default_action: Action) -> Result<Context>

Create a new seccomp context with the given Action as default action.

source

pub fn allow_syscall(&mut self, syscall: Syscall) -> Result<()>

Allow the given syscall regardless of the arguments.

source

pub fn set_action_for_syscall( &mut self, action: Action, syscall: Syscall ) -> Result<()>

Execute the given action for the given syscall. This can be used to either allow or deny a syscall, regardless of the arguments.

source

pub fn set_rule_for_syscall( &mut self, action: Action, syscall: Syscall, comparators: &[Comparator] ) -> Result<()>

Execute a given action for a given syscall if the Comparators match the given arguments.

source

pub fn load(&self) -> Result<()>

Load and enforce the configured seccomp policy

source

pub fn export_bpf(&self, fd: &mut dyn AsRawFd) -> Result<()>

Generate and output the current seccomp filter in BPF (Berkeley Packet Filter) format. The output is suitable to be loaded into the kernel. The filter is written to the given file descriptor.

source

pub fn export_pfc(&self, fd: &mut dyn AsRawFd) -> Result<()>

Generate and output the current seccomp filter in PFC (Pseudo Filter Code) format. The output is human read and meant to be used for debugging for developers. The filter is written to the given file descriptor.

Trait Implementations§

source§

impl Drop for Context

source§

fn drop(&mut self)

Executes the destructor for this type. 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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.