diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index a5a2fc61d507d..69c1efbbcd1ac 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -283,6 +283,11 @@ s! { pub msg_len: ::c_uint, } + pub struct __exit_status { + pub e_termination: u16, + pub e_exit: u16, + } + pub struct shmid_ds { pub shm_perm: ::ipc_perm, pub shm_segsz: ::size_t, @@ -297,6 +302,28 @@ s! { } s_no_extra_traits! { + + pub struct utmpx { + pub ut_name: [::c_char; _UTX_USERSIZE], + pub ut_id: [::c_char; _UTX_IDSIZE], + pub ut_line: [::c_char; _UTX_LINESIZE], + pub ut_host: [::c_char; _UTX_HOSTSIZE], + pub ut_session: u16, + pub ut_type: u16, + pub ut_pid: ::pid_t, + pub ut_exit: __exit_status, + pub ut_ss: sockaddr_storage, + pub ut_tv: ::timeval, + pub ut_pad: [u8; _UTX_PADSIZE], + } + + pub struct lastlogx { + pub ll_tv: ::timeval, + pub ll_line: [::c_char; _UTX_LINESIZE], + pub ll_host: [::c_char; _UTX_HOSTSIZE], + pub ll_ss: sockaddr_storage, + } + pub struct in_pktinfo { pub ipi_addr: ::in_addr, pub ipi_ifindex: ::c_uint, @@ -390,6 +417,97 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { + impl PartialEq for utmpx { + fn eq(&self, other: &utmpx) -> bool { + self.ut_type == other.ut_type + && self.ut_pid == other.ut_pid + && self.ut_name == other.ut_name + && self.ut_line == other.ut_line + && self.ut_id == other.ut_id + && self.ut_exit == other.ut_exit + && self.ut_session == other.ut_session + && self.ut_tv == other.ut_tv + && self.ut_ss == other.ut_ss + && self + .ut_pad + .iter() + .zip(other.ut_pad.iter()) + .all(|(a,b)| a == b) + && self + .ut_host + .iter() + .zip(other.ut_host.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for utmpx {} + + impl ::fmt::Debug for utmpx { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("utmpx") + .field("ut_name", &self.ut_name) + .field("ut_id", &self.ut_id) + .field("ut_line", &self.ut_line) + .field("ut_host", &self.ut_host) + .field("ut_session", &self.ut_session) + .field("ut_type", &self.ut_type) + .field("ut_pid", &self.ut_pid) + .field("ut_exit", &self.ut_exit) + .field("ut_ss", &self.ut_ss) + .field("ut_tv", &self.ut_tv) + .field("ut_pad", &self.ut_pad) + .finish() + } + } + + impl ::hash::Hash for utmpx { + fn hash(&self, state: &mut H) { + self.ut_name.hash(state); + self.ut_type.hash(state); + self.ut_pid.hash(state); + self.ut_line.hash(state); + self.ut_id.hash(state); + self.ut_host.hash(state); + self.ut_exit.hash(state); + self.ut_session.hash(state); + self.ut_tv.hash(state); + self.ut_ss.hash(state); + self.ut_pad.hash(state); + } + } + + impl PartialEq for lastlogx { + fn eq(&self, other: &lastlogx) -> bool { + self.ll_tv == other.ll_tv + && self.ll_line == other.ll_line + && self.ll_host == other.ll_host + && self.ll_ss == other.ll_ss + } + } + + impl Eq for lastlogx {} + + impl ::fmt::Debug for lastlogx { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("lastlogx") + .field("ll_tv", &self.ll_tv) + .field("ll_line", &self.ll_line) + .field("ll_host", &self.ll_host) + .field("ll_ss", &self.ll_ss) + .finish() + } + } + + impl ::hash::Hash for lastlogx { + fn hash(&self, state: &mut H) { + self.ll_tv.hash(state); + self.ll_line.hash(state); + self.ll_host.hash(state); + self.ll_ss.hash(state); + } + } + impl PartialEq for in_pktinfo { fn eq(&self, other: &in_pktinfo) -> bool { self.ipi_addr == other.ipi_addr @@ -1391,6 +1509,28 @@ pub const ONLRET: ::tcflag_t = 0x40; pub const CDTRCTS: ::tcflag_t = 0x00020000; pub const CHWFLOW: ::tcflag_t = ::MDMBUF | ::CRTSCTS | ::CDTRCTS; +// pub const _PATH_UTMPX: &[::c_char; 14] = b"/var/run/utmpx"; +// pub const _PATH_WTMPX: &[::c_char; 14] = b"/var/log/wtmpx"; +// pub const _PATH_LASTLOGX: &[::c_char; 17] = b"/var/log/lastlogx"; +// pub const _PATH_UTMP_UPDATE: &[::c_char; 24] = b"/usr/libexec/utmp_update"; +pub const _UTX_USERSIZE: usize = 32; +pub const _UTX_LINESIZE: usize = 32; +pub const _UTX_PADSIZE: usize = 40; +pub const _UTX_IDSIZE: usize = 4; +pub const _UTX_HOSTSIZE: usize = 256; +pub const EMPTY: u16 = 0; +pub const RUN_LVL: u16 = 1; +pub const BOOT_TIME: u16 = 2; +pub const OLD_TIME: u16 = 3; +pub const NEW_TIME: u16 = 4; +pub const INIT_PROCESS: u16 = 5; +pub const LOGIN_PROCESS: u16 = 6; +pub const USER_PROCESS: u16 = 7; +pub const DEAD_PROCESS: u16 = 8; +pub const ACCOUNTING: u16 = 9; +pub const SIGNATURE: u16 = 10; +pub const DOWN_TIME: u16 = 11; + pub const SOCK_CLOEXEC: ::c_int = 0x10000000; pub const SOCK_NONBLOCK: ::c_int = 0x20000000; @@ -1751,6 +1891,28 @@ extern "C" { buflen: ::size_t, result: *mut *mut ::group, ) -> ::c_int; + + pub fn updwtmpx(file: *const ::c_char, ut: *const utmpx) -> ::c_int; + pub fn getlastlogx( + fname: *const ::c_char, + uid: ::uid_t, + ll: *mut lastlogx, + ) -> *mut lastlogx; + pub fn updlastlogx( + fname: *const ::c_char, + uid: ::uid_t, + ll: *mut lastlogx, + ) -> ::c_int; + pub fn utmpxname(file: *const ::c_char) -> ::c_int; + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + pub fn setutxent(); + pub fn endutxent(); +// TODO: uncomment after utmp implementation +// pub fn getutmp(ux: *const utmpx, u: *mut utmp); +// pub fn getutmpx(u: *const utmp, ux: *mut utmpx); } cfg_if! {