]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ssh-generator: handle gracefully if AF_VSOCK works, but /dev/vsock doesn't
authorLennart Poettering <lennart@poettering.net>
Thu, 29 Feb 2024 14:56:24 +0000 (15:56 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 29 Feb 2024 17:28:01 +0000 (18:28 +0100)
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

index 2c4cf5a16a5a5f775ca67a0e8a6b0c4c538d4231..f906b4756840e62c0c965ddd6098b6ffae0e3ff9 100644 (file)
@@ -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,