I've been trying to configure a service to start / stop whenever a given device appears / disappears, and I came out with the following options: [Unit] BindTo=dev-sdd.device [Install] WantedBy=dev-sdd.device Then I do a "systemctl enable test.service" and that works perfectly. But here is the problem: if the device contains escaped characters: [Unit] BindTo=dev-disk-by\x2did-usb\x2dSanDisk_Cruzer_2444631B4C02C434\x2d0:0.device [Install] WantedBy=dev-disk-by\x2did-usb\x2dSanDisk_Cruzer_2444631B4C02C434\x2d0:0.device It just half-works: the service is stopped when the device disappears, but it is not started when it later reappears. After some research, I found that the problem is that the command "systemctl enable test.service" creates the link as: /etc/systemd/system/dev-disk-by-did-usb-SanDisk_Cruzer_2444631B4C02C434-0:0.device.wants/test.service If then I rename it into: /etc/systemd/system/dev-disk-by\x2did-usb\x2dSanDisk_Cruzer_2444631B4C02C434\x2d0:0.device/test.service And it works again. It looks like the escape rules in the unit file are different for different lines. Regards. -- Rodrigo Rivas Costa
I think we should not remove escaping from strings in [Install] section, I will attach patch which should resolve the issue, but I'm not 100% sure that it's not gonna break something else.
Created attachment 64541 [details] [review] Don't remove escaping
This should be fixed in 194 (possibly older). If not, please reopen.
*** Bug 78994 has been marked as a duplicate of this bug. ***
Still here in V212 (I mistakenly opened a new bug for it).
I refreshed the patch and pushed it as http://cgit.freedesktop.org/systemd/systemd/commit/?id=000f6e56.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.