endpoint_sec/event/
event_login_logout.rs

1//! [`EventLoginLogout`]
2
3use std::ffi::OsStr;
4
5use endpoint_sec_sys::{es_event_login_logout_t, uid_t};
6
7/// Authenticated logout event from `/usr/bin/login`.
8#[doc(alias = "es_event_login_logout_t")]
9pub struct EventLoginLogout<'a> {
10    /// Raw event
11    pub(crate) raw: &'a es_event_login_logout_t,
12}
13
14impl<'a> EventLoginLogout<'a> {
15    /// Username used for login.
16    #[inline(always)]
17    pub fn username(&self) -> &'a OsStr {
18        // Safety: 'a tied to self, object obtained through ES
19        unsafe { self.raw.username.as_os_str() }
20    }
21
22    /// UID of user that was logged out.
23    #[inline(always)]
24    pub fn uid(&self) -> uid_t {
25        self.raw.uid
26    }
27}
28
29// Safety: safe to send across threads: does not contain any interior mutability nor depend on current thread state
30unsafe impl Send for EventLoginLogout<'_> {}
31// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
32unsafe impl Sync for EventLoginLogout<'_> {}
33
34impl_debug_eq_hash_with_functions!(EventLoginLogout<'a>; username, uid);