Struct endpoint_sec::Client
source · pub struct Client { /* private fields */ }Expand description
Wrapper around the opaque type that stores the ES client state.
Note: this implementation ignores the return value of es_delete_client if you use Drop,
use Client::delete() instead if you want to check it.
This type is neither Send nor Sync because the client must be released on the same
thread it was created.
Implementations§
source§impl Client
impl Client
Public bindings to the underlying es_client_t API.
sourcepub fn new<F>(handler: F) -> Result<Self, NewClientError>where
F: Fn(&mut Client, Message) + RefUnwindSafe + 'static,
pub fn new<F>(handler: F) -> Result<Self, NewClientError>where F: Fn(&mut Client, Message) + RefUnwindSafe + 'static,
Creates a new Client.
Callers must respect the following requirement if they want this function to succeed:
- Have the necessary entitlement for Endpoint Security
- Have the user’s approval (TCC)
- Be running as root when launching the client (and while it is active)
- Not have previously reached the maximum number of connected clients
See es_new_client().
sourcepub fn subscribe(
&mut self,
events: &[es_event_type_t]
) -> Result<(), ReturnError>
pub fn subscribe( &mut self, events: &[es_event_type_t] ) -> Result<(), ReturnError>
Subscribe the client to events, without removing previous subscriptions.
Panics
events can contain at most u32::MAX elements. This is a limitation of Apple’s API.
See es_subscribe.
sourcepub fn unsubscribe(
&mut self,
events: &[es_event_type_t]
) -> Result<(), ReturnError>
pub fn unsubscribe( &mut self, events: &[es_event_type_t] ) -> Result<(), ReturnError>
Unsubscribe the client from events, without removing other subscriptions.
Panics
events can contain at most u32::MAX elements. This is a limitation of Apple’s API.
See es_unsubscribe.
sourcepub fn unsubscribe_all(&mut self) -> Result<(), ReturnError>
pub fn unsubscribe_all(&mut self) -> Result<(), ReturnError>
Unsubscribe the client from all its current subscriptions.
See es_unsubscribe_all.
sourcepub fn subscriptions(&mut self) -> Result<Vec<es_event_type_t>, ReturnError>
pub fn subscriptions(&mut self) -> Result<Vec<es_event_type_t>, ReturnError>
List current subscriptions of client.
See es_subscriptions.
sourcepub fn respond_auth_result(
&mut self,
msg: &Message,
resp: es_auth_result_t,
cache: bool
) -> Result<(), RespondError>
pub fn respond_auth_result( &mut self, msg: &Message, resp: es_auth_result_t, cache: bool ) -> Result<(), RespondError>
Respond to an auth event.
sourcepub fn respond_flags_result(
&mut self,
msg: &Message,
authorized_flags: u32,
cache: bool
) -> Result<(), RespondError>
pub fn respond_flags_result( &mut self, msg: &Message, authorized_flags: u32, cache: bool ) -> Result<(), RespondError>
Respong to an auth event that needs a flag response.
sourcepub fn mute_process(&mut self, process: &AuditToken) -> Result<(), ReturnError>
pub fn mute_process(&mut self, process: &AuditToken) -> Result<(), ReturnError>
Fully mute the given process.
See es_mute_process.
sourcepub fn mute_process_events(
&mut self,
process: &AuditToken,
events: &[es_event_type_t]
) -> Result<(), ReturnError>
Available on crate feature macos_12_0_0 only.
pub fn mute_process_events( &mut self, process: &AuditToken, events: &[es_event_type_t] ) -> Result<(), ReturnError>
macos_12_0_0 only.Mute only some events for the given process.
Only available on macOS 12.0+.
sourcepub fn unmute_process(
&mut self,
process: &AuditToken
) -> Result<(), ReturnError>
pub fn unmute_process( &mut self, process: &AuditToken ) -> Result<(), ReturnError>
Fully unmute the given process.
See es_unmute_process.
sourcepub fn unmute_process_events(
&mut self,
process: &AuditToken,
events: &[es_event_type_t]
) -> Result<(), ReturnError>
Available on crate feature macos_12_0_0 only.
pub fn unmute_process_events( &mut self, process: &AuditToken, events: &[es_event_type_t] ) -> Result<(), ReturnError>
macos_12_0_0 only.Unmute only some events for the given process.
Only available on macOS 12.0+.
sourcepub fn muted_processes(&mut self) -> Result<Vec<AuditToken>, ReturnError>
pub fn muted_processes(&mut self) -> Result<Vec<AuditToken>, ReturnError>
List muted processes.
The returned AuditToken are in the same state as they were passed in to
Self::mute_process() and may not accuretly reflect the current state of the respective processes.
See es_muted_processes.
Deprecated in macOS 12.0+
sourcepub fn muted_processes_events(
&mut self
) -> Result<Vec<MutedProcess>, ReturnError>
Available on crate feature macos_12_0_0 only.
pub fn muted_processes_events( &mut self ) -> Result<Vec<MutedProcess>, ReturnError>
macos_12_0_0 only.List muted processes with additional informations
See es_muted_processes_events.
Only available on macOS 12.0+.
sourcepub fn mute_path(
&mut self,
path: &OsStr,
ty: es_mute_path_type_t
) -> Result<(), ReturnError>
pub fn mute_path( &mut self, path: &OsStr, ty: es_mute_path_type_t ) -> Result<(), ReturnError>
Mute a path for all event types.
See es_mute_path.
Note
The C function takes a const char * _Nonnull path, which means it expects a nul-
terminated string. Since the functions to gather such paths give OsStrings (ex:
Self::muted_paths_events), this method will truncate the given path to the first