From 06d9eb655c1c0ba27b3643d180bd74c6b7a7aa2f Mon Sep 17 00:00:00 2001 From: Jorge Prendes Date: Tue, 26 Sep 2023 09:24:23 +0100 Subject: [PATCH] bump nix to 1.27.1 Signed-off-by: Jorge Prendes --- Cargo.lock | 2 +- Cargo.toml | 2 +- crates/containerd-shim-wasm/Cargo.toml | 2 +- .../src/sys/unix/container/instance.rs | 7 ++++--- crates/containerd-shim-wasm/src/sys/unix/networking.rs | 3 +-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1f2c5e45c..7550ad1f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -562,7 +562,7 @@ dependencies = [ "libc", "libcontainer", "log", - "nix 0.26.4", + "nix 0.27.1", "oci-spec", "protobuf 3.2.0", "serde", diff --git a/Cargo.toml b/Cargo.toml index d4bf240cc..0be2dd2f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ env_logger = "0.10" libc = "0.2.147" libcontainer = { version = "0.2", default-features = false } log = "0.4" -nix = "0.26" +nix = "0.27" oci-spec = { version = "0.6.1", features = ["runtime"] } serde = "1.0" serde_json = "1.0" diff --git a/crates/containerd-shim-wasm/Cargo.toml b/crates/containerd-shim-wasm/Cargo.toml index 5ac5cf8d5..6cdea5181 100644 --- a/crates/containerd-shim-wasm/Cargo.toml +++ b/crates/containerd-shim-wasm/Cargo.toml @@ -31,7 +31,7 @@ wat = { workspace = true } caps = "0.5" dbus = { version = "*", features = ["vendored"] } libcontainer = { workspace = true, features = ["libseccomp", "systemd", "v1", "v2"]} -nix = { workspace = true } +nix = { workspace = true, features = ["sched", "mount"] } [target.'cfg(windows)'.dependencies] windows-sys = { workspace = true, features = ["Win32_Foundation", "Win32_Storage_FileSystem"] } diff --git a/crates/containerd-shim-wasm/src/sys/unix/container/instance.rs b/crates/containerd-shim-wasm/src/sys/unix/container/instance.rs index c6b1d51a0..39ba7e9fd 100644 --- a/crates/containerd-shim-wasm/src/sys/unix/container/instance.rs +++ b/crates/containerd-shim-wasm/src/sys/unix/container/instance.rs @@ -9,6 +9,7 @@ use libcontainer::signal::Signal; use libcontainer::syscall::syscall::SyscallType; use nix::errno::Errno; use nix::sys::wait::{waitid, Id as WaitID, WaitPidFlag, WaitStatus}; +use nix::unistd::Pid; use crate::container::Engine; use crate::sandbox::instance::{ExitCode, Wait}; @@ -60,7 +61,7 @@ impl SandboxInstance for Instance { .with_systemd(false) .build()?; - let pid = container.pid().context("failed to get pid")?; + let pid = container.pid().context("failed to get pid")?.as_raw(); container.start().map_err(|err| { SandboxError::Any(anyhow::anyhow!("failed to start container: {}", err)) @@ -70,7 +71,7 @@ impl SandboxInstance for Instance { thread::spawn(move || { let (lock, cvar) = &*exit_code; - let status = match waitid(WaitID::Pid(pid), WaitPidFlag::WEXITED) { + let status = match waitid(WaitID::Pid(Pid::from_raw(pid)), WaitPidFlag::WEXITED) { Ok(WaitStatus::Exited(_, status)) => status, Ok(WaitStatus::Signaled(_, sig, _)) => sig as i32, Ok(_) => 0, @@ -86,7 +87,7 @@ impl SandboxInstance for Instance { cvar.notify_all(); }); - Ok(pid.as_raw() as u32) + Ok(pid as u32) } /// Send a signal to the instance diff --git a/crates/containerd-shim-wasm/src/sys/unix/networking.rs b/crates/containerd-shim-wasm/src/sys/unix/networking.rs index 5f1d15fcb..be7f29742 100644 --- a/crates/containerd-shim-wasm/src/sys/unix/networking.rs +++ b/crates/containerd-shim-wasm/src/sys/unix/networking.rs @@ -1,5 +1,4 @@ use std::fs::File; -use std::os::unix::io::AsRawFd; use anyhow::Result; use containerd_shim::error::Error as ShimError; @@ -25,7 +24,7 @@ pub fn setup_namespaces(spec: &runtime::Spec) -> Result<()> { err )) })?; - setns(f.as_raw_fd(), CloneFlags::CLONE_NEWNET).map_err(|err| { + setns(f, CloneFlags::CLONE_NEWNET).map_err(|err| { ShimError::Other(format!("could not set network namespace: {0}", err)) })?; } else {