Bug 661291

Summary: Quoted assignments in EnvironmentFile passed as one argument
Product: [Fedora] Fedora Reporter: Miroslav Lichvar <mlichvar>
Component: systemdAssignee: Lennart Poettering <lpoetter>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: rawhideCC: lpoetter, metherid, mhlavink, mschmidt, notting, plautrba
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-01-05 15:19:17 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: 660206    

Description Miroslav Lichvar 2010-12-08 13:20:41 UTC
Description of problem:
When a file specified by EnvironmentFile uses 

OPTIONS="-a -b"

and the unit file uses

ExecStart=foo $OPTIONS

foo will be started with '-a -b', not with '-a' '-b' as would be in a shell script. This should happen only when "$OPTIONS" is used.

Version-Release number of selected component (if applicable):
systemd-15-1.fc15.x86_64

Comment 1 Lennart Poettering 2010-12-28 23:34:03 UTC
Quoting from systemd.service(5):

"On top of that basic environment variable substitution is supported, where ${FOO} is replaced by the string value of the environment variable of the same name. Also $FOO may appear as separate word on the command line in which case the
variable is replaced by its value split at whitespaces. Note that the first argument (i.e. the binary to execute) may not be a variable, and must be a literal and absolute path name."

Hmm, as I read your bug report, this is actually not what happens?

Comment 2 Michal Hlavinka 2011-01-03 08:05:48 UTC
*** Bug 663358 has been marked as a duplicate of this bug. ***

Comment 3 Michal Hlavinka 2011-01-03 08:08:31 UTC
I don't know why ${OPTIONS} should behave differently than $OPTIONS,
because it's misleading. These variables looks like shell variables and from
shell's pov both are interpreted the same way. Anyway, ${var} does not work
too, because $var is interpreted as "-a -b" and ${var} as "\"-a -b\""

For ${FOO} functionality from man page, "$FOO" should be used and ${FOO} should work the same way as $FOO.

Comment 4 Miroslav Lichvar 2011-01-03 08:53:18 UTC
$FOO is split with this assignment (not valid in shell)

FOO=-a -b

but not with this one

FOO="-a -b"

So it seems the problem is that systemd doesn't remove the quotes.

Comment 5 Lennart Poettering 2011-01-04 23:35:01 UTC
Oh, indeed. I guess that should be simple to fix.

Comment 6 Lennart Poettering 2011-01-05 15:19:17 UTC
Fixed now in git.