From 4b9b62bb3ec1720d9fd2ecd5460cd219f851a3b9 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Thu, 28 Apr 2022 11:56:02 +0100 Subject: [PATCH] agent-ctl: Fix abstract socket connections Unbreak the `agent-ctl` tool connecting to the agent with a Unix domain socket. It appears that [1] changed the behaviour of connecting to the agent using a local Unix socket (which is not used by Kata under normal operation). The change can be seen by reverting to commit 72b8144b569f1d0fef3001642f244bf79b17ddc6 (the one before [1]) and running the agent manually as: ```bash $ sudo KATA_AGENT_SERVER_ADDR=unix:///tmp/foo.socket target/x86_64-unknown-linux-musl/release/kata-agent ``` Before [1], in another terminal we see this: ```bash $ sudo lsof -U 2>/dev/null |grep foo|awk '{print $9}' @/tmp/foo.socket@ ``` But now, we see the following: ```bash $ sudo lsof -U 2>/dev/null |grep foo|awk '{print $9}' @/tmp/foo.socket ``` Note the last byte which represents a nul (`\0`) value. The `agent-ctl` tool used to add that trailing nul but now it seems to not be needed, so this change removes it, restoring functionality. No external changes are necessary so the `agent-ctl` tool can connect to the agent as below like this: ```bash $ cargo run -- -l debug connect --server-address "unix://@/tmp/foo.socket" --bundle-dir "$bundle_dir" -c Check -c GetGuestDetails ``` [1] - https://github.com/kata-containers/kata-containers/issues/3124 Fixes: #4164. Signed-off-by: James O. D. Hunt --- src/tools/agent-ctl/src/client.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/tools/agent-ctl/src/client.rs b/src/tools/agent-ctl/src/client.rs index a4f1e45a82..bcaa878440 100644 --- a/src/tools/agent-ctl/src/client.rs +++ b/src/tools/agent-ctl/src/client.rs @@ -473,10 +473,8 @@ fn create_ttrpc_client( if path.starts_with('@') { abstract_socket = true; - // Remove the magic abstract-socket request character ('@') - // and crucially add a trailing nul terminator (required to - // interoperate with the ttrpc crate). - path = path[1..].to_string() + &"\x00".to_string(); + // Remove the magic abstract-socket request character ('@'). + path = path[1..].to_string(); } if abstract_socket {