diff options
-rw-r--r-- | .travis.yml | 50 | ||||
-rw-r--r-- | CHANGELOG.md | 11 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | src/sys/socket/mod.rs | 14 | ||||
-rw-r--r-- | src/sys/time.rs | 3 | ||||
-rw-r--r-- | src/unistd.rs | 21 | ||||
-rw-r--r-- | test/test_unistd.rs | 3 |
8 files changed, 75 insertions, 31 deletions
diff --git a/.travis.yml b/.travis.yml index 3e584c26..de68f214 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,63 +22,63 @@ matrix: # Additionally they're moved to the front of the line to get them in the Travis # OS X build queue first. - env: TARGET="aarch64-apple-ios;armv7-apple-ios;armv7s-apple-ios;i386-apple-ios;x86_64-apple-ios" DISABLE_TESTS=1 - rust: 1.22.1 + rust: 1.24.1 os: osx # Mac builds # These are also moved to be first because they wait in a long queue with Travis - env: TARGET=i686-apple-darwin - rust: 1.22.1 + rust: 1.24.1 os: osx - env: TARGET=x86_64-apple-darwin - rust: 1.22.1 + rust: 1.24.1 os: osx # Android - env: TARGET=aarch64-linux-android DISABLE_TESTS=1 - rust: 1.22.1 + rust: 1.24.1 - env: TARGET=arm-linux-androideabi DISABLE_TESTS=1 - rust: 1.22.1 + rust: 1.24.1 - env: TARGET=armv7-linux-androideabi DISABLE_TESTS=1 - rust: 1.22.1 + rust: 1.24.1 - env: TARGET=i686-linux-android DISABLE_TESTS=1 - rust: 1.22.1 + rust: 1.24.1 - env: TARGET=x86_64-linux-android DISABLE_TESTS=1 - rust: 1.22.1 + rust: 1.24.1 # Linux - env: TARGET=aarch64-unknown-linux-gnu - rust: 1.22.1 + rust: 1.24.1 - env: TARGET=arm-unknown-linux-gnueabi - rust: 1.22.1 + rust: 1.24.1 - env: TARGET=arm-unknown-linux-musleabi DISABLE_TESTS=1 - rust: 1.22.1 + rust: 1.24.1 - env: TARGET=armv7-unknown-linux-gnueabihf - rust: 1.22.1 + rust: 1.24.1 - env: TARGET=i686-unknown-linux-gnu - rust: 1.22.1 + rust: 1.24.1 - env: TARGET=i686-unknown-linux-musl - rust: 1.22.1 + rust: 1.24.1 - env: TARGET=mips-unknown-linux-gnu - rust: 1.22.1 + rust: 1.24.1 - env: TARGET=mips64-unknown-linux-gnuabi64 - rust: 1.22.1 + rust: 1.24.1 - env: TARGET=mips64el-unknown-linux-gnuabi64 - rust: 1.22.1 + rust: 1.24.1 - env: TARGET=mipsel-unknown-linux-gnu - rust: 1.22.1 + rust: 1.24.1 - env: TARGET=powerpc-unknown-linux-gnu DISABLE_TESTS=1 - rust: 1.22.1 + rust: 1.24.1 - env: TARGET=powerpc64-unknown-linux-gnu - rust: 1.22.1 + rust: 1.24.1 - env: TARGET=powerpc64le-unknown-linux-gnu - rust: 1.22.1 + rust: 1.24.1 - env: TARGET=s390x-unknown-linux-gnu DISABLE_TESTS=1 - rust: 1.22.1 + rust: 1.24.1 - env: TARGET=x86_64-unknown-linux-gnu - rust: 1.22.1 + rust: 1.24.1 - env: TARGET=x86_64-unknown-linux-musl - rust: 1.22.1 + rust: 1.24.1 # *BSD # FreeBSD i686 and x86_64 use BuildBot instead of Travis @@ -87,7 +87,7 @@ matrix: # - env: TARGET=i686-unknown-freebsd DISABLE_TESTS=1 # - env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1 - env: TARGET=x86_64-unknown-netbsd DISABLE_TESTS=1 - rust: 1.22.1 + rust: 1.24.1 # Make sure stable is always working too - env: TARGET=x86_64-unknown-linux-gnu diff --git a/CHANGELOG.md b/CHANGELOG.md index d2a97bc4..fb0b85ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Added +- Added `FromStr` and `Display` impls for `nix::sys::Signal` + ([#884](https://github.com/nix-rust/nix/pull/884)) - Added a `sync` wrapper. ([#961](https://github.com/nix-rust/nix/pull/961)) - Added a `sysinfo` wrapper. @@ -33,10 +35,15 @@ This project adheres to [Semantic Versioning](http://semver.org/). ([#949](https://github.com/nix-rust/nix/pull/949)) ([#958](https://github.com/nix-rust/nix/pull/958)) - Added a `acct` wrapper module for enabling and disabling process accounting ([#952](https://github.com/nix-rust/nix/pull/952)) +- Added the `time_t` and `suseconds_t` public aliases within `sys::time`. + ([#968](https://github.com/nix-rust/nix/pull/968)) +- Added `unistd::execvpe` for Haiku, Linux and OpenBSD + ([#975](https://github.com/nix-rust/nix/pull/975)) ### Changed -- Increased required Rust version to 1.22.1/ +- Increased required Rust version to 1.24.1 ([#900](https://github.com/nix-rust/nix/pull/900)) + ([#966](https://github.com/nix-rust/nix/pull/966)) ### Fixed - Made `preadv` take immutable slice of IoVec. @@ -80,8 +87,6 @@ This project adheres to [Semantic Versioning](http://semver.org/). ([#857](https://github.com/nix-rust/nix/pull/857)) - Added `request_code_write_int!` on FreeBSD/DragonFlyBSD ([#833](https://github.com/nix-rust/nix/pull/833)) -- Added `FromStr` and `Display` impls for `nix::sys::Signal` - ([#884](https://github.com/nix-rust/nix/pull/884)) ### Changed - `Display` and `Debug` for `SysControlAddr` now includes all fields. @@ -26,7 +26,7 @@ cc = "1" [dev-dependencies] bytes = "0.4.8" -lazy_static = "1" +lazy_static = "1.2" rand = "0.5" tempfile = "3" @@ -44,7 +44,7 @@ limitations. Support for platforms is split into three tiers: *do not* block the inclusion of new code. Testing may be run, but failures in tests don't block the inclusion of new code. -The following targets are all supported by nix on Rust 1.22.1 or newer (unless +The following targets are all supported by nix on Rust 1.24.1 or newer (unless otherwise noted): Tier 1: diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index 4ee1acee..85acaf4c 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -976,6 +976,20 @@ pub fn getsockopt<O: GetSockOpt>(fd: RawFd, opt: O) -> Result<O::Val> { /// Sets the value for the requested socket option /// /// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html) +/// +/// # Examples +/// +/// ``` +/// use nix::sys::socket::setsockopt; +/// use nix::sys::socket::sockopt::KeepAlive; +/// use std::net::TcpListener; +/// use std::os::unix::io::AsRawFd; +/// +/// let listener = TcpListener::bind("0.0.0.0:0").unwrap(); +/// let fd = listener.as_raw_fd(); +/// let res = setsockopt(fd, KeepAlive, &true); +/// assert!(res.is_ok()); +/// ``` pub fn setsockopt<O: SetSockOpt>(fd: RawFd, opt: O, val: &O::Val) -> Result<()> { opt.set(fd, val) } diff --git a/src/sys/time.rs b/src/sys/time.rs index 51286a06..e300cfe7 100644 --- a/src/sys/time.rs +++ b/src/sys/time.rs @@ -1,5 +1,6 @@ use std::{cmp, fmt, ops}; -use libc::{c_long, time_t, suseconds_t, timespec, timeval}; +use libc::{c_long, timespec, timeval}; +pub use libc::{time_t, suseconds_t}; pub trait TimeValLike: Sized { #[inline] diff --git a/src/unistd.rs b/src/unistd.rs index aadd3c6b..12f3566a 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -701,6 +701,27 @@ pub fn execvp(filename: &CString, args: &[CString]) -> Result<Void> { Err(Error::Sys(Errno::last())) } +/// Replace the current process image with a new one and replicate shell `PATH` +/// searching behavior (see +/// [`execvpe(3)`](http://man7.org/linux/man-pages/man3/exec.3.html)). +/// +/// This functions like a combination of `execvp(2)` and `execve(2)` to pass an +/// environment and have a search path. See these two for additional +/// information. +#[cfg(any(target_os = "haiku", + target_os = "linux", + target_os = "openbsd"))] +pub fn execvpe(filename: &CString, args: &[CString], env: &[CString]) -> Result<Void> { + let args_p = to_exec_array(args); + let env_p = to_exec_array(env); + + unsafe { + libc::execvpe(filename.as_ptr(), args_p.as_ptr(), env_p.as_ptr()) + }; + + Err(Error::Sys(Errno::last())) +} + /// Replace the current process image with a new one (see /// [fexecve(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/fexecve.html)). /// diff --git a/test/test_unistd.rs b/test/test_unistd.rs index 52eb365c..b03e8853 100644 --- a/test/test_unistd.rs +++ b/test/test_unistd.rs @@ -243,6 +243,9 @@ cfg_if!{ } } +#[cfg(any(target_os = "haiku", target_os = "linux", target_os = "openbsd"))] +execve_test_factory!(test_execvpe, execvpe, &CString::new("sh").unwrap()); + cfg_if!{ if #[cfg(target_os = "android")] { use nix::fcntl::AtFlags; |