Skip to content

Commit

Permalink
Add setresuid and setresgid
Browse files Browse the repository at this point in the history
These were both recently added to libc, add wrappers.

Signed-off-by: Dylan Reid <dgreid@chromium.org>
  • Loading branch information
dgreid committed Oct 25, 2016
1 parent 284c9f4 commit 5b0452a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ pub fn mkstemp<P: ?Sized + NixPath>(template: &P) -> Result<(RawFd, PathBuf)> {

#[cfg(any(target_os = "linux", target_os = "android"))]
mod linux {
use libc::{self, uid_t, gid_t};
use sys::syscall::{syscall, SYSPIVOTROOT};
use {Errno, Result, NixPath};

Expand All @@ -587,6 +588,20 @@ mod linux {
Errno::result(res).map(drop)
}

#[inline]
pub fn setresuid(ruid: uid_t, euid: uid_t, suid: uid_t) -> Result<()> {
let res = unsafe { libc::setresuid(ruid, euid, suid) };

Errno::result(res).map(drop)
}

#[inline]
pub fn setresgid(rgid: gid_t, egid: gid_t, sgid: gid_t) -> Result<()> {
let res = unsafe { libc::setresgid(rgid, egid, sgid) };

Errno::result(res).map(drop)
}

#[inline]
#[cfg(feature = "execvpe")]
pub fn execvpe(filename: &CString, args: &[CString], env: &[CString]) -> Result<()> {
Expand Down

0 comments on commit 5b0452a

Please sign in to comment.