Skip to content

Commit be7acc1

Browse files
committed
Merge #721
721: Enable setresuid/setresgid on FreeBSD and OpenBSD r=asomers Fixes #717 This PR enables `setresuid` and `setresgid` on FreeBSD and OpenBSD. These functions are not present on NetBSD, macOS, and iOS as far as I can tell.
2 parents 607ab97 + c925bed commit be7acc1

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1919
has changed type from `c_int` to `SockProtocol`.
2020
It accepts a `None` value for default protocol that was specified with zero using `c_int`.
2121
([#647](https://github.com/nix-rust/nix/pull/647))
22+
- Exposed `unistd::setresuid` and `unistd::setresgid` on FreeBSD and OpenBSD
23+
([#721](https://github.com/nix-rust/nix/pull/721))
2224

2325
## [0.9.0] 2017-07-23
2426

src/unistd.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ use void::Void;
1515
use sys::stat::Mode;
1616
use std::fmt;
1717

18-
#[cfg(any(target_os = "linux", target_os = "android"))]
18+
#[cfg(any(target_os = "android", target_os = "linux"))]
1919
pub use self::linux::*;
2020

21+
#[cfg(any(target_os = "android", target_os = "freebsd",
22+
target_os = "linux", target_os = "openbsd"))]
23+
pub use self::setres::*;
24+
2125
/// User identifier
2226
///
2327
/// 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>> {
16011605
}
16021606
}
16031607

1604-
#[cfg(any(target_os = "linux", target_os = "android"))]
1608+
#[cfg(any(target_os = "android", target_os = "linux"))]
16051609
mod linux {
1606-
use libc;
16071610
use sys::syscall::{syscall, SYSPIVOTROOT};
16081611
use {Errno, Result, NixPath};
1609-
use super::{Uid, Gid};
16101612

16111613
pub fn pivot_root<P1: ?Sized + NixPath, P2: ?Sized + NixPath>(
16121614
new_root: &P1, put_old: &P2) -> Result<()> {
@@ -1620,6 +1622,14 @@ mod linux {
16201622

16211623
Errno::result(res).map(drop)
16221624
}
1625+
}
1626+
1627+
#[cfg(any(target_os = "android", target_os = "freebsd",
1628+
target_os = "linux", target_os = "openbsd"))]
1629+
mod setres {
1630+
use libc;
1631+
use {Errno, Result};
1632+
use super::{Uid, Gid};
16231633

16241634
/// Sets the real, effective, and saved uid.
16251635
/// ([see setresuid(2)](http://man7.org/linux/man-pages/man2/setresuid.2.html))

0 commit comments

Comments
 (0)