mirror of
https://github.com/containers/youki
synced 2024-11-22 17:02:00 +01:00
remove do_exec now that default executor is used.
Signed-off-by: yihuaf <yihuaf@unkies.org>
This commit is contained in:
parent
dc5d021b0f
commit
1d81f05f93
@ -1,16 +1,14 @@
|
||||
//! Utility functionality
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::ffi::CString;
|
||||
use std::fs::{self, DirBuilder, File};
|
||||
use std::os::linux::fs::MetadataExt;
|
||||
use std::os::unix::fs::DirBuilderExt;
|
||||
use std::os::unix::prelude::{AsRawFd, OsStrExt};
|
||||
use std::os::unix::prelude::AsRawFd;
|
||||
use std::path::{Component, Path, PathBuf};
|
||||
|
||||
use nix::sys::stat::Mode;
|
||||
use nix::sys::statfs;
|
||||
use nix::unistd;
|
||||
use nix::unistd::{Uid, User};
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
@ -145,33 +143,6 @@ pub fn get_user_home(uid: u32) -> Option<PathBuf> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum DoExecError {
|
||||
#[error("failed to convert path to cstring")]
|
||||
PathToCString {
|
||||
source: std::ffi::NulError,
|
||||
path: PathBuf,
|
||||
},
|
||||
#[error("failed to execvp")]
|
||||
Execvp { source: nix::Error },
|
||||
}
|
||||
|
||||
pub fn do_exec(path: impl AsRef<Path>, args: &[String]) -> Result<(), DoExecError> {
|
||||
let p = CString::new(path.as_ref().as_os_str().as_bytes()).map_err(|e| {
|
||||
DoExecError::PathToCString {
|
||||
source: e,
|
||||
path: path.as_ref().to_path_buf(),
|
||||
}
|
||||
})?;
|
||||
let c_args: Vec<CString> = args
|
||||
.iter()
|
||||
.map(|s| CString::new(s.as_bytes()).unwrap_or_default())
|
||||
.collect();
|
||||
unistd::execvp(&p, &c_args).map_err(|err| DoExecError::Execvp { source: err })?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// If None, it will generate a default path for cgroups.
|
||||
pub fn get_cgroup_path(
|
||||
cgroups_path: &Option<PathBuf>,
|
||||
|
@ -38,7 +38,7 @@ impl Executor for DefaultExecutor {
|
||||
ExecutorError::Execution(err.into())
|
||||
})?;
|
||||
|
||||
// After do_exec is called, the process is replaced with the container
|
||||
// After execvp is called, the process is replaced with the container
|
||||
// payload through execvp, so it should never reach here.
|
||||
unreachable!();
|
||||
}
|
||||
|
@ -32,4 +32,4 @@ This exposes several modules, each dealing with a specific aspect of working wit
|
||||
|
||||
- `tty` : this deals with setting up the tty for the container process.
|
||||
|
||||
- `utils` : provides various utility functions, such as `parse_env` to parse the env variables, `do_exec` to do an exec syscall and execute a binary in the container process, `get_cgroups_path`, `create_dir_all_with_mode` etc.
|
||||
- `utils` : provides various utility functions, such as `parse_env` to parse the env variables, `get_cgroups_path`, `create_dir_all_with_mode` etc.
|
||||
|
Loading…
Reference in New Issue
Block a user