Skip to main content

Handle

Struct Handle 

Source
pub struct Handle(/* private fields */);
Expand description

A handle to the netlink connection, used to send and receive netlink messsage

Implementations§

Source§

impl Handle

Source

pub fn request( &mut self, message: NetlinkMessage<AuditMessage>, ) -> Result<impl Stream<Item = NetlinkMessage<AuditMessage>>, Error>

Send a netlink message, and get the reponse as a stream of messages.

Source

pub async fn add_rule(&mut self, rule: RuleMessage) -> Result<(), Error>

Add the given rule

Source

pub async fn del_rule(&mut self, rule: RuleMessage) -> Result<(), Error>

Deletes a given rule

Source

pub fn list_rules(&mut self) -> impl TryStream<Ok = RuleMessage, Error = Error>

List the current rules

Source

pub async fn enable_events(&mut self) -> Result<(), Error>

Enable receiving events in this process.

This function enable events and set the PID in a single message.

This works well if done once in the process life. If however you need to disable and enable events, you will want to call the Handle::set_enabled and Handle::set_pid directly, so as to handle the errors in a more granular manner.

Source

pub async fn set_enabled(&mut self, value: bool) -> Result<(), Error>

Set whether to enable the audit daemon or not.

When enabling the audit daemon with this function, you should ensure that you set the PID of the current process already with a call to Handle::set_pid.

See Handle::enable_events for a more convenient helper to enable events in a single call.

Source

pub async fn set_pid(&mut self, pid: u32) -> Result<(), Error>

Set the PID to which audit messages should be addressed.

You probably want to use either:

  • Your own pid, to receive audit events
  • 0, to unset the PID restriction, for example when disabling the audit connection.
Source

pub async fn get_status(&mut self) -> Result<StatusMessage, Error>

Get current audit status

Source

pub async fn set_status(&mut self, status: StatusMessage) -> Result<(), Error>

Set the audit status

You must have properly set the mask field according to which fields must be set.

Trait Implementations§

Source§

impl Clone for Handle

Source§

fn clone(&self) -> Handle

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Handle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.