Bug 663358 - environment variables from /etc/sysconfig/* does not work
Summary: environment variables from /etc/sysconfig/* does not work
Keywords:
Status: CLOSED DUPLICATE of bug 661291
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:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-12-15 14:42 UTC by Michal Hlavinka
Modified: 2018-04-11 08:15 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-01-03 08:05:47 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Michal Hlavinka 2010-12-15 14:42:52 UTC
Description of problem:
We are trying to create service file for smartd for which some configuration is present in /etc/sysconfig/smartmontools :

smartd_opts="-q never"

however systemd does not handle it correctly:

ExecStart=/usr/sbin/smartd -n $smartd_opts

is always interpreted as:
argv[1]=-n
argv[2]=-q never

instead of expected:
argv[1]=-n
argv[2]=-q
argv[3]=never

man page contains:
 Also $FOO may appear as separate word on the command line in which case the variable is replaced by its value split at whitespaces.

but it behaves differently


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

How reproducible:
always

Steps to Reproduce:
1)
/lib/systemd/system/smartd.service:
""""""""""""""
[Unit]
Description=Self Monitoring and Reporting Technology (SMART) Daemon
After=syslog.target

[Service]
EnvironmentFile=/etc/sysconfig/smartmontools
ExecStart=/usr/sbin/smartd.sh -n $smartd_opts

[Install]
WantedBy=multi-user.target
"""""""""""""

2) /usr/sbin/smartd.sh
"""""""""""""
#!/bin/bash
sleep 3600
"""""""""""""

3) chmod +x /usr/sbin/smartd.sh
4) systemctl --system daemon-reload
5) systemctl start smartd.service
6) get pid from systemctl status smartd.service
7) check /proc/<pid>/cmdline

Actual results:
no '\0' between "-q" and "never"
cat /proc/<pid>/cmdline shows /bin/bash/usr/sbin/smartde-n-q never because there is ' ' instead of '\0'

Expected results:
'\0' between "-q" and "never"
cat /proc/<pid>/cmdline would show /bin/bash/usr/sbin/smartde-n-qnever

additional comments:
I don't know why ${smartd_opts} should behave differently than $smartd_opts, 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 "-q never" and ${var} as "\"-q never\""
if ${smartd_opts} is used instead of $smartd_opts

Comment 1 Matěj Cepl 2010-12-29 11:29:10 UTC
Michal, why is this not a duplicate of bug 661291?

Comment 2 Michal Hlavinka 2011-01-03 08:05:47 UTC

*** This bug has been marked as a duplicate of bug 661291 ***


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