seccomp 0.1.2

higher-level bindings to libseccomp
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
extern crate libc;
extern crate seccomp;

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() });
}