]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bus-unit-util: make sure we can set LoadCredentials= property with a single string
authorLennart Poettering <lennart@poettering.net>
Thu, 14 Apr 2022 15:57:33 +0000 (17:57 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 21 Apr 2022 13:28:57 +0000 (15:28 +0200)
LoadCredentials= in unit files supports a syntax passing a single string
only (in which case the credentials are propagated down from the host).
but systemd-run's --property= setting doesn't allow that yet. Fix that.

src/shared/bus-unit-util.c

index 4f02c2c373062a8dd19a957a93b22a3595f9f718..d78d75bf0f858e1b465f4a66df9cdb8b6a60ee84 100644 (file)
@@ -1156,9 +1156,12 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
                                 return log_oom();
                         if (r < 0)
                                 return log_error_errno(r, "Failed to parse %s= parameter: %s", field, eq);
-                        if (r == 0 || !p)
+                        if (r == 0)
                                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Missing argument to %s=.", field);
 
+                        if (isempty(p)) /* If only one field is specified, then this means "inherit from above" */
+                                p = eq;
+
                         r = sd_bus_message_append(m, "a(ss)", 1, word, p);
                 }
                 if (r < 0)