pub struct Compare { /* private fields */ }Expand description
Comparison definition builder
Implementations§
Source§impl Compare
impl Compare
Sourcepub fn arg(arg_num: u32) -> Self
pub fn arg(arg_num: u32) -> Self
argument number, starting at 0
Examples found in repository?
examples/setuid.rs (line 9)
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}Sourcepub fn using(self, op: Op) -> Self
pub fn using(self, op: Op) -> Self
Comparison operator
Examples found in repository?
examples/setuid.rs (line 11)
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}Sourcepub fn with(self, datum: u64) -> Self
pub fn with(self, datum: u64) -> Self
Datum to compare with
Examples found in repository?
examples/setuid.rs (line 10)
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}Sourcepub fn build(self) -> Option<Cmp>
pub fn build(self) -> Option<Cmp>
build comparison definition
Examples found in repository?
examples/setuid.rs (line 12)
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}Auto Trait Implementations§
impl Freeze for Compare
impl RefUnwindSafe for Compare
impl Send for Compare
impl Sync for Compare
impl Unpin for Compare
impl UnwindSafe for Compare
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more