]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: drop specifier expansion when parsing transient dbus properties
authorLennart Poettering <lennart@poettering.net>
Tue, 21 Nov 2017 16:32:01 +0000 (17:32 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 29 Nov 2017 11:32:53 +0000 (12:32 +0100)
Specifier expansion (much like C escape handling) should be a helper for
writing unit files, but should be nothing we do on programatic APIs. For
those, the client can do the necessary replacements anyway, and we
really should be careful with doing such string processing of data we
get via lower level programmatic APIs.

We currently do specifier expansion only for the env var transient unit
APIs, no other properties do this. Let's remove it here too, to be fully
systematic.

Yes, in a way this is API breakage, but then again this API isn't
documented yet, and an outlier, hence let's clear this up now, before it
is too late.

src/core/dbus-execute.c

index 7b0e91cdc4384c28831a52cbb5b9d2d009349953..57ccdcbe330cc6688682f47a3cafc094f19cbe50 100644 (file)
@@ -2061,35 +2061,30 @@ int bus_exec_context_set_transient_property(
 
         } else if (streq(name, "Environment")) {
 
-                _cleanup_strv_free_ char **l = NULL, **q = NULL;
+                _cleanup_strv_free_ char **l = NULL;
 
                 r = sd_bus_message_read_strv(message, &l);
                 if (r < 0)
                         return r;
 
-                r = unit_full_printf_strv(u, l, &q);
-                if (r < 0)
-                        return r;
-
-                if (!strv_env_is_valid(q))
+                if (!strv_env_is_valid(l))
                         return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment block.");
 
                 if (mode != UNIT_CHECK) {
-                        if (strv_length(q) == 0) {
+                        if (strv_length(l) == 0) {
                                 c->environment = strv_free(c->environment);
                                 unit_write_drop_in_private_format(u, mode, name, "Environment=");
                         } else {
                                 _cleanup_free_ char *joined = NULL;
                                 char **e;
 
-                                e = strv_env_merge(2, c->environment, q);
+                                e = strv_env_merge(2, c->environment, l);
                                 if (!e)
                                         return -ENOMEM;
 
                                 strv_free(c->environment);
                                 c->environment = e;
 
-                                /* We write just the new settings out to file, with unresolved specifiers */
                                 joined = strv_join_quoted(l);
                                 if (!joined)
                                         return -ENOMEM;
@@ -2102,28 +2097,24 @@ int bus_exec_context_set_transient_property(
 
         } else if (streq(name, "UnsetEnvironment")) {
 
-                _cleanup_strv_free_ char **l = NULL, **q = NULL;
+                _cleanup_strv_free_ char **l = NULL;
 
                 r = sd_bus_message_read_strv(message, &l);
                 if (r < 0)
                         return r;
 
-                r = unit_full_printf_strv(u, l, &q);
-                if (r < 0)
-                        return r;
-
-                if (!strv_env_name_or_assignment_is_valid(q))
+                if (!strv_env_name_or_assignment_is_valid(l))
                         return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid UnsetEnvironment= list.");
 
                 if (mode != UNIT_CHECK) {
-                        if (strv_length(q) == 0) {
+                        if (strv_length(l) == 0) {
                                 c->unset_environment = strv_free(c->unset_environment);
                                 unit_write_drop_in_private_format(u, mode, name, "UnsetEnvironment=");
                         } else {
                                 _cleanup_free_ char *joined = NULL;
                                 char **e;
 
-                                e = strv_env_merge(2, c->unset_environment, q);
+                                e = strv_env_merge(2, c->unset_environment, l);
                                 if (!e)
                                         return -ENOMEM;
 
@@ -2250,17 +2241,13 @@ int bus_exec_context_set_transient_property(
 
         } else if (streq(name, "PassEnvironment")) {
 
-                _cleanup_strv_free_ char **l = NULL, **q = NULL;
+                _cleanup_strv_free_ char **l = NULL;
 
                 r = sd_bus_message_read_strv(message, &l);
                 if (r < 0)
                         return r;
 
-                r = unit_full_printf_strv(u, l, &q);
-                if (r < 0)
-                        return r;
-
-                if (!strv_env_name_is_valid(q))
+                if (!strv_env_name_is_valid(l))
                         return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid PassEnvironment= block.");
 
                 if (mode != UNIT_CHECK) {
@@ -2270,10 +2257,6 @@ int bus_exec_context_set_transient_property(
                         } else {
                                 _cleanup_free_ char *joined = NULL;
 
-                                r = strv_extend_strv(&c->pass_environment, q, true);
-                                if (r < 0)
-                                        return r;
-
                                 /* We write just the new settings out to file, with unresolved specifiers. */
                                 joined = strv_join_quoted(l);
                                 if (!joined)