Bug 731870 - DOC: Environment= and EnvironmentFIle= syntax needs documentation
DOC: Environment= and EnvironmentFIle= syntax needs documentation
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: systemd (Show other bugs)
19
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: systemd-maint
Fedora Extras Quality Assurance
: Reopened
Depends On:
Blocks: systemd-RFE
  Show dependency treegraph
 
Reported: 2011-08-18 16:28 EDT by Ville Skyttä
Modified: 2013-05-15 22:59 EDT (History)
10 users (show)

See Also:
Fixed In Version: systemd-201-2.fc18.6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-05-15 22:59:50 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Ville Skyttä 2011-08-18 16:28:23 EDT
Similarly as in bug 661291 (which was for EnvironmentFile= contents), Environment= does not process quotes properly, making it hard (impossible?) to put multiple space separated args into a variable and have them passed as separate args to processes, and it's inconsistent with how EnvironmentFile= contents work.

This is with systemd-26-8.fc15.x86_64 on F-15, I'm unable to test later versions at the moment.


# cat /tmp/foo.sh 
#!/bin/bash
for i in "$@"; do
	echo "'$i'"
done


# cat /lib/systemd/system/foo.service 
[Unit]
Description=foo

[Service]
Type=oneshot
Environment=FOO="--foo 1" BAR="a b c"
ExecStart=/tmp/foo.sh $FOO $BAR
StandardOutput=syslog

[Install]
WantedBy=multi-user.target


# systemctl daemon-reload ; systemctl start foo.service
# tail -n 5 /var/log/messages | grep -o 'foo.*'
foo.sh[2679]: '--foo'
foo.sh[2679]: 'a'


I would have expected this output:

foo.sh[2679]: '--foo'
foo.sh[2679]: '1'
foo.sh[2679]: 'a'
foo.sh[2679]: 'b'
foo.sh[2679]: 'c'

...which is what happens if adding EnvironmentFile=/etc/sysconfig/foo with contents:

FOO="--foo 1"
BAR="a b c"
Comment 1 Lennart Poettering 2011-08-21 08:14:06 EDT
Use this instead:

Environment="FOO=-foo 1" "BAR=a b c"

We are not a shell and we treat all string lists the same: quotation marks enclose words, not part of words.
Comment 2 Ville Skyttä 2011-08-21 15:19:09 EDT
It's a bit of a stretch to expect people to figure that out from the man page, and on the other hand, that syntax doesn't work in EnvironmentFile= files.

The case I had was already solved - luckily the daemon had long --foo=bar options that I could use after banging my head against the wall with space separated ones for a while.

Please save the time of other people who are migrating to systemd by documenting the exact syntax to use in Environment= and EnvironmentFile= (reopening and adjusting bug summary for that).  And making the Environment= and EnvironmentFile= variable assignment syntaxes consistent would not hurt either.
Comment 3 Fedora Admin XMLRPC Client 2011-10-20 12:29:37 EDT
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.
Comment 4 Jóhann B. Guðmundsson 2012-02-20 06:32:19 EST
Given that we will be only back porting important fixes for F15 at this point in time I'm moving this DOC against Rawhide so it does not get forgotten or lost in the EOL process.
Comment 5 Zbigniew Jędrzejewski-Szmek 2013-01-25 08:04:15 EST
Fixed in http://cgit.freedesktop.org/systemd/systemd/commit/?id=0ae9c92.
Comment 6 Fedora End Of Life 2013-04-03 15:45:27 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 19 development cycle.
Changing version to '19'.

(As we did not run this process for some time, it could affect also pre-Fedora 19 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 19 End Of Life. Thank you.)

More information and reason for this action is here:
https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora19
Comment 7 Fedora Update System 2013-04-10 16:15:18 EDT
systemd-201-2.fc18.1 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/systemd-201-2.fc18.1
Comment 8 Fedora Update System 2013-04-11 19:28:25 EDT
Package systemd-201-2.fc18.2:
* should fix your issue,
* was pushed to the Fedora 18 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing systemd-201-2.fc18.2'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-5452/systemd-201-2.fc18.2
then log in and leave karma (feedback).
Comment 9 Fedora Update System 2013-04-15 20:03:03 EDT
Package systemd-201-2.fc18.4:
* should fix your issue,
* was pushed to the Fedora 18 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing systemd-201-2.fc18.4'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-5452/systemd-201-2.fc18.4
then log in and leave karma (feedback).
Comment 10 Fedora Update System 2013-04-17 22:40:38 EDT
Package systemd-201-2.fc18.5:
* should fix your issue,
* was pushed to the Fedora 18 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing systemd-201-2.fc18.5'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-5452/systemd-201-2.fc18.5
then log in and leave karma (feedback).
Comment 11 Fedora Update System 2013-05-07 09:42:36 EDT
systemd-201-2.fc18.6 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/FEDORA-2013-5452/systemd-201-2.fc18.6
Comment 12 Fedora Update System 2013-05-09 06:04:24 EDT
Package systemd-201-2.fc18.6:
* should fix your issue,
* was pushed to the Fedora 18 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing systemd-201-2.fc18.6'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-5452/systemd-201-2.fc18.6
then log in and leave karma (feedback).
Comment 13 Fedora Update System 2013-05-15 22:59:50 EDT
systemd-201-2.fc18.6 has been pushed to the Fedora 18 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.