Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump nix from 0.26.2 to 0.27.1 #1651

Merged
merged 2 commits into from
Sep 18, 2023
Merged
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
39 changes: 26 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = [
"conmon-rs/common",
"conmon-rs/client",
Expand Down
2 changes: 1 addition & 1 deletion conmon-rs/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ libc = "0.2.147"
libsystemd = "0.6.0"
memchr = "2.6.0"
multimap = "0.9.0"
nix = "0.26.2"
nix = { version = "0.27.1", features = ["fs", "hostname", "mount", "sched", "signal", "socket", "term", "user"] }
notify = "6.1.1"
once_cell = "1.18.0"
opentelemetry = { version = "0.20.0", features = ["rt-tokio"] }
Expand Down
16 changes: 7 additions & 9 deletions conmon-rs/server/src/attach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ use nix::{
};
use std::{
convert::From,
os::unix::{
fs::PermissionsExt,
io::{FromRawFd, RawFd},
net,
os::{
fd::{AsRawFd, OwnedFd},
unix::fs::PermissionsExt,
},
path::{Path, PathBuf},
};
Expand Down Expand Up @@ -154,13 +153,13 @@ impl Attach {
let (shortened_path, _parent_dir) =
Listener::<DefaultListener>::default().shorten_socket_path(path)?;
let addr = UnixAddr::new(&shortened_path).context("create socket addr")?;
bind(fd, &addr).context("bind socket fd")?;
bind(fd.as_raw_fd(), &addr).context("bind socket fd")?;

let metadata = path.metadata()?;
let mut permissions = metadata.permissions();
permissions.set_mode(0o700);

listen(fd, 10).context("listen on socket fd")?;
listen(&fd, 10).context("listen on socket fd")?;

task::spawn(
async move {
Expand All @@ -177,15 +176,14 @@ impl Attach {
}

async fn start(
fd: RawFd,
fd: OwnedFd,
read_half_tx: Sender<Vec<u8>>,
write_half_tx: Sender<Message>,
token: CancellationToken,
stop_after_stdin_eof: bool,
) -> Result<()> {
debug!("Start listening on attach socket");
let listener = UnixListener::from_std(unsafe { net::UnixListener::from_raw_fd(fd) })
.context("create unix listener")?;
let listener = UnixListener::from_std(fd.into()).context("create unix listener")?;
loop {
match listener.accept().await {
Ok((stream, _)) => {
Expand Down
19 changes: 12 additions & 7 deletions conmon-rs/server/src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use sendfd::RecvWithFd;
use std::{
io::{self, ErrorKind, Read, Write},
os::{
fd::{AsRawFd, FromRawFd, OwnedFd},
fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, OwnedFd},
unix::{fs::PermissionsExt, io::RawFd},
},
path::PathBuf,
Expand Down Expand Up @@ -112,9 +112,9 @@ impl Terminal {
self.set_tty(Arc::downgrade(&fd).into());

debug!("Changing terminal settings");
let mut term = termios::tcgetattr(fd.as_raw_fd())?;
let mut term = termios::tcgetattr(&fd)?;
term.output_flags |= OutputFlags::ONLCR;
termios::tcsetattr(fd.as_raw_fd(), SetArg::TCSANOW, &term)?;
termios::tcsetattr(&fd, SetArg::TCSANOW, &term)?;

let attach_clone = self.attach.clone();
let logger_clone = self.logger.clone();
Expand Down Expand Up @@ -268,7 +268,6 @@ mod tests {
use crate::{attach::SharedContainerAttach, container_log::ContainerLog};
use nix::pty;
use sendfd::SendWithFd;
use std::os::unix::io::FromRawFd;

#[tokio::test(flavor = "multi_thread")]
async fn new_success() -> Result<()> {
Expand All @@ -285,7 +284,7 @@ mod tests {
loop {
let ready = stream.ready(Interest::WRITABLE).await?;
if ready.is_writable() {
match stream.send_with_fd(b"test", &[res.master]) {
match stream.send_with_fd(b"test", &[res.master.as_raw_fd()]) {
Ok(_) => break,
Err(ref e) if e.kind() == ErrorKind::WouldBlock => continue,
Err(e) => anyhow::bail!(e),
Expand All @@ -297,8 +296,8 @@ mod tests {
assert!(!sut.path().exists());

// Write to the slave
let mut file = unsafe { fs::File::from_raw_fd(res.slave) };
file.write_all(b"test").await?;
let mut file: std::fs::File = res.slave.into();
file.write_all(b"test")?;

Ok(())
}
Expand All @@ -322,6 +321,12 @@ impl AsRawFd for TerminalFd {
}
}

impl AsFd for TerminalFd {
fn as_fd(&self) -> BorrowedFd {
self.0.as_fd()
}
}

impl AsyncRead for &TerminalFd {
fn poll_read(
self: Pin<&mut Self>,
Expand Down