Bug 661291 - Quoted assignments in EnvironmentFile passed as one argument
Summary: Quoted assignments in EnvironmentFile passed as one argument
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: systemd
Version: rawhide
Hardware: Unspecified
OS: Unspecified
low
medium
Target Milestone: ---
Assignee: Lennart Poettering
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 663358 (view as bug list)
Depends On:
Blocks: 660206
TreeView+ depends on / blocked
 
Reported: 2010-12-08 13:20 UTC by Miroslav Lichvar
Modified: 2011-01-05 15:19 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2011-01-05 15:19:17 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

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.


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