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