Bug 49316

Summary: WantedBy= in [Install] is unescaped unexpectedly
Product: systemd Reporter: rodrigo <rodrigorivascosta>
Component: generalAssignee: Lennart Poettering <lennart>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: medium CC: rodrigorivascosta, yannayl
Version: unspecified   
Hardware: All   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: Don't remove escaping

Description rodrigo 2012-04-30 16:05:25 UTC
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
Comment 1 Michal Sekletar 2012-07-23 13:09:03 UTC
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.
Comment 2 Michal Sekletar 2012-07-23 13:11:32 UTC
Created attachment 64541 [details] [review]
Don't remove escaping
Comment 3 Lennart Poettering 2012-10-17 17:22:53 UTC
This should be fixed in 194 (possibly older). If not, please reopen.
Comment 4 yannay 2014-05-25 21:58:04 UTC
*** Bug 78994 has been marked as a duplicate of this bug. ***
Comment 5 yannay 2014-05-25 21:59:42 UTC
Still here in V212 (I mistakenly opened a new bug for it).
Comment 6 Zbigniew Jedrzejewski-Szmek 2014-05-26 18:15:38 UTC
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.