View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0018375||CentOS-7||systemd||public||2021-12-22 16:03||2021-12-23 11:21|
|Platform||kernel 3.10.0-1160.36.2.el7.x86_||OS||CentOS||OS Version||7.9.2009|
|Summary||0018375: WorkingDirectory path containing whitespace in service unit not handled correctly|
|Description||It is impossible to create a properly working service unit file which has, for its WorkingDirectory, a path containing whitespace. None of the following will work:|
* double- or single-quoting the path
* escaping the whitespace characters with backslashes
* substituting the output of 'systemd-escape -p <path>' for the path
When an attempt is made to use a unit file employing the first or third schemes above, the message "systemd: [<unit file>:<line number>] Not an absolute path, ignoring: <path>" is sent to the journal; however the service does indeed run. (If backslash-escaping is tried, the error is different and the service will not start.)
Systemd is up to date on my system: "systemctl --version" reports "systemd 219" and the systemd package version is 219-78.el7_9.3.
|Steps To Reproduce||This can be reproduced by creating a short script, for example:|
pwd > /tmp/<output file>
...and creating a test service unit, for example:
WorkingDirectory=<path containing spaces, using any of the 3 schemes quoted above>
ExecStart=<path to script>
When this service is started using systemctl, the working directory will be revealed as "/" for the first and third schemes above, and the service will fail to start for the second scheme above.
If a path not containing whitespace is entered in the unit file for WorkingDirectory (and is one accessible to the quoted user), the service will start without errors and the called script will output the correct working directory to the output file.
|Tags||No tags attached.|
I reproduced all your findings. Theoretically you should file a bug at bugzilla.redhat.com and if/when RH accepts it and incorporates it into RHEL and releases a patched version, then CentOS will pick it up automatically. Unfortunately RHEL 7 is in maintenance mode and RH only accepts critical bugs so most probably the bug you have found will not be acted upon.
|Thanks @ManuelWolfshant. I've raised the following RH Bugzilla for this: https://bugzilla.redhat.com/show_bug.cgi?id=2035241. You never know, it may somehow get fed into RHEL 8 & 9.|