Compare

Struct Compare 

Source
pub struct Compare { /* private fields */ }
Expand description

Comparison definition builder

Implementations§

Source§

impl Compare

Source

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}
Source

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}
Source

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}
Source

pub fn and(self, datum: u64) -> Self

Second datum

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.