]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Add handling for '-1' when parsing vsock CID (#42654)
authorGabriel <10530980+gpotter2@users.noreply.github.com>
Mon, 22 Jun 2026 19:57:03 +0000 (21:57 +0200)
committerGitHub <noreply@github.com>
Mon, 22 Jun 2026 19:57:03 +0000 (21:57 +0200)
Currently `systemd-ssh-generator` supports
`systemd.ssh_listen=vsock::22` and aliases the "empty CID" towards
`VMADDR_CID_ANY`. VMADDR_CID_ANY is -1, so it's confusing from a user
experience that `systemd.ssh_listen=vsock:-1:22` isn't supported.

src/basic/socket-util.c

index 614f762b57df88d9124a453327343bc0a8789e80..d8f41f0f9c0d69571ce69530247620e194b864b8 100644 (file)
@@ -1730,7 +1730,7 @@ int vsock_parse_cid(const char *s, unsigned *ret) {
                 return -EINVAL;
 
         /* Parsed an AF_VSOCK "CID". This is a 32bit entity, and the usual type is "unsigned". We recognize
-         * the three special CIDs as strings, and otherwise parse the numeric CIDs. */
+         * the four special CIDs as strings, and otherwise parse the numeric CIDs. */
 
         if (streq(s, "hypervisor"))
                 *ret = VMADDR_CID_HYPERVISOR;
@@ -1738,6 +1738,8 @@ int vsock_parse_cid(const char *s, unsigned *ret) {
                 *ret = VMADDR_CID_LOCAL;
         else if (streq(s, "host"))
                 *ret = VMADDR_CID_HOST;
+        else if (STR_IN_SET(s, "any", "-1"))
+                *ret = VMADDR_CID_ANY;
         else
                 return safe_atou(s, ret);