55 lines
2.1 KiB
Diff
55 lines
2.1 KiB
Diff
From f5fe08ec458eea4308f807ade0cbf9a5af663f30 Mon Sep 17 00:00:00 2001
|
|
From: Daniel Mack <daniel@zonque.org>
|
|
Date: Mon, 1 Jun 2015 18:05:02 +0200
|
|
Subject: [PATCH] test-unit-file: add test for improperly escaped exec string
|
|
|
|
Add a regression test for the recent breakage of handling improperly
|
|
escaped exec strings in unit files.
|
|
|
|
Code contributed by Martin Pitt:
|
|
|
|
https://bugs.freedesktop.org/show_bug.cgi?id=90794
|
|
|
|
(cherry picked from commit 80979f1ce4dadf797a42e85a97dc10960c1f6509)
|
|
---
|
|
src/test/test-unit-file.c | 19 +++++++++++++++++++
|
|
1 file changed, 19 insertions(+)
|
|
|
|
diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c
|
|
index a9711ac9f5..31b12d50d7 100644
|
|
--- a/src/test/test-unit-file.c
|
|
+++ b/src/test/test-unit-file.c
|
|
@@ -225,6 +225,15 @@ static void test_config_parse_exec(void) {
|
|
check_execcommand(c1,
|
|
"/sbin/find", NULL, ";", "x", false);
|
|
|
|
+ log_info("/* encoded semicolon */");
|
|
+ r = config_parse_exec(NULL, "fake", 5, "section", 1,
|
|
+ "LValue", 0,
|
|
+ "/bin/find \\073",
|
|
+ &c, NULL);
|
|
+ assert_se(r >= 0);
|
|
+ c1 = c1->command_next;
|
|
+ check_execcommand(c1, "/bin/find", NULL, "\\073", NULL, false);
|
|
+
|
|
log_info("/* spaces in the filename */");
|
|
r = config_parse_exec(NULL, "fake", 5, "section", 1,
|
|
"LValue", 0,
|
|
@@ -296,6 +305,16 @@ static void test_config_parse_exec(void) {
|
|
c1 = c1->command_next;
|
|
check_execcommand(c1, "/path ", NULL, NULL, NULL, false);
|
|
|
|
+ log_info("/* quoted backslashes */");
|
|
+ r = config_parse_exec(NULL, "fake", 5, "section", 1,
|
|
+ "LValue", 0,
|
|
+ "/bin/grep '\\w+\\K'",
|
|
+ &c, NULL);
|
|
+ assert_se(r >= 0);
|
|
+ c1 = c1->command_next;
|
|
+ check_execcommand(c1, "/bin/grep", NULL, "\\w+\\K", NULL, false);
|
|
+
|
|
+
|
|
log_info("/* trailing backslash: \\ */");
|
|
/* backslash is invalid */
|
|
r = config_parse_exec(NULL, "fake", 4, "section", 1,
|