26 releases (16 breaking)

0.17.0 Sep 28, 2023
0.16.2 Nov 12, 2022
0.16.1 Sep 11, 2021
0.15.0 Oct 6, 2020
0.7.0 Jul 22, 2018

#230 in Unix APIs

Download history 70/week @ 2023-12-11 81/week @ 2023-12-18 47/week @ 2023-12-25 128/week @ 2024-01-01 161/week @ 2024-01-08 85/week @ 2024-01-15 92/week @ 2024-01-22 106/week @ 2024-01-29 138/week @ 2024-02-05 147/week @ 2024-02-12 181/week @ 2024-02-19 250/week @ 2024-02-26 226/week @ 2024-03-04 162/week @ 2024-03-11 130/week @ 2024-03-18 123/week @ 2024-03-25

672 downloads per month
Used in 5 crates

MIT/Apache and LGPL-2.1

105KB
5.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

~0.5–1MB
~23K SLoC