1
0
Fork 0
mirror of https://github.com/containers/youki synced 2024-06-10 08:46:21 +02:00

minor fixes

This commit is contained in:
yihuaf 2021-07-19 06:36:00 +00:00
parent 68e30596ea
commit e497179119
2 changed files with 2 additions and 26 deletions

View File

@ -51,12 +51,12 @@ pub(super) struct ContainerBuilderImpl {
impl ContainerBuilderImpl {
pub(super) fn create(&mut self) -> Result<()> {
self.run_container_clone()?;
self.run_container()?;
Ok(())
}
fn run_container_clone(&mut self) -> Result<()> {
fn run_container(&mut self) -> Result<()> {
prctl::set_dumpable(false).unwrap();
let linux = self.spec.linux.as_ref().unwrap();

View File

@ -16,9 +16,6 @@ use nix::{
unistd::{self, Gid, Uid},
};
use oci_spec::LinuxNamespace;
use std::collections;
use std::iter::FromIterator;
use std::vec;
pub struct Namespaces {
spaces: Vec<LinuxNamespace>,
@ -78,27 +75,6 @@ impl Namespaces {
Ok(())
}
}
pub fn translate_clone_flag(namespace_type: oci_spec::LinuxNamespaceType) -> sched::CloneFlags {
match namespace_type {
oci_spec::LinuxNamespaceType::Pid => sched::CloneFlags::CLONE_NEWPID,
oci_spec::LinuxNamespaceType::User => sched::CloneFlags::CLONE_NEWUSER,
oci_spec::LinuxNamespaceType::Uts => sched::CloneFlags::CLONE_NEWUTS,
oci_spec::LinuxNamespaceType::Cgroup => sched::CloneFlags::CLONE_NEWCGROUP,
oci_spec::LinuxNamespaceType::Ipc => sched::CloneFlags::CLONE_NEWIPC,
oci_spec::LinuxNamespaceType::Network => sched::CloneFlags::CLONE_NEWNET,
oci_spec::LinuxNamespaceType::Mount => sched::CloneFlags::CLONE_NEWNS,
}
}
pub fn get_namespace_map(
namespace_list: &vec::Vec<oci_spec::LinuxNamespace>,
) -> collections::HashMap<oci_spec::LinuxNamespaceType, &oci_spec::LinuxNamespace> {
let to_tuple = namespace_list
.iter()
.map(|ns| -> (oci_spec::LinuxNamespaceType, &oci_spec::LinuxNamespace) { (ns.typ, ns) });
collections::HashMap::from_iter(to_tuple)
}
#[cfg(test)]
mod tests {
use oci_spec::LinuxNamespaceType;