summaryrefslogtreecommitdiff
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
parent607ab97ac64f597e78ab321aedd3063f8e040074 (diff)
downloadnix-c925beddeed1d2ab0a6f3ab7f13e06420c3fd889.zip
Add FreeBSD, OpenBSD support for setresuid/setresgid
-rw-r--r--CHANGELOG.md2
-rw-r--r--src/unistd.rs18
2 files changed, 16 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f1d278d6..75346799 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
has changed type from `c_int` to `SockProtocol`.
It accepts a `None` value for default protocol that was specified with zero using `c_int`.
([#647](https://github.com/nix-rust/nix/pull/647))
+- Exposed `unistd::setresuid` and `unistd::setresgid` on FreeBSD and OpenBSD
+ ([#721](https://github.com/nix-rust/nix/pull/721))
## [0.9.0] 2017-07-23
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))