1 unstable release

Uses old Rust 2015

0.1.0 Mar 11, 2018

#7 in #libseccomp


Used in 2 crates (via bigbro)

LGPL-2.1

33KB
985 lines

seccomp

This library provides a higher-level wrapper around libseccomp.

Add to Cargo.toml:

[dependencies]
seccomp-droundy = "0.1"

lib.rs:

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

Example usage:

extern crate seccomp_droundy;
extern crate libc;

use seccomp_droundy::*;

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

~705KB
~17K SLoC