diff --git a/Cargo.toml b/Cargo.toml index db18f65b..3cfd081b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,8 +44,8 @@ composefs-ostree = { version = "0.7.0", path = "crates/composefs-ostree", defaul cap-std-ext = "5.1.2" ocidir = "0.8.0" -zlink = { version = "0.5", default-features = false, features = ["tokio", "introspection", "proxy", "server", "service", "tracing"] } -zlink-core = { version = "0.5", default-features = false, features = ["introspection", "std", "tracing"] } +zlink = { version = "0.6", default-features = false, features = ["tokio", "introspection", "proxy", "server", "service", "tracing"] } +zlink-core = { version = "0.6", default-features = false, features = ["introspection", "std", "tracing"] } [profile.dev.package.sha2] # this is *really* slow otherwise diff --git a/crates/composefs-ctl/Cargo.toml b/crates/composefs-ctl/Cargo.toml index 7eb558e3..512b48a3 100644 --- a/crates/composefs-ctl/Cargo.toml +++ b/crates/composefs-ctl/Cargo.toml @@ -54,7 +54,7 @@ tokio = { version = "1.24.2", default-features = false, features = ["io-std", "i zlink = { workspace = true } [dev-dependencies] -similar-asserts = "1.7.0" +similar-asserts = "2.0.0" tar = { version = "0.4.38", default-features = false } tempfile = "3.8.0" tokio = { version = "1.24.2", default-features = false, features = ["macros", "rt-multi-thread"] } diff --git a/crates/composefs-ctl/src/varlink.rs b/crates/composefs-ctl/src/varlink.rs index 25347b53..f37aa480 100644 --- a/crates/composefs-ctl/src/varlink.rs +++ b/crates/composefs-ctl/src/varlink.rs @@ -1796,9 +1796,9 @@ pub(crate) struct ActivatedListener { impl zlink::Listener for ActivatedListener { type Socket = zlink::unix::Stream; - async fn accept(&mut self) -> zlink::Result> { + async fn accept(&mut self) -> zlink::Result>> { match self.conn.take() { - Some(conn) => Ok(conn), + Some(conn) => Ok(Some(conn)), None => std::future::pending().await, } } @@ -1863,8 +1863,9 @@ pub(crate) fn try_activated_listener() -> Result> { .context("setting systemd socket to non-blocking")?; let tokio_stream = tokio::net::UnixStream::from_std(std_stream) .context("converting systemd UnixStream to tokio")?; - let zlink_stream = zlink::unix::Stream::from(tokio_stream); - let conn = zlink::Connection::from(zlink_stream); + let zlink_stream = + zlink::unix::Stream::try_from(tokio_stream).map_err(|e| anyhow::anyhow!(e))?; + let conn = zlink::Connection::new(zlink_stream); Ok(Some(ActivatedSocket::Connected(ActivatedListener { conn: Some(conn), }))) @@ -2847,8 +2848,9 @@ pub(crate) fn spawn_in_process( server_std.set_nonblocking(true)?; let client_stream = tokio::net::UnixStream::from_std(client_std)?; - let client_zlink = zlink::unix::Stream::from(client_stream); - let client_conn = zlink::Connection::from(client_zlink); + let client_zlink = + zlink::unix::Stream::try_from(client_stream).map_err(std::io::Error::other)?; + let client_conn = zlink::Connection::new(client_zlink); let handle = std::thread::Builder::new() .name("cfsctl-service-server".into()) @@ -2872,7 +2874,13 @@ pub(crate) fn spawn_in_process( return; } }; - let server_zlink = zlink::unix::Stream::from(server_stream); + let server_zlink = match zlink::unix::Stream::try_from(server_stream) { + Ok(s) => s, + Err(e) => { + log::error!("CfsctlService server zlink stream conversion failed: {e:#?}"); + return; + } + }; let listener = zlink::ReadyListener::new(server_zlink); let server = zlink::Server::new(listener, service); if let Err(e) = server.run().await { diff --git a/crates/composefs-splitdirfdstream/Cargo.toml b/crates/composefs-splitdirfdstream/Cargo.toml index 9f46172c..3af54e9c 100644 --- a/crates/composefs-splitdirfdstream/Cargo.toml +++ b/crates/composefs-splitdirfdstream/Cargo.toml @@ -20,7 +20,7 @@ tokio = ["dep:tokio"] rand = { version = "0.10.0", default-features = false, features = ["alloc"] } rand_pcg = { version = "0.10.0", default-features = false } rustix = { version = "1.0.0", default-features = false, features = ["fs", "pipe", "std"] } -sha2 = { version = "0.10", default-features = false, features = ["std"] } +sha2 = { version = "0.11", default-features = false } thiserror = { version = "2.0.0", default-features = false } tokio = { version = "1", default-features = false, features = ["rt"], optional = true } diff --git a/crates/composefs-storage/src/cstor_service.rs b/crates/composefs-storage/src/cstor_service.rs index da5a34e5..48084792 100644 --- a/crates/composefs-storage/src/cstor_service.rs +++ b/crates/composefs-storage/src/cstor_service.rs @@ -496,8 +496,9 @@ pub fn spawn_in_process( server_std.set_nonblocking(true)?; let client_stream = tokio::net::UnixStream::from_std(client_std)?; - let client_zlink = zlink::unix::Stream::from(client_stream); - let client_conn = zlink::Connection::from(client_zlink); + let client_zlink = + zlink::unix::Stream::try_from(client_stream).map_err(std::io::Error::other)?; + let client_conn = zlink::Connection::new(client_zlink); let (shutdown_tx, shutdown_rx) = tokio::sync::oneshot::channel::<()>(); @@ -525,7 +526,15 @@ pub fn spawn_in_process( return; } }; - let server_zlink = zlink::unix::Stream::from(server_stream); + let server_zlink = match zlink::unix::Stream::try_from(server_stream) { + Ok(s) => s, + Err(e) => { + tracing::error!( + "CstorLayerService server zlink stream conversion failed: {e:#?}" + ); + return; + } + }; let listener = zlink::ReadyListener::new(server_zlink); let server = zlink::Server::new(listener, service); @@ -569,7 +578,7 @@ pub fn serve_on_socket_blocking(socket: std::os::unix::net::UnixStream) -> std:: local.block_on(&rt, async move { // `from_std` must be called inside the runtime context. let stream = tokio::net::UnixStream::from_std(socket)?; - let zs = zlink::unix::Stream::from(stream); + let zs = zlink::unix::Stream::try_from(stream).map_err(std::io::Error::other)?; let listener = zlink::ReadyListener::new(zs); let server = zlink::Server::new(listener, CstorLayerService); server diff --git a/crates/composefs-storage/src/userns_helper.rs b/crates/composefs-storage/src/userns_helper.rs index 55174258..81782678 100644 --- a/crates/composefs-storage/src/userns_helper.rs +++ b/crates/composefs-storage/src/userns_helper.rs @@ -238,8 +238,8 @@ impl StorageProxy { parent_sock.set_nonblocking(true)?; let tok = tokio::net::UnixStream::from_std(parent_sock) .map_err(|e| HelperError::Ipc(format!("failed to convert socket: {e}")))?; - let zs = zlink::unix::Stream::from(tok); - let conn = zlink::Connection::from(zs); + let zs = zlink::unix::Stream::try_from(tok).map_err(std::io::Error::other)?; + let conn = zlink::Connection::new(zs); Ok(Self { child: Some(child),