3 releases

Uses old Rust 2015

0.1.2 Oct 15, 2020
0.1.1 Apr 7, 2016
0.1.0 Apr 7, 2016

#796 in Unix APIs

Download history 3/week @ 2024-12-10 16/week @ 2025-02-04 72/week @ 2025-02-11 20/week @ 2025-02-18 12/week @ 2025-02-25 19/week @ 2025-03-04 10/week @ 2025-03-11 29/week @ 2025-03-18 4/week @ 2025-03-25

64 downloads per month

LGPL-2.1

9KB
187 lines

seccomp

This library provides a higher-level wrapper around libseccomp.

Add to Cargo.toml:

[dependencies]
seccomp = "0.1"

Documentation


lib.rs:

This crate is based on seccomp_sys and provides a higher level wrapper for libseccomp.

Example usage:

extern crate seccomp;
extern crate libc;

use seccomp::*;

fn main() {
    let mut ctx = Context::default(Action::Allow).unwrap();
    let rule = Rule::new(105 /* setuid on x86_64 */,
        Compare::arg(0)
                .with(1000)
                .using(Op::Eq)
                .build().unwrap(),
        Action::Errno(libc::EPERM) /* return EPERM */
    );
    ctx.add_rule(rule).unwrap();
    ctx.load().unwrap();
    let ret = unsafe { libc::setuid(1000) };
    println!("ret = {}, uid = {}", ret, unsafe { libc::getuid() });
}

Dependencies

~58KB