3 releases

Uses old Rust 2015

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

#831 in Unix APIs

21 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

~59KB