]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/test/test-unit-file.c
load-fragment: use unquote_first_word in config_parse_exec
authorFilipe Brandenburger <filbranden@google.com>
Sun, 31 May 2015 05:48:52 +0000 (22:48 -0700)
committerFilipe Brandenburger <filbranden@google.com>
Wed, 17 Jun 2015 18:12:12 +0000 (11:12 -0700)
commit46a0d98ac0fb5b507a6423e60058a2483830b432
tree9e8778c396ff42db125beeaf2b23e5329325c361
parent0e9800d5d938acb350b2a3a29b938bc1deed0313
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
src/core/load-fragment.c
src/test/test-unit-file.c