Bug 731870

Summary: DOC: Environment= and EnvironmentFIle= syntax needs documentation
Product: [Fedora] Fedora Reporter: Ville Skyttä <ville.skytta>
Component: systemdAssignee: systemd-maint
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 19CC: harald, johannbg, johannbg, kay, lpoetter, metherid, mschmidt, notting, plautrba, zbyszek
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: systemd-201-2.fc18.6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-05-16 02:59:50 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 784611    

Description Ville Skyttä 2011-08-18 20:28:23 UTC
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 12:14:06 UTC
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 19:19:09 UTC
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 16:29:37 UTC
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 11:32:19 UTC
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 13:04:15 UTC
Fixed in http://cgit.freedesktop.org/systemd/systemd/commit/?id=0ae9c92.

Comment 6 Fedora End Of Life 2013-04-03 19:45:27 UTC
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 20:15:18 UTC
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 23:28:25 UTC
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-16 00:03:03 UTC
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-18 02:40:38 UTC
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 13:42:36 UTC
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 10:04:24 UTC
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-16 02:59:50 UTC
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.