Path instances with dashes do not work #5072

Open
bradbishop opened this Issue Jan 12, 2017 · 1 comment

Comments

Projects
None yet
2 participants

bradbishop commented Jan 12, 2017

Submission type

  • Bug report
  • Request for enhancement (RFE)

systemd version the issue has been seen with

5aac0be (1/11 HEAD)

Used distribution

Fedora 25

In case of bug report: Expected behaviour you didn't see

I'm trying to start a service instance via SYSTEMD_WANTS in a udev rule. The service is templated on a path. When the path contains a dash and the template references the unescaped instance, it is not unescaped properly.

In case of bug report: Unexpected behaviour you saw

$ cat foo@.service
[Service]
ExecStart=/bin/echo %I
$ journalctl -f &
$ systemctl start foo@/bar/baz-foo.service
echo[22021]: /bar/baz/boo

In case of bug report: Steps to reproduce the problem

systemd-escape -m foo@/bar/baz-foo.service

bradbishop added a commit to bradbishop/systemd that referenced this issue Jan 12, 2017

basic: Use path escaping when mangling path instances
Allow path instances with dashes in them to be unescaped
properly.

Fixes systemd/systemd#5072

Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>

bradbishop added a commit to bradbishop/systemd that referenced this issue Jan 12, 2017

basic: Use path escaping when mangling path instances
Allow path instances with dashes in them to be unescaped
properly.

Fixes systemd/systemd#5072

Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>

bradbishop added a commit to bradbishop/systemd that referenced this issue Feb 1, 2017

basic: Use path escaping when mangling path instances
Allow path instances with dashes in them to be unescaped
properly.

Fixes systemd/systemd#5072

Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Owner

poettering commented Feb 1, 2017

yeah, we currently expect any unit listed in SYSTEMD_WANTS is properly escaped already, and if we notice it isn't we'll do minimal escaping, the same way "systemctl start …" will do it. But you really shouldn't rely on it, as it's not properly reversible, as you just noticed.

A proper fix could be something like adding support for a new SYSTEMD_WANTS_INSTANCE property or so, where you'd specify a template name, and systemd would automatically fill in the device name in escaped form or so.

williamspatrick pushed a commit to openbmc/phosphor-led-sysfs that referenced this issue Jun 12, 2017

Work-around: Extract led name from device path
udev rule for leds subsystem in Witherspoon launches a systemd
service file with /sys/class/leds/$name. If the path is
sys-class-leds-rear-fault, systemd service file
interprets it as /sys/class/leds/rear/fault.

However, what is really needed by the service file is
/sys/class/leds/rear-fault.

This is a limitation in current systemd with template argument
containing hyphen.

Short term solution is to extract $name from path
and convert "/" to "-".  It would then become:
/sys/class/leds/rear-fault and hence will work.

Refer: systemd/systemd#5072

Change-Id: I0acc11d039650857005ba75810e3ef6bcc4a3934
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment