Skip to content

Commit

Permalink
add setfsuid and setfsgid implementation for filesystem checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Conte committed Dec 15, 2019
1 parent 1282815 commit fe4e1d0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,26 @@ pub fn setgid(gid: Gid) -> Result<()> {
Errno::result(res).map(drop)
}

/// Set the user identity used for filesystem checks
///
/// See also [setfsuid(2)](http://man7.org/linux/man-pages/man2/setfsuid.2.html)
#[inline]
pub fn setfsuid(uid: Uid) -> Result<()> {
let res = unsafe { libc::setfsuid(uid.into()) };

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

/// Set the group identity used for filesystem checks
///
/// See also [setfsgid(2)](http://man7.org/linux/man-pages/man2/setfsgid.2.html)
#[inline]
pub fn setfsgid(gid: Gid) -> Result<()> {
let res = unsafe { libc::setfsgid(gid.into()) };

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

/// Get the list of supplementary group IDs of the calling process.
///
/// [Further reading](http://pubs.opengroup.org/onlinepubs/009695399/functions/getgroups.html)
Expand Down

0 comments on commit fe4e1d0

Please sign in to comment.