summaryrefslogtreecommitdiff
path: root/src/test/test-unit-file.c
diff options
context:
space:
mode:
authorFilipe Brandenburger <filbranden@google.com>2015-05-30 22:48:52 -0700
committerFilipe Brandenburger <filbranden@google.com>2015-06-17 11:12:12 -0700
commit46a0d98ac0fb5b507a6423e60058a2483830b432 (patch)
tree9e8778c396ff42db125beeaf2b23e5329325c361 /src/test/test-unit-file.c
parent0e9800d5d938acb350b2a3a29b938bc1deed0313 (diff)
load-fragment: use unquote_first_word in config_parse_exec
Convert config_parse_exec() from using FOREACH_WORD_QUOTED into a loop of unquote_first_word. Loop through the arguments only once (the FOREACH_WORD_QUOTED implementation did it twice, once to count them and another time to process and store them.) Use newly introduced flag UNQUOTE_UNESCAPE_RELAX to preserve unrecognized escape sequences such as regexps matches such as "\w", "\d", etc. (Valid escape sequences such as "\s" or "\b" still need an extra backslash if literals are desired for regexps.) Differences in behavior: - Handle ; (command separator) in special, so that only ; on its own is valid for that purpose, an quoted semicolon ";" or ';' will now behave as a literal semicolon. This is probably what was initially intended. - Handle \; (to introduce a literal semicolon) in special, so that only \; is turned into a semicolon but not \\; or "\\;" or "\;" which are kept as a literal \; in the output. This is probably what was initially intended. Known issues: - Using an empty string (for example, ExecStartPre=<empty>) will empty the list and remove the existing commands, but using whitespace only (for example, ExecStartPre=<spaces>) will not. This is a pre-existing issue and will be dealt with in a follow up commit. Tested: - Unit tests passing. Also `make distcheck` still works as expected. - Installed it on a local machine and booted with it, checked console output, systemctl and journalctl output, did not notice any issues running the patched systemd binaries. Relevant bug: https://bugs.freedesktop.org/show_bug.cgi?id=90794
Diffstat (limited to 'src/test/test-unit-file.c')
-rw-r--r--src/test/test-unit-file.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c
index 892b65d322..c7e8353b3b 100644
--- a/src/test/test-unit-file.c
+++ b/src/test/test-unit-file.c
@@ -237,7 +237,7 @@ static void test_config_parse_exec(void) {
&c, NULL);
assert_se(r >= 0);
c1 = c1->command_next;
- check_execcommand(c1, "/RValue", "argv0", "r1", NULL, true);
+ check_execcommand(c1, "/RValue", "argv0", "r1", ";", true);
log_info("/* escaped semicolon */");
r = config_parse_exec(NULL, "fake", 5, "section", 1,
@@ -284,7 +284,7 @@ static void test_config_parse_exec(void) {
&c, NULL);
assert_se(r >= 0);
c1 = c1->command_next;
- check_execcommand(c1, "/bin/find", NULL, NULL, NULL, false);
+ check_execcommand(c1, "/bin/find", NULL, ";", NULL, false);
log_info("/* quoted semicolon with following arg */");
r = config_parse_exec(NULL, "fake", 5, "section", 1,
@@ -294,11 +294,7 @@ static void test_config_parse_exec(void) {
assert_se(r >= 0);
c1 = c1->command_next;
check_execcommand(c1,
- "/sbin/find", NULL, NULL, NULL, false);
-
- c1 = c1->command_next;
- check_execcommand(c1,
- "/x", NULL, NULL, NULL, false);
+ "/sbin/find", NULL, ";", "/x", false);
log_info("/* spaces in the filename */");
r = config_parse_exec(NULL, "fake", 5, "section", 1,