setuid/setuid.rs
1extern crate seccomp_droundy;
2extern crate libc;
3
4use seccomp_droundy::*;
5
6fn main() {
7 let mut ctx = Context::default(Action::Allow).unwrap();
8 let rule = Rule::new(105 /* setuid on x86_64 */,
9 Compare::arg(0)
10 .with(1000)
11 .using(Op::Eq)
12 .build().unwrap(),
13 Action::Errno(libc::EPERM) /* return EPERM */
14 );
15 ctx.add_rule(rule).unwrap();
16 ctx.load().unwrap();
17 let ret = unsafe { libc::setuid(1000) };
18 println!("ret = {}, uid = {}", ret, unsafe { libc::getuid() });
19}