Crate endpoint_sec_sys
source ·Expand description
Raw manual bindings for the Endpoint Security Framework for Apple targets (macOS) (referred to as ES in the following documentation).
Everything that was not present in the original release is feature gated to the macOS version
that saw it released, so you can ensure you don’t use any newer functions and types. Additional
checks are done at runtime to return None or an Err when using something not yet available,
in the endpoint-sec crate. This crate does not perform the checks since it contains the
raw types and extern "C" declaration. This is done because 1) the performance hit of a version
check is negligible in my experience and 2) even if compiled for a newer version where
information A is available, your program will still be able to handle older versions since A
will be returned in an Option.
Debug implementations (and PartialEq, Eq, Hash)
Several types do not have a Debug implementation because it depends on the es_message_t
version field. In this case, use the endpoint-sec crate, which bundle the version with
the data (for example with es_event_exec_t), allowing to implement Debug, PartialEq,
Eq and Hash correctly.
For lots of other types, it’s because the implementation would be useless because they contain
pointers like es_string_token_t: implementing Debug for it in a useful way needs unsafe
code that we don’t want to hide in a Debug impl. See the endpoint-sec crate, with its
higher level types for useful Debug impls (and PartialEq, Eq, Hash).
Re-exports
pub use block2;
Structs
- A wrapper type around
*mut Tto communicate a pointer should not be null without introducing undefined behaviour. - _acl
macos_10_15_1Never use directly, useacl_tinstead - The audit token is an opaque token which identifies Mach tasks and senders of Mach messages as subjects to the BSM audit system. Only the appropriate BSM library routines should be used to interpret the contents of the audit token as the representation of the subject identity within the token may change over time.
- Type of action to take after receiving a message
- Type of a network address.
- Valid authorization values to be used when responding to a
es_message_tauth event - This enum describes the types of authentications that
ES_EVENT_TYPE_NOTIFY_AUTHENTICATIONcan describe. - Type of launch item.
- es_btm_launch_item_t
macos_13_0_0Structure describing a BTM launch item - Error conditions for clearing the authorisation caches
- Opaque type that stores the endpoint security client state.
- es_event_access_t
macos_10_15_1Test file access - es_event_authentication_auto_unlock_t
macos_13_0_0Auto Unlock authentication data for typeES_AUTHENTICATION_TYPE_TOKEN. - es_event_authentication_od_t
macos_13_0_0OpenDirectory authentication data for typeES_AUTHENTICATION_TYPE_OD. - es_event_authentication_t
macos_13_0_0Notification that an authentication was performed. - es_event_authentication_token_t
macos_13_0_0Token authentication data for typeES_AUTHENTICATION_TYPE_TOKEN. - es_event_authentication_touchid_t
macos_13_0_0TouchID authentication data for typeES_AUTHENTICATION_TYPE_TOUCHID. - es_event_btm_launch_item_add_t
macos_13_0_0Notification for launch item being made known to background task management. This includes launch agents and daemons as well as login items added by the user, via MDM or by an app. - es_event_btm_launch_item_remove_t
macos_13_0_0Notification for launch item being removed from background task management. This includes launch agents and daemons as well as login items added by the user, via MDM or by an app. - es_event_chdir_t
macos_10_15_1Changes directories - es_event_chroot_t
macos_10_15_1Changes the root directory for a process - es_event_clone_t
macos_10_15_1Clone a file - Close a file descriptor
- es_event_copyfile_t
macos_12_0_0Copy a file using the copyfile syscall. - Create a file system object.
- es_event_create_t_anon_1_anon_0
macos_10_15_1 - es_event_cs_invalidated_t
macos_11_0_0Code signing status for process was invalidated. - es_event_deleteextattr_t
macos_10_15_1Delete an extended attribute - es_event_dup_t
macos_10_15_1Duplicate a file descriptor - Exchange data atomically between two files
- Execute a new process
- See [
es_event_exec_t_anon_0.anon_0] - Terminate a process
- es_event_fcntl_t
macos_10_15_1File control - Materialize a file via the
FileProviderframework - Update file contents via the
FileProviderframework - Fork a new process
- es_event_fsgetpath_t
macos_10_15_1Retrieve file system path based on FSID. - es_event_get_task_inspect_t
macos_11_3_0Get a process’s task inspect port. - es_event_get_task_name_t
macos_11_0_0Get a process’s task name port. - es_event_get_task_read_t
macos_11_3_0Get a process’s task read port. - Get a process’s task control port.
- es_event_getattrlist_t
macos_10_15_1Retrieve file system attributes - es_event_getextattr_t
macos_10_15_1Retrieve an extended attribute - Unique ID for an event
- Open a connection to an I/O Kit IOService.
- Load a kernel extension
- Unload a kernel extension
- Link to a file
- es_event_listextattr_t
macos_10_15_1List extended attributes of a file - es_event_login_login_t
macos_13_0_0Notification for authenticated login event from/usr/bin/login. - es_event_login_logout_t
macos_13_0_0Notification for authenticated logout event from/usr/bin/login. - Lookup a file system object.
- es_event_lw_session_lock_t
macos_13_0_0Notification that LoginWindow locked the screen of a session. - es_event_lw_session_login_t
macos_13_0_0Notification that LoginWindow has logged in a user. - es_event_lw_session_logout_t
macos_13_0_0Notification that LoginWindow has logged out a user. - es_event_lw_session_unlock_t
macos_13_0_0Notification that LoginWindow unlocked the screen of a session. - Memory map a file
- Mount a file system
- Control protection of pages
- Open a file system object.
- es_event_openssh_login_t
macos_13_0_0Notification for OpenSSH login event. - es_event_openssh_logout_t
macos_13_0_0Notification for OpenSSH logout event. - es_event_proc_check_t
macos_10_15_4Access control check for retrieving process information - es_event_proc_suspend_resume_t
macos_11_0_0Fired when one of pid_suspend, pid_resume or pid_shutdown_sockets is called on a process - es_event_pty_close_t
macos_10_15_4Fired when a pseudoterminal control device is closed - es_event_pty_grant_t
macos_10_15_4Fired when a pseudoterminal control device is granted - es_event_readdir_t
macos_10_15_1Read directory entries - Resolve a symbolic link.
- es_event_remote_thread_create_t
macos_11_0_0Notification that a process has attempted to create a thread in another process by calling one of thethread_createorthread_create_runningMIG routines - es_event_remount_t
macos_10_15_1Remount a file system - Rename a file system object.
- es_event_screensharing_attach_t
macos_13_0_0Notification that Screen Sharing has attached to a graphical session. - es_event_screensharing_detach_t
macos_13_0_0Notification that Screen Sharing has detached from a graphical session. - es_event_searchfs_t
macos_11_0_0Access control check for searching a volume or a mounted file system - es_event_setacl_t
macos_10_15_1Set a file ACL. - Modify file system attributes
- es_event_setegid_t
macos_12_0_0Notification that a process has calledsetegid() - es_event_seteuid_t
macos_12_0_0Notification that a process has calledseteuid() - Set an extended attribute
- Modify file flags information.
- es_event_setgid_t
macos_12_0_0Notification that a process has calledsetgid() - Modify file mode.
- Modify file owner information
- es_event_setregid_t
macos_12_0_0Notification that a process has calledsetregid() - es_event_setreuid_t
macos_12_0_0Notification that a process has calledsetreuid() - es_event_settime_t
macos_10_15_1Modify the system time - es_event_setuid_t
macos_12_0_0Notification that a process has calledsetuid() - Send a signal to a process.
- es_event_stat_t
macos_10_15_1View stat information of a file - es_event_trace_t
macos_11_0_0Fired when one process attempts to attach to another process - Truncate to a file
- The valid event types recognized by Endpoint Security.
- es_event_uipc_bind_t
macos_10_15_1Fired when a UNIX-domain socket is about to be bound to a path - es_event_uipc_connect_t
macos_10_15_1Fired when a UNIX-domain socket is about to be connected. - Unlink a file system object.
- Unmount a file system
- es_event_utimes_t
macos_10_15_1Change file access and modification times (e.g. viautimes(2)) - Write to a file
- es_event_xp_malware_detected_t
macos_13_0_0Notification that XProtect detected malware. - es_event_xp_malware_remediated_t
macos_13_0_0Notification that XProtect remediated malware. - es_fd_t
macos_11_0_0An open file descriptor - es_fd_t_anon_0_pipe
macos_11_0_0 - Provides the
statinformation and path to a file that relates to a security event. The path may be truncated, which is indicated by thepath_truncatedflag. - This is the top level datatype that encodes information sent from the ES subsystem to its clients. Each security event being processed by the ES subsystem will be encoded in an
es_message_t. A message can be an authorization request or a notification of an event that has already taken place. - Return type for mute inversion
- Values that will be paired with path strings to describe the type of the path
- Structure to describe attributes of a muted path
- Structure for a set of muted paths
- Structure to describe attributes of a muted process
- Structure for a set of muted processes
- Error conditions for creating a new client
- This enum describes the type of
es_event_proc_check_tevents that are currently used. - This enum describes the type of suspend/resume operations that are currently used
- Information related to a process. This is used both for describing processes that performed an action (e.g. in the case of the [
es_message_t.process] field, or are targets of an action (e.g. for exec events this describes the new process being executed, for signal events this describes the process that will receive the signal). - Error conditions for responding to a message
- Indicates the result of the ES subsystem authorization process
- Valid authorization values to be used when responding to a
es_message_tauth event - Return value for functions that can only fail in one way
- Whether an ACL is being set or cleared
- Structure for handling strings
- es_thread_state_t
macos_11_0_0Machine-specific thread state as used bythread_create_runningand other Mach API functions. - es_thread_t
macos_11_0_0Information related to a thread - Structure buffer with size
Enums
- Clearing authorisation caches failed.
- MuteInvertedType
macos_13_0_0Type of muting for a specifices_mute_inversion_type_t - MuteTypeError
macos_13_0_0Getting the mute type failed. - Creating a new client failed.
- OpenSSH login failed.
- Responding to a message failed.
- Basic error without additional informations.
- Equivalent to C’s
voidtype when used as a pointer.
Functions
- Extract the audit session ID from an
audit_token_t, used to identify Mach tasks and senders of Mach messages as subjects of the audit system. - Extract information from an
audit_token_t, used to identify Mach tasks and senders of Mach messages as subjects to the audit system.audit_tokent_to_au32()is the only method that should be used to parse anaudit_token_t, since its internal representation may change over time. A pointer parameter may beNULLif that information is not needed.audit_token_to_au32()has been deprecated because the terminal ID information is no longer saved in this token. The last parameter is actually the process ID version. The API callsaudit_token_to_auid(),audit_token_to_euid(),audit_token_to_ruid(),audit_token_to_rgid(),audit_token_to_pid(),audit_token_to_asid(), and/oraudit_token_to_pidversion()should be used instead. - Extract the audit user ID from an
audit_token_t, used to identify Mach tasks and senders of Mach messages as subjects of the audit system. - Extract the effective group ID from an
audit_token_t, used to identify Mach tasks and senders of Mach messages as subjects of the audit system. - Extract the effective user ID from an
audit_token_t, used to identify Mach tasks and senders of Mach messages as subjects of the audit system. - Extract the process ID from an
audit_token_t, used to identify Mach tasks and senders of Mach messages as subjects of the audit system. - Extract the process ID version from an
audit_token_t, used to identify Mach tasks and senders of Mach messages as subjects of the audit system. - Extract the real group ID from an
audit_token_t, used to identify Mach tasks and senders of Mach messages as subjects of the audit system. - Extract the real user ID from an
audit_token_t, used to identify Mach tasks and senders of Mach messages as subjects of the audit system. - Clear all cached results for all clients.
- Retains an
es_message_t, returning a non-const pointer to the givenes_message_tfor compatibility with existing code. - Destroy an
es_client_t, freeing resources and disconnecting from the ES subsystem - Get the argument at the specified position in the message containing an
es_event_exec_t - Get the number of arguments in a message containing an
es_event_exec_t - Get the environment variable at the specified position in the message containing an
es_event_exec_t - Get the number of environment variables in a message containing an
es_event_exec_t - es_exec_fd⚠
macos_11_0_0Get the file descriptor at the specified position in the message containing anes_event_exec_t - es_exec_fd_count⚠
macos_11_0_0Get the number of file descriptors in a message containing anes_event_exec_t - Releases the memory associated with the given
es_message_tthat was retained viaes_copy_message() - es_invert_muting⚠
macos_13_0_0Invert the mute state of a given mute dimension - Calculate the size of an
es_message_t. - es_mute_path⚠
macos_12_0_0Suppress all events matching a path. - es_mute_path_events⚠
macos_12_0_0Suppress a subset of events matching a path. - Suppress events matching a path literal
- Suppress events matching a path prefix
- Suppress all events from the process described by the given
audit_token - es_mute_process_events⚠
macos_12_0_0Suppress a subset of events from the process described by the givenaudit_token - es_muted_paths_events⚠
macos_12_0_0Retrieve a list of all muted paths. - List muted processes
- es_muted_processes_events⚠
macos_12_0_0Retrieve a list of all muted processes. - es_muting_inverted⚠
macos_13_0_0Query mute inversion state - Initialise a new
es_client_tand connect to the ES subsystem - es_release_message⚠
macos_11_0_0Releases the givenes_message_tthat was previously retained withes_retain_message() - es_release_muted_paths⚠
macos_12_0_0Delete a set of muted paths obtained fromes_muted_paths_events, freeing resources. - es_release_muted_processes⚠
macos_12_0_0Delete a set of muted processes obtained fromes_muted_processes_events, freeing resources. - Respond to an auth event that requires an
es_auth_result_tresponse - Respond to an auth event that requires an
u32flags response - es_retain_message⚠
macos_11_0_0Retains the givenes_message_t, extending its lifetime until released withes_release_message(). - Subscribe to some set of events
- List subscriptions
- Unmute all paths
- es_unmute_all_target_paths⚠
macos_13_0_0Unmute all target paths - es_unmute_path⚠
macos_12_0_0Unmute a path for all event types. - es_unmute_path_events⚠
macos_12_0_0Unmute a path for a subset of event types. - Unmute a process for all event types
- es_unmute_process_events⚠
macos_12_0_0Unmute a process for a subset of event types. - Unsubscribe from some set of events
- Unsubscribe from all events
- stat⚠
Type Definitions
- acl_t
macos_10_15_1Pointer to opaque type for Endpoint Security ACL. - Equivalent to C’s
signed int(int) type. - Equivalent to C’s
unsigned inttype. - Equivalent to C’s
unsigned shorttype. - cpu_subtype_t
macos_13_0_0 - cpu_type_t
macos_13_0_0 - es_graphical_session_id_t
macos_13_0_0A session identifier identifying a on-console or off-console graphical session. - The type of block that will be invoked to handled messages from the ES subsystem
- gid_tNeither
target_os="espidf"nortarget_os="horizon"nortarget_os="vita"nortarget_os="nto" - uid_tNeither
target_os="espidf"nortarget_os="horizon"nortarget_os="vita"nortarget_os="nto"
Unions
- es_event_authentication_t_anon0
macos_13_0_0 - es_event_authentication_touchid_t_anon0
macos_13_0_0 - See
es_event_close_t. - See [
es_event_exec_t.anon_0] - es_event_login_login_t_anon0
macos_13_0_0 - es_event_openssh_login_t_anon0
macos_13_0_0 - es_event_setacl_t_anon_0
macos_10_15_1 - Union of all possible events that can appear in an
es_message_t - es_fd_t_anon_0
macos_11_0_0See [es_fd_t_anon_0.anon_0] - See
es_result_t