summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTilde Engineering <engineering@tilde.io>2015-07-06 12:57:53 -0700
committerTilde Engineering <engineering@tilde.io>2015-07-06 13:38:19 -0700
commit2f4111b620e1d7589d967322f26681768f87a43b (patch)
tree89e7cf8e82105d571fa3021c054aa7ce2aafbad8
parentb7e64a7545481f1d2b01c3a1232f18b269f4fb5b (diff)
downloadnix-2f4111b620e1d7589d967322f26681768f87a43b.zip
Add feature flag around execvpe
-rw-r--r--.travis.yml2
-rw-r--r--Cargo.toml1
-rw-r--r--src/unistd.rs9
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
diff --git a/Cargo.toml b/Cargo.toml
index fddc4f8e..8ff9d203 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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());