mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-10-01 12:20:39 +00:00
net: make UCred fields private (#2936)
This commit is contained in:
parent
2e05399f4b
commit
b047f647b7
@ -4,9 +4,21 @@ use libc::{gid_t, uid_t};
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
|
||||
pub struct UCred {
|
||||
/// UID (user ID) of the process
|
||||
pub uid: uid_t,
|
||||
uid: uid_t,
|
||||
/// GID (group ID) of the process
|
||||
pub gid: gid_t,
|
||||
gid: gid_t,
|
||||
}
|
||||
|
||||
impl UCred {
|
||||
/// Gets UID (user ID) of the process.
|
||||
pub fn uid(&self) -> uid_t {
|
||||
self.uid
|
||||
}
|
||||
|
||||
/// Gets GID (group ID) of the process.
|
||||
pub fn gid(&self) -> gid_t {
|
||||
self.gid
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
|
@ -25,6 +25,6 @@ async fn test_socket_pair() {
|
||||
let uid = unsafe { geteuid() };
|
||||
let gid = unsafe { getegid() };
|
||||
|
||||
assert_eq!(cred_a.uid, uid);
|
||||
assert_eq!(cred_a.gid, gid);
|
||||
assert_eq!(cred_a.uid(), uid);
|
||||
assert_eq!(cred_a.gid(), gid);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user