1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! Module for OS processes and types abstractions.
pub mod group;
pub mod login_name;
pub mod passwd;
pub mod process;
pub mod time;
pub mod tty;
pub mod utsname;

// Specific Modules
#[cfg(not(any(target_os = "fuchsia", target_os = "haiku")))]
pub mod load;

#[cfg(any(target_os = "netbsd", target_os = "openbsd", target_os = "solaris"))]
pub mod utmp;

#[cfg(not(any(target_os = "fuchsia", target_os = "haiku", target_os = "openbsd")))]
pub mod utmpx;

#[cfg(any(target_os = "freebsd", target_os = "macos"))]
pub mod audit;

#[cfg(target_os = "openbsd")]
pub mod routing_table;

use libc::{
    c_int, getegid, geteuid, getgid, getuid, gid_t, pid_t, suseconds_t, time_t, timeval, tm, uid_t,
};

pub type Tm = tm;

/// Time stamp type used on system structures.
pub type TimeVal = timeval;

/// Group ID type.
pub type Gid = gid_t;

/// User ID type.
pub type Uid = uid_t;

/// Process ID Type.
pub type Pid = pid_t;

/// Passwd time type.
pub type Time = time_t;

/// Passwd field type.
pub type Fields = c_int;

/// Field for [`TimeVal`] in microseconds.
pub type Susec = suseconds_t;

/// Get the current running process user effective group id.
#[inline]
pub fn get_effective_gid() -> Uid { unsafe { getegid() } }

/// Get the current running process user real group id.
#[inline]
pub fn get_real_gid() -> Uid { unsafe { getgid() } }

/// Get the current running process user effective user id.
#[inline]
pub fn get_effective_uid() -> Uid { unsafe { geteuid() } }

/// Get the current running process user real user id.
#[inline]
pub fn get_real_uid() -> Uid { unsafe { getuid() } }