diff options
author | Tilde Engineering <engineering@tilde.io> | 2015-07-06 12:57:53 -0700 |
---|---|---|
committer | Tilde Engineering <engineering@tilde.io> | 2015-07-06 13:38:19 -0700 |
commit | 2f4111b620e1d7589d967322f26681768f87a43b (patch) | |
tree | 89e7cf8e82105d571fa3021c054aa7ce2aafbad8 | |
parent | b7e64a7545481f1d2b01c3a1232f18b269f4fb5b (diff) | |
download | nix-2f4111b620e1d7589d967322f26681768f87a43b.zip |
Add feature flag around execvpe
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | src/unistd.rs | 9 |
3 files changed, 9 insertions, 3 deletions
diff --git a/.travis.yml b/.travis.yml index 5140a310..a937847e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ os: - osx script: - - cargo test + - cargo test --features execvpe - cargo doc --no-deps # Deploy documentation to S3 for specific branches. At some @@ -16,6 +16,7 @@ exclude = [ [features] eventfd = [] +execvpe = [] [dependencies] libc = "0.1.8" diff --git a/src/unistd.rs b/src/unistd.rs index eb263d85..4181ccd8 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -32,6 +32,7 @@ mod ffi { pub fn execve(filename: *const c_char, argv: *const *const c_char, envp: *const *const c_char) -> c_int; // doc: http://man7.org/linux/man-pages/man3/exec.3.html #[cfg(any(target_os = "linux", target_os = "android"))] + #[cfg(feature = "execvpe")] pub fn execvpe(filename: *const c_char, argv: *const *const c_char, envp: *const *const c_char) -> c_int; // run the current process in the background @@ -325,12 +326,12 @@ pub fn chroot<P: ?Sized + NixPath>(path: &P) -> Result<()> { #[cfg(any(target_os = "linux", target_os = "android"))] mod linux { - use std::ptr; use sys::syscall::{syscall, SYSPIVOTROOT}; use errno::Errno; use {Error, Result, NixPath}; + + #[cfg(feature = "execvpe")] use std::ffi::CString; - use libc::c_char; pub fn pivot_root<P1: ?Sized + NixPath, P2: ?Sized + NixPath>( new_root: &P1, put_old: &P2) -> Result<()> { @@ -350,7 +351,11 @@ mod linux { } #[inline] + #[cfg(feature = "execvpe")] pub fn execvpe(filename: &CString, args: &[CString], env: &[CString]) -> Result<()> { + use std::ptr; + use libc::c_char; + let mut args_p: Vec<*const c_char> = args.iter().map(|s| s.as_ptr()).collect(); args_p.push(ptr::null()); |