pub struct Filter { /* private fields */ }Expand description
The Filter is a wrapper around a SECCOMP Context.
This implementation has first-class support for the SECCOMP Notify
API, but a lot of the logic needs to be implemented in the
application. Firstly, implement the Notifier trait for
the calling process (The one that loads the filter). Then,
use a notify::Pair on the monitoring process. A working
implementation of both exist in Antimony.
§Examples
Load a basic rule that logs everything but read.
use seccomp::{filter::Filter, action::Action, attribute::Attribute, syscall::Syscall};
let mut filter = Filter::new(Action::Log).unwrap();
filter.set_attribute(Attribute::NoNewPrivileges(true)).unwrap();
filter.add_rule(Action::Allow, Syscall::from_name("read").unwrap()).unwrap();
filter.load();Implementations§
Source§impl Filter
impl Filter
Sourcepub fn new(def_action: Action) -> Result<Self, Error>
pub fn new(def_action: Action) -> Result<Self, Error>
Construct a new filter with a default action.
Sourcepub fn set_notifier(&mut self, f: impl Notifier)
pub fn set_notifier(&mut self, f: impl Notifier)
Set a notifier monitor process. See the Notifier trait for more information.
Sourcepub fn add_rule(
&mut self,
action: Action,
syscall: Syscall,
) -> Result<(), Error>
pub fn add_rule( &mut self, action: Action, syscall: Syscall, ) -> Result<(), Error>
Add a rule. Complex rules are not supported.
Sourcepub fn write(&self, path: &Path) -> Result<OwnedFd, Error>
pub fn write(&self, path: &Path) -> Result<OwnedFd, Error>
Write the filter to a new file with the BPF format of the filter.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Filter
impl !RefUnwindSafe for Filter
impl Unpin for Filter
impl !UnwindSafe for Filter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more