]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
vmspawn: Use machine_credential_add()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 21 Oct 2025 19:38:18 +0000 (21:38 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 22 Oct 2025 14:42:50 +0000 (16:42 +0200)
src/vmspawn/vmspawn.c

index c6d52cccb7f6763acc6a961de77d757265f61bd6..735d733f2459996397bf5d6b0ed1cd79f4537bbb 100644 (file)
@@ -2441,7 +2441,7 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) {
         }
 
         if (arg_forward_journal) {
-                _cleanup_free_ char *listen_address = NULL, *cred = NULL;
+                _cleanup_free_ char *listen_address = NULL;
 
                 if (!GREEDY_REALLOC(children, n_children + 1))
                         return log_oom();
@@ -2459,11 +2459,7 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) {
                 pidref_done(&child);
                 children[n_children++] = TAKE_PTR(source);
 
-                cred = strjoin("journal.forward_to_socket:", listen_address);
-                if (!cred)
-                        return log_oom();
-
-                r = machine_credential_set(&arg_credentials, cred);
+                r = machine_credential_add(&arg_credentials, "journal.forward_to_socket", listen_address, SIZE_MAX);
                 if (r < 0)
                         return r;
         }
@@ -2509,13 +2505,14 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) {
 
                 /* on distros that provide their own sshd@.service file we need to provide a dropin which
                  * picks up our public key credential */
-                r = machine_credential_set(
+                r = machine_credential_add(
                                 &arg_credentials,
-                                "systemd.unit-dropin.sshd-vsock@.service:"
+                                "systemd.unit-dropin.sshd-vsock@.service",
                                 "[Service]\n"
                                 "ExecStart=\n"
                                 "ExecStart=-sshd -i -o 'AuthorizedKeysFile=%d/ssh.ephemeral-authorized_keys-all .ssh/authorized_keys'\n"
-                                "ImportCredential=ssh.ephemeral-authorized_keys-all\n");
+                                "ImportCredential=ssh.ephemeral-authorized_keys-all\n",
+                                SIZE_MAX);
                 if (r < 0)
                         return log_error_errno(r, "Failed to set credential systemd.unit-dropin.sshd-vsock@.service: %m");
         }