Struct extrasafe::SafetyContext
source · [−]pub struct SafetyContext { /* private fields */ }Expand description
A struct representing a set of rules to be loaded into a seccomp filter and applied to the current thread, or all threads in the current process.
Create with new(). Add RuleSets with enable(), and then use apply_to_current_thread()
to apply the filters to the current thread, or apply_to_all_threads() to apply the filter to
all threads in the process.
Implementations
sourceimpl SafetyContext
impl SafetyContext
sourcepub fn new() -> SafetyContext
pub fn new() -> SafetyContext
Create a new SafetyContext. The seccomp filters will not be loaded until either
apply_to_current_thread or
apply_to_all_threads is called.
sourcepub fn enable(
self,
policy: impl RuleSet
) -> Result<SafetyContext, ExtraSafeError>
pub fn enable(
self,
policy: impl RuleSet
) -> Result<SafetyContext, ExtraSafeError>
Enable the simple and conditional rules provided by the RuleSet.
Errors
Will return ExtraSafeError::ConditionalNoEffectError if a conditional rule is enabled at
the same time as a simple rule for a syscall, which would override the conditional rule.
sourcepub fn apply_to_current_thread(self) -> Result<(), ExtraSafeError>
pub fn apply_to_current_thread(self) -> Result<(), ExtraSafeError>
Load the SafetyContext’s rules into a seccomp filter and apply the filter to the current
thread.
Errors
May return ExtraSafeError::SeccompError.
sourcepub fn apply_to_all_threads(self) -> Result<(), ExtraSafeError>
pub fn apply_to_all_threads(self) -> Result<(), ExtraSafeError>
Load the SafetyContext’s rules into a seccomp filter and apply the filter to all threads in
this process.
Errors
May return ExtraSafeError::SeccompError.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for SafetyContext
impl Send for SafetyContext
impl Sync for SafetyContext
impl Unpin for SafetyContext
impl UnwindSafe for SafetyContext
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more