chiark / gitweb /
core: escape unit name from udev
authorMUNEDA Takahiro <muneda.takahiro@jp.fujitsu.com>
Tue, 23 Apr 2013 17:34:38 +0000 (13:34 -0400)
committerLennart Poettering <lennart@poettering.net>
Mon, 6 May 2013 21:10:44 +0000 (23:10 +0200)
commitd9abd1493d6adca4038121f2c969fdcaf89b9b7a
tree6d560c64cd673b9250449bc67aa7372e8af5a35d
parent19adb8a3204fefd91411b5f0f350c8bc6bcf75fe
core: escape unit name from udev

This patch escapes a unit name which was derived from udev.

Please imagine following udev rule.

  ACTION=="online|offline", TAG+="systemd", ENV{SYSTEMD_WANTS}="muneda@%p.service"
  ACTION=="online|offline", TAG+="systemd", ENV{SYSTEMD_WANTS}="muneda@%r.service"
  ACTION=="online|offline", TAG+="systemd", ENV{SYSTEMD_WANTS}="muneda@%S.service"

When unit name is derived from udev via
udev_device_get_property_value(), the name may contains '/' if
ENV{SYSTEMD_WANTS} has the udev options $devpath(%p), $root(%r), or
$sys(%S).  However, '/' is a invalid char for unit name so processing
of this rule fails as Invalid argument with following message.

Apr 22 13:21:37 localhost systemd[1]: Failed to load device unit: Invalid argument
Apr 22 13:21:37 localhost systemd[1]: Failed to process udev device event: Invalid argument

This patch escapes those invalid chars in a unit name.
Tested with 202, and confirmed to apply cleanly on top of commit 195f8e36.

Thanks,
Takahiro
src/core/device.c