From f557129ecba0826f2a2bfe055a21e7e33ccb57b0 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 29 Feb 2024 15:56:24 +0100 Subject: [PATCH] ssh-generator: handle gracefully if AF_VSOCK works, but /dev/vsock doesn't Apparently this case exists, let's handle it gracefully. Prompted by: https://github.com/systemd/systemd/pull/31544#issuecomment-1971241397 --- src/ssh-generator/ssh-generator.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ssh-generator/ssh-generator.c b/src/ssh-generator/ssh-generator.c index 2c4cf5a16a5..f906b475684 100644 --- a/src/ssh-generator/ssh-generator.c +++ b/src/ssh-generator/ssh-generator.c @@ -207,8 +207,14 @@ static int add_vsock_socket( /* Determine the local CID so that we can log it to help users to connect to this VM */ unsigned local_cid; r = vsock_get_local_cid(&local_cid); - if (r < 0) + if (r < 0) { + if (ERRNO_IS_DEVICE_ABSENT(r)) { + log_debug("Not creating AF_VSOCK ssh listener, since /dev/vsock is not available (even though AF_VSOCK is)."); + return 0; + } + return log_error_errno(r, "Failed to query local AF_VSOCK CID: %m"); + } r = make_sshd_template_unit( dest, -- 2.47.3