RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1032694 - Wrong parsing Environment= arguments
Summary: Wrong parsing Environment= arguments
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: systemd
Version: 7.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: systemd-maint
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-11-20 15:25 UTC by Honza Horak
Modified: 2013-11-21 12:42 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-11-21 12:42:55 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Honza Horak 2013-11-20 15:25:03 UTC
Description of problem:
Basically, when passing an argument in Environment=, which includes a white-space, I need to use quotes (like Environment=MYVAR1="aaa bbb"), but even then the argument is not read by systemd (seems like only '"aaa' is read, which is broken imho).

Version-Release number of selected component (if applicable):
# rpm -q systemd
systemd-207-4.el7.x86_64

How reproducible:
every-time

Steps to Reproduce:
1. # cat >/etc/systemd/system/foo.service<<EOF
[Unit]
Description=Testing environment variable setting
[Service]
Type=oneshot
Environment=MYVAR1="e f"
Environment=MYVAR2=g h
Environment=MYVAR3=i "j k"
ExecStart=/usr/local/bin/foo a "b c" d \${MYVAR1} "\${MYVAR2}" "\${MYVAR3} l"
EOF
2. # cat >/usr/local/bin/foo<<EOF
#!/bin/bash
while [ ! -z "\$1" ] ; do
    echo \$1
    shift
done
EOF
3. # chmod a+x /usr/local/bin/foo
4. # systemctl daemon-reload
5. # systemctl status foo -l
6. # systemctl start foo
7. # tail -n 20 /var/log/messages

Actual results:
Nov 20 13:29:17 unused-4-187 foo: a
Nov 20 13:29:17 unused-4-187 foo: b c
Nov 20 13:29:17 unused-4-187 foo: d
Nov 20 13:29:17 unused-4-187 foo: "e
Nov 20 13:29:17 unused-4-187 foo: g
Nov 20 13:29:17 unused-4-187 foo: i l
Nov 20 13:29:17 unused-4-187 systemd: Started Testing environment variable setting.
Nov 20 13:29:17 unused-4-187 systemd: [/etc/systemd/system/foo.service:5] Invalid environment assignment, ignoring: MYVAR1="e f"
Nov 20 13:29:17 unused-4-187 systemd: [/etc/systemd/system/foo.service:6] Invalid environment assignment, ignoring: MYVAR2=g h
Nov 20 13:29:17 unused-4-187 systemd: [/etc/systemd/system/foo.service:7] Invalid environment assignment, ignoring: MYVAR3=i "j k"
Nov 20 13:29:23 unused-4-187 systemd: [/etc/systemd/system/foo.service:5] Invalid environment assignment, ignoring: MYVAR1="e f"
Nov 20 13:29:23 unused-4-187 systemd: [/etc/systemd/system/foo.service:6] Invalid environment assignment, ignoring: MYVAR2=g h
Nov 20 13:29:23 unused-4-187 systemd: [/etc/systemd/system/foo.service:7] Invalid environment assignment, ignoring: MYVAR3=i "j k"

Expected results:
Nov 20 13:29:17 unused-4-187 foo: a
Nov 20 13:29:17 unused-4-187 foo: b c
Nov 20 13:29:17 unused-4-187 foo: d
Nov 20 13:29:17 unused-4-187 foo: e f
Nov 20 13:29:17 unused-4-187 foo: g h
Nov 20 13:29:17 unused-4-187 foo: i j k l

Additional info:
First, I thought version 204 from Fedora 19 works fine, but it seems more like it works similar, only doesn't print errors.

We can work-around this by some wrapper script, but that is ugly. systemd should have the power to pass proper arguments to daemons.

Comment 1 Lukáš Nykrýn 2013-11-21 12:42:55 UTC
If you are using spaces you should quote whole expression.

From the manpage:
If you need to assign a value containing spaces to a variable, use double quotes (") for the assignment.

Example:

Environment="VAR1=word1 word2" VAR2=word3 "VAR3=word 5 6"

So if I am not missing anything this should be closed as NOTABUG.


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