This service will be undergoing maintenance at 00:00 UTC, 2016-08-01. It is expected to last about 1 hours
Bug 661291 - Quoted assignments in EnvironmentFile passed as one argument
Quoted assignments in EnvironmentFile passed as one argument
Status: CLOSED UPSTREAM
Product: Fedora
Classification: Fedora
Component: systemd (Show other bugs)
rawhide
Unspecified Unspecified
low Severity medium
: ---
: ---
Assigned To: Lennart Poettering
Fedora Extras Quality Assurance
:
: 663358 (view as bug list)
Depends On:
Blocks: 660206
  Show dependency treegraph
 
Reported: 2010-12-08 08:20 EST by Miroslav Lichvar
Modified: 2011-01-05 10:19 EST (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-01-05 10:19:17 EST
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 Miroslav Lichvar 2010-12-08 08:20:41 EST
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 18:34:03 EST
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 03:05:48 EST
*** Bug 663358 has been marked as a duplicate of this bug. ***
Comment 3 Michal Hlavinka 2011-01-03 03:08:31 EST
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 03:53:18 EST
$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 18:35:01 EST
Oh, indeed. I guess that should be simple to fix.
Comment 6 Lennart Poettering 2011-01-05 10:19:17 EST
Fixed now in git.

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