summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWesley Moore <wes@wezm.net>2017-08-07 18:00:58 +1000
committerWesley Moore <wes@wezm.net>2017-08-08 06:58:58 +1000
commitc925beddeed1d2ab0a6f3ab7f13e06420c3fd889 (patch)
tree4ed6cb9700e48812fed5a7acdbbeddc55d0bf51c /src
parent607ab97ac64f597e78ab321aedd3063f8e040074 (diff)
downloadnix-c925beddeed1d2ab0a6f3ab7f13e06420c3fd889.zip
Add FreeBSD, OpenBSD support for setresuid/setresgid
Diffstat (limited to 'src')
-rw-r--r--src/unistd.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/unistd.rs b/src/unistd.rs
index 19f82ef6..47057e34 100644
--- a/src/unistd.rs
+++ b/src/unistd.rs
@@ -15,9 +15,13 @@ use void::Void;
use sys::stat::Mode;
use std::fmt;
-#[cfg(any(target_os = "linux", target_os = "android"))]
+#[cfg(any(target_os = "android", target_os = "linux"))]
pub use self::linux::*;
+#[cfg(any(target_os = "android", target_os = "freebsd",
+ target_os = "linux", target_os = "openbsd"))]
+pub use self::setres::*;
+
/// User identifier
///
/// Newtype pattern around `uid_t` (which is just alias). It prevents bugs caused by accidentally
@@ -1601,12 +1605,10 @@ pub fn sysconf(var: SysconfVar) -> Result<Option<c_long>> {
}
}
-#[cfg(any(target_os = "linux", target_os = "android"))]
+#[cfg(any(target_os = "android", target_os = "linux"))]
mod linux {
- use libc;
use sys::syscall::{syscall, SYSPIVOTROOT};
use {Errno, Result, NixPath};
- use super::{Uid, Gid};
pub fn pivot_root<P1: ?Sized + NixPath, P2: ?Sized + NixPath>(
new_root: &P1, put_old: &P2) -> Result<()> {
@@ -1620,6 +1622,14 @@ mod linux {
Errno::result(res).map(drop)
}
+}
+
+#[cfg(any(target_os = "android", target_os = "freebsd",
+ target_os = "linux", target_os = "openbsd"))]
+mod setres {
+ use libc;
+ use {Errno, Result};
+ use super::{Uid, Gid};
/// Sets the real, effective, and saved uid.
/// ([see setresuid(2)](http://man7.org/linux/man-pages/man2/setresuid.2.html))