ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
Zbigniew Jędrzejewski-Szmek 436654
From df78ada3b4543af43e4059d0185e3cfd007a9899 Mon Sep 17 00:00:00 2001
Zbigniew Jędrzejewski-Szmek 436654
From: Daniel Mack <daniel@zonque.org>
Zbigniew Jędrzejewski-Szmek 436654
Date: Mon, 1 Jun 2015 17:49:04 +0200
Zbigniew Jędrzejewski-Szmek 436654
Subject: [PATCH] load-fragment: use UNESCAPE_RELAX flag to parse exec
Zbigniew Jędrzejewski-Szmek 436654
 directives
Zbigniew Jędrzejewski-Szmek 436654
Zbigniew Jędrzejewski-Szmek 436654
The cunescape() helper function used to handle unknown escaping sequences
Zbigniew Jędrzejewski-Szmek 436654
gracefully by copying them over verbatim.
Zbigniew Jędrzejewski-Szmek 436654
Zbigniew Jędrzejewski-Szmek 436654
Commit 527b7a42 ("util: rework cunescape(), improve error handling") added
Zbigniew Jędrzejewski-Szmek 436654
a flag to make that behavior optional, and changed to default to error out
Zbigniew Jędrzejewski-Szmek 436654
with -EINVAL otherwise.
Zbigniew Jędrzejewski-Szmek 436654
Zbigniew Jędrzejewski-Szmek 436654
However, config_parse_exec(), which is used to parse the
Zbigniew Jędrzejewski-Szmek 436654
Exec{Start,Stop}{Post,Pre,} directives of unit files, was not changed along
Zbigniew Jędrzejewski-Szmek 436654
with that commit, which means that directives with improperly escaped
Zbigniew Jędrzejewski-Szmek 436654
command line strings are no longer parsed.
Zbigniew Jędrzejewski-Szmek 436654
Zbigniew Jędrzejewski-Szmek 436654
Relevant bugreports include:
Zbigniew Jędrzejewski-Szmek 436654
Zbigniew Jędrzejewski-Szmek 436654
  https://bugs.freedesktop.org/show_bug.cgi?id=90794
Zbigniew Jędrzejewski-Szmek 436654
  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=787256
Zbigniew Jędrzejewski-Szmek 436654
Zbigniew Jędrzejewski-Szmek 436654
Fix this by passing UNESCAPE_RELAX to config_parse_exec() in order to
Zbigniew Jędrzejewski-Szmek 436654
restore the original behavior.
Zbigniew Jędrzejewski-Szmek 436654
Zbigniew Jędrzejewski-Szmek 436654
(cherry picked from commit 22874a348fb1540c1a2b7907748fc57c9756a7ed)
Zbigniew Jędrzejewski-Szmek 436654
---
Zbigniew Jędrzejewski-Szmek 436654
 src/core/load-fragment.c | 2 +-
Zbigniew Jędrzejewski-Szmek 436654
 1 file changed, 1 insertion(+), 1 deletion(-)
Zbigniew Jędrzejewski-Szmek 436654
Zbigniew Jędrzejewski-Szmek 436654
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
Zbigniew Jędrzejewski-Szmek 436654
index 9415e92c90..b09481a16b 100644
Zbigniew Jędrzejewski-Szmek 436654
--- a/src/core/load-fragment.c
Zbigniew Jędrzejewski-Szmek 436654
+++ b/src/core/load-fragment.c
Zbigniew Jędrzejewski-Szmek 436654
@@ -609,7 +609,7 @@ int config_parse_exec(
Zbigniew Jędrzejewski-Szmek 436654
                         else
Zbigniew Jędrzejewski-Szmek 436654
                                 skip = strneq(word, "\\;", MAX(l, 1U));
Zbigniew Jędrzejewski-Szmek 436654
 
Zbigniew Jędrzejewski-Szmek 436654
-                        r = cunescape_length(word + skip, l - skip, 0, &c);
Zbigniew Jędrzejewski-Szmek 436654
+                        r = cunescape_length(word + skip, l - skip, UNESCAPE_RELAX, &c);
Zbigniew Jędrzejewski-Szmek 436654
                         if (r < 0) {
Zbigniew Jędrzejewski-Szmek 436654
                                 log_syntax(unit, LOG_ERR, filename, line, r, "Failed to unescape command line, ignoring: %s", rvalue);
Zbigniew Jędrzejewski-Szmek 436654
                                 r = 0;