]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
conf-parser: Set EXTRACT_RETAIN_ESCAPE when extracting words (#2917)
authorDan Nicholson <nicholson@endlessm.com>
Mon, 18 Apr 2016 02:52:45 +0000 (19:52 -0700)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 18 Apr 2016 02:52:45 +0000 (22:52 -0400)
If you reference another unit with an escaped name, the escaped characters
should remain in the extracted word. This used to work correctly prior to
commit 34f253f0.

The problem can be seen when units with escaped names are referenced.

$ cat "/usr/lib/systemd/system/dev-disk-by\x2dlabel-eos\x2dswap.swap"
[Swap]
What=/dev/disk/by-label/eos-swap

[Install]
WantedBy=dev-disk-by\x2dlabel-eos\x2dswap.device

$ systemctl enable "dev-disk-by\x2dlabel-eos\x2dswap.swap"
Created symlink
/etc/systemd/system/dev-disk-byx2dlabel-eosx2dswap.device.wants/dev-disk-by\x2dlabel-eos\x2dswap.swap,
pointing to /usr/lib/systemd/system/dev-disk-by\x2dlabel-eos\x2dswap.swap.

The wants directory should be created with the x2ds escaped with \.

src/shared/conf-parser.c

index bd0a1f483b54961f089d315a1b5378e7cbf0cc87..1141f9964f9ed8a7e8cd6c904341fd613c215a08 100644 (file)
@@ -732,7 +732,7 @@ int config_parse_strv(const char *unit,
         for (;;) {
                 char *word = NULL;
                 int r;
-                r = extract_first_word(&rvalue, &word, WHITESPACE, EXTRACT_QUOTES);
+                r = extract_first_word(&rvalue, &word, WHITESPACE, EXTRACT_QUOTES|EXTRACT_RETAIN_ESCAPE);
                 if (r == 0)
                         break;
                 if (r == -ENOMEM)