Bug 49316 - WantedBy= in [Install] is unescaped unexpectedly
Summary: WantedBy= in [Install] is unescaped unexpectedly
Status: RESOLVED FIXED
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: All Linux (All)
: medium minor
Assignee: Lennart Poettering
QA Contact:
URL:
Whiteboard:
Keywords:
: 78994 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-04-30 16:05 UTC by rodrigo
Modified: 2014-05-26 18:15 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Don't remove escaping (465 bytes, patch)
2012-07-23 13:11 UTC, Michal Sekletar
Details | Splinter Review

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.