Skip to content

Commit

Permalink
Merge #1577
Browse files Browse the repository at this point in the history
1577: DragonFly 6.0 added fexecve(2) r=rtzoeller a=rtzoeller

Enable `fexecve()` on DragonFly, as it was added in the 6.0 release.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
  • Loading branch information
bors[bot] and rtzoeller authored Dec 22, 2021
2 parents 8eac0ee + 2eb6e88 commit 3e952d3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
## [Unreleased] - ReleaseDate
### Added

- Added `fexecve` on DragonFly.
(#[1577](https://github.com/nix-rust/nix/pull/1577))
- Added fine-grained features flags. Most Nix functionality can now be
conditionally enabled. By default, all features are enabled.
(#[1611](https://github.com/nix-rust/nix/pull/1611))
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ targets = [
]

[dependencies]
libc = { version = "0.2.102", features = [ "extra_traits" ] }
libc = { version = "0.2.112", features = [ "extra_traits" ] }
bitflags = "1.1"
cfg-if = "1.0"

Expand Down
4 changes: 1 addition & 3 deletions src/unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,11 +848,9 @@ pub fn execvpe<SA: AsRef<CStr>, SE: AsRef<CStr>>(filename: &CStr, args: &[SA], e
///
/// This function is similar to `execve`, except that the program to be executed
/// is referenced as a file descriptor instead of a path.
// Note for NetBSD and OpenBSD: although rust-lang/libc includes it (under
// unix/bsd/netbsdlike/) fexecve is not currently implemented on NetBSD nor on
// OpenBSD.
#[cfg(any(target_os = "android",
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd"))]
#[inline]
pub fn fexecve<SA: AsRef<CStr> ,SE: AsRef<CStr>>(fd: RawFd, args: &[SA], env: &[SE]) -> Result<Infallible> {
Expand Down
12 changes: 4 additions & 8 deletions test/test_unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,25 +363,21 @@ cfg_if!{
if #[cfg(target_os = "android")] {
execve_test_factory!(test_execve, execve, CString::new("/system/bin/sh").unwrap().as_c_str());
execve_test_factory!(test_fexecve, fexecve, File::open("/system/bin/sh").unwrap().into_raw_fd());
} else if #[cfg(any(target_os = "freebsd",
} else if #[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
target_os = "linux"))] {
// These tests frequently fail on musl, probably due to
// https://github.com/nix-rust/nix/issues/555
execve_test_factory!(test_execve, execve, CString::new("/bin/sh").unwrap().as_c_str());
execve_test_factory!(test_fexecve, fexecve, File::open("/bin/sh").unwrap().into_raw_fd());
} else if #[cfg(any(target_os = "dragonfly",
target_os = "illumos",
} else if #[cfg(any(target_os = "illumos",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris"))] {
execve_test_factory!(test_execve, execve, CString::new("/bin/sh").unwrap().as_c_str());
// No fexecve() on DragonFly, ios, macos, NetBSD, OpenBSD.
//
// Note for NetBSD and OpenBSD: although rust-lang/libc includes it
// (under unix/bsd/netbsdlike/) fexecve is not currently implemented on
// NetBSD nor on OpenBSD.
// No fexecve() on ios, macos, NetBSD, OpenBSD.
}
}

Expand Down

0 comments on commit 3e952d3

Please sign in to comment.