3 releases

Uses old Rust 2015

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

#935 in Unix APIs

Download history 3/week @ 2024-02-15 24/week @ 2024-02-22 12/week @ 2024-02-29 5/week @ 2024-03-07 12/week @ 2024-03-14

54 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