View Issue Details

IDProjectCategoryView StatusLast Update
0018375CentOS-7systemdpublic2021-12-23 11:21
ReporterGhepardo Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status acknowledgedResolutionopen 
Platformkernel 3.10.0-1160.36.2.el7.x86_OSCentOSOS Version7.9.2009
Product Version7.9.2009 
Summary0018375: WorkingDirectory path containing whitespace in service unit not handled correctly
DescriptionIt 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[1]: [<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 ReproduceThis can be reproduced by creating a short script, for example:

#!/bin/bash
pwd > /tmp/<output file>

...and creating a test service unit, for example:

[Unit]
Description=Test service

[Service]
WorkingDirectory=<path containing spaces, using any of the 3 schemes quoted above>
ExecStart=<path to script>
User=<my user>
Group=<my group>
Type=simple

[Install]
WantedBy=multi-user.target

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.
TagsNo tags attached.
abrt_hash
URL

Activities

ManuelWolfshant

ManuelWolfshant

2021-12-22 23:50

manager   ~0038767

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.
Ghepardo

Ghepardo

2021-12-23 11:21

reporter   ~0038769

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.

Issue History

Date Modified Username Field Change
2021-12-22 16:03 Ghepardo New Issue
2021-12-22 23:50 ManuelWolfshant Status new => acknowledged
2021-12-22 23:50 ManuelWolfshant Note Added: 0038767
2021-12-23 11:21 Ghepardo Note Added: 0038769