Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async-trait = "0.1.52"
futures = "0.3.19"
libc = "0.2.112"
log = "0.4"
nix = "0.26"
nix = "0.27"
oci-spec = "0.6"
os_pipe = "1.1"
prost = "0.12"
Expand Down
2 changes: 1 addition & 1 deletion crates/runc-shim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ containerd-shim = { path = "../shim", version = "0.5.0", features = ["async"] }
crossbeam = "0.8.1"
libc.workspace = true
log.workspace = true
nix.workspace = true
nix = {workspace = true, features = ["socket", "term", "uio"]}
oci-spec.workspace = true
runc = { path = "../runc", version = "0.2.0", features = ["async"] }
serde.workspace = true
Expand Down
6 changes: 1 addition & 5 deletions crates/runc-shim/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ use containerd_shim::{
use log::{debug, warn};
use nix::{
cmsg_space,
sys::{
socket::{recvmsg, ControlMessageOwned, MsgFlags, UnixAddr},
termios::tcgetattr,
},
sys::socket::{recvmsg, ControlMessageOwned, MsgFlags, UnixAddr},
};
use oci_spec::runtime::{LinuxNamespaceType, Spec};
use runc::{
Expand Down Expand Up @@ -206,7 +203,6 @@ pub fn receive_socket(stream_fd: RawFd) -> containerd_shim::Result<RawFd> {
"copy_console: console socket get path: {}, fd: {}",
path, &fds[0]
);
tcgetattr(fds[0])?;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after updating, this was throwing the following error:

error[E0277]: the trait bound `i32: std::os::fd::AsFd` is not satisfied
    --> crates/runc-shim/src/common.rs:209:15
     |
209  |     tcgetattr(fds[0])?;
     |     --------- ^^^^^^ the trait `std::os::fd::AsFd` is not implemented for `i32`
     |     |
     |     required by a bound introduced by this call
     |

Looking into the docs, it looks like the current implementation is a no-op since tcsetattr() is never called on the structure https://github.com/nix-rust/nix/blob/996db47d542ae20f09eb344b9fcb88c40ae38e3d/src/sys/termios.rs#L1156-L1158

Ok(fds[0])
}

Expand Down
2 changes: 1 addition & 1 deletion crates/runc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async = ["tokio", "async-trait", "futures", "tokio-pipe"]
[dependencies]
libc.workspace = true
log.workspace = true
nix.workspace = true
nix = {workspace = true, features = ["user"]}
oci-spec.workspace = true
os_pipe.workspace = true
path-absolutize = "3.0.11"
Expand Down
2 changes: 1 addition & 1 deletion crates/shim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ go-flag = "0.1.0"
lazy_static = "1.4.0"
libc.workspace = true
log = { workspace = true, features = ["std"]}
nix.workspace = true
nix = {workspace = true, features = ["ioctl", "mount", "socket"]}
oci-spec.workspace = true
page_size = "0.6.0"
prctl = "1.0.0"
Expand Down
4 changes: 2 additions & 2 deletions crates/shim/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

#[cfg(unix)]
use std::os::unix::io::RawFd;
use std::os::unix::io::{AsRawFd, RawFd};
use std::time::{SystemTime, UNIX_EPOCH};

use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -112,7 +112,7 @@ pub fn connect(address: impl AsRef<str>) -> Result<RawFd> {
#[cfg(not(target_os = "linux"))]
const SOCK_CLOEXEC: SockFlag = SockFlag::empty();

let fd = socket(AddressFamily::Unix, SockType::Stream, SOCK_CLOEXEC, None)?;
let fd = socket(AddressFamily::Unix, SockType::Stream, SOCK_CLOEXEC, None)?.as_raw_fd();

// MacOS doesn't support atomic creation of a socket descriptor with `SOCK_CLOEXEC` flag,
// so there is a chance of leak if fork + exec happens in between of these calls.
Expand Down