Mercurial > public > mercurial-scm > hg-stable
diff rust/chg/src/procutil.rs @ 39977:44840bcc411a
rust-chg: port basic socket path handling from cHg of C
This is basically modeled after setcmdserveropts() of chg.c.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 24 Sep 2018 18:33:46 +0900 |
parents | ba447b83cd56 |
children | 89742f1fa6cb |
line wrap: on
line diff
--- a/rust/chg/src/procutil.rs Mon Sep 24 18:21:10 2018 +0900 +++ b/rust/chg/src/procutil.rs Mon Sep 24 18:33:46 2018 +0900 @@ -15,6 +15,11 @@ fn sendfds(sockfd: c_int, fds: *const c_int, fdlen: size_t) -> ssize_t; } +/// Returns the effective uid of the current process. +pub fn get_effective_uid() -> u32 { + unsafe { libc::geteuid() } +} + /// Changes the given fd to blocking mode. pub fn set_blocking_fd(fd: RawFd) -> io::Result<()> { let flags = unsafe { libc::fcntl(fd, libc::F_GETFL) };