25 releases (15 breaking)

0.16.2 Nov 12, 2022
0.16.1 Sep 11, 2021
0.16.0 Aug 1, 2021
0.15.0 Oct 6, 2020
0.7.0 Jul 22, 2018

#178 in Unix APIs

Download history 453/week @ 2023-02-11 359/week @ 2023-02-18 366/week @ 2023-02-25 336/week @ 2023-03-04 299/week @ 2023-03-11 246/week @ 2023-03-18 366/week @ 2023-03-25 309/week @ 2023-04-01 260/week @ 2023-04-08 211/week @ 2023-04-15 228/week @ 2023-04-22 253/week @ 2023-04-29 249/week @ 2023-05-06 184/week @ 2023-05-13 225/week @ 2023-05-20 207/week @ 2023-05-27

899 downloads per month
Used in 5 crates

MIT/Apache and LGPL-2.1

99KB
5K SLoC

syscallz-rs Build Status crates.io docs.rs

Simple seccomp library for rust. Please note that the syscall list is incomplete and you might need to send a PR to get your syscalls included. This crate releases frequently if the syscall list has been updated.

# Cargo.toml
[dependencies]
syscallz = "0.16"

License

MIT/Apache-2.0


lib.rs:

Simple seccomp library for rust. Please note that the syscall list is incomplete and you might need to send a PR to get your syscalls included. This crate releases frequently if the syscall list has been updated.

Example

use syscallz::{Context, Syscall, Action};

fn main() -> syscallz::Result<()> {

    // The default action if no other rule matches is syscallz::DEFAULT_KILL
    // For a different default use `Context::init_with_action`
    let mut ctx = Context::init()?;

    // Allow-list some syscalls
    ctx.allow_syscall(Syscall::open);
    ctx.allow_syscall(Syscall::getpid);
    // Set a specific action for a syscall
    ctx.set_action_for_syscall(Action::Errno(1), Syscall::execve);

    // Enforce the seccomp filter
    ctx.load()?;

    Ok(())
}

Dependencies

~2MB
~42K SLoC