Bug 76744 - core: bus_exec_context_set_transient_property: Environment transient file is totally broken in most cases
Summary: core: bus_exec_context_set_transient_property: Environment transient file is ...
Status: RESOLVED FIXED
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: systemd-bugs
QA Contact: systemd-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-28 16:16 UTC by Hristo Venev
Modified: 2014-06-23 16:54 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Hristo Venev 2014-03-28 16:16:31 UTC
In most cases the generated file will not even be valid. Example:

systemd-run --setenv 'a=b c' true

This will yield the following file:
[Service]
Environment=a=b c

Invalid environment assignment, ignoring: a=b c

--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -842,7 +842,7 @@
                         strv_free(c->environment);
                         c->environment = e;
 
-                        joined = strv_join(c->environment, " ");
+                        joined = strv_join_quoted(c->environment);
                         if (!joined)
                                 return -ENOMEM;
Comment 1 David Strauss 2014-03-28 21:33:20 UTC
Please submit patches to the mailing list, not to Bugzilla.
Comment 2 Hristo Venev 2014-03-29 11:42:17 UTC
Please ignore the patch and fix the bug.
Comment 3 Hristo Venev 2014-04-03 07:01:18 UTC
Bump.
Comment 4 David Strauss 2014-04-06 05:39:14 UTC
I'm not convinced this is a bug. systemd-run's --setenv option is documented to correspond to setting Environment= in the transient unit file. This means it uses the same syntax [1], too.

Given that you're trying to assign a value with spaces, I believe you want this:
systemd-run --setenv '"a=b c"' true

Your suggestion would change the effect of multiple settings, which we support in cases like this:
systemd-run --setenv 'a=b c=d' true

With strv_join(), it would be:
Environment=a=b c=d

With strv_join_quoted(), it would be:
Environment="a=b c=d"

So, strv_join_quoted() would result in, I think, $a being set to "b c=d".

If I'm wrong about breaking multiple environment settings, please re-open, and I'll take another look.

[1] http://www.freedesktop.org/software/systemd/man/systemd.exec.html#Environment=
Comment 5 Lennart Poettering 2014-04-11 00:01:04 UTC
David, it's actually OK to submit patches via fdo bugzilla. We support both ways.

I think Hristo has a point, this is a bug. Reopening.
Comment 6 Lennart Poettering 2014-06-23 16:54:26 UTC
Applied to git! Thanks!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.