Skip to content

Commit

Permalink
remove unnecessary clone() in create.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
utam0k committed Jun 30, 2021
1 parent f583d4e commit 61758bd
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ impl Create {
Ok(())
}
}

/// Fork the process and actually start the container process
fn run_container<P: AsRef<Path>>(
pid_file: Option<P>,
Expand Down Expand Up @@ -186,15 +187,15 @@ fn run_container<P: AsRef<Path>>(
Process::Child(_child) => unreachable!(),
// This is actually the child process after fork
Process::Init(mut init) => {
// setup args and env vars as in the spec
let spec_args: &Vec<String> = &spec.process.args.clone();
let envs: &Vec<String> = &spec.process.env.clone();
// prepare process
init_process(spec, command, rootfs, namespaces)?;
setup_init_process(&spec, command, rootfs, &namespaces)?;
init.ready()?;
notify_socket.wait_for_container_start()?;
// actually run the command / program to be run in container
utils::do_exec(&spec_args[0], spec_args, envs)?;
let args: &Vec<String> = &spec.process.args;
let envs: &Vec<String> = &spec.process.env;
utils::do_exec(&args[0], args, envs)?;

// the command / program is done executing
container
.refresh_state()?
Expand All @@ -211,16 +212,16 @@ fn run_container<P: AsRef<Path>>(
}

/// setup hostname, rootfs for the container process
fn init_process(
spec: oci_spec::Spec,
fn setup_init_process(
spec: &oci_spec::Spec,
command: impl Command,
rootfs: PathBuf,
namespaces: Namespaces,
namespaces: &Namespaces,
) -> Result<()> {
let proc = spec.process.clone();
let proc = &spec.process;

command.set_hostname(&spec.hostname.as_str())?;
if spec.process.no_new_privileges {
command.set_hostname(spec.hostname.as_str())?;
if proc.no_new_privileges {
let _ = prctl::set_no_new_privileges(true);
}

Expand Down

0 comments on commit 61758bd

Please sign in to comment.