|
|
ab36df |
From b8ea1456a156ffe54b2d8a972b14f89cc8f014eb Mon Sep 17 00:00:00 2001
|
|
|
ab36df |
From: Dominic Cleal <dcleal@redhat.com>
|
|
|
ab36df |
Date: Tue, 9 Sep 2014 11:29:25 +0100
|
|
|
ab36df |
Subject: [PATCH] Systemd: parse semicolons inside entry values, not as EOL
|
|
|
ab36df |
comments
|
|
|
ab36df |
|
|
|
ab36df |
Fixes RHBZ#1139498
|
|
|
ab36df |
|
|
|
ab36df |
(cherry picked from commit 414f049a8e65d84eb579d1e40dbf75045ed8d3bd)
|
|
|
ab36df |
|
|
|
ab36df |
Conflicts:
|
|
|
ab36df |
NEWS
|
|
|
ab36df |
---
|
|
|
ab36df |
lenses/systemd.aug | 24 ++++++++++++++----------
|
|
|
ab36df |
lenses/tests/test_systemd.aug | 29 +++++++++++++++++++++++++++++
|
|
|
ab36df |
2 files changed, 43 insertions(+), 10 deletions(-)
|
|
|
ab36df |
|
|
|
ab36df |
diff --git a/lenses/systemd.aug b/lenses/systemd.aug
|
|
|
ab36df |
index 370945b..e1d9e5a 100644
|
|
|
ab36df |
--- a/lenses/systemd.aug
|
|
|
ab36df |
+++ b/lenses/systemd.aug
|
|
|
ab36df |
@@ -29,9 +29,13 @@ autoload xfm
|
|
|
ab36df |
(* View: eol *)
|
|
|
ab36df |
let eol = Util.eol
|
|
|
ab36df |
|
|
|
ab36df |
-(* View: comment
|
|
|
ab36df |
- An <IniFile.comment> entry *)
|
|
|
ab36df |
-let comment = IniFile.comment IniFile.comment_re "#"
|
|
|
ab36df |
+(* View: eol_comment
|
|
|
ab36df |
+ An <IniFile.comment> entry for standalone comment lines (; or #) *)
|
|
|
ab36df |
+let comment = IniFile.comment IniFile.comment_re "#"
|
|
|
ab36df |
+
|
|
|
ab36df |
+(* View: eol_comment
|
|
|
ab36df |
+ An <IniFile.comment> entry for end of line comments (# only) *)
|
|
|
ab36df |
+let eol_comment = IniFile.comment "#" "#"
|
|
|
ab36df |
|
|
|
ab36df |
(* View: sep
|
|
|
ab36df |
An <IniFile.sep> entry *)
|
|
|
ab36df |
@@ -52,7 +56,7 @@ let entry_multi_kw =
|
|
|
ab36df |
in /[A-Za-z][A-Za-z0-9._-]+/ - forbidden
|
|
|
ab36df |
|
|
|
ab36df |
(* Variable: value_single_re *)
|
|
|
ab36df |
-let value_single_re = /[^;# \t\n\\][^;#\n\\]*[^;# \t\n\\]|[^;# \t\n\\]/
|
|
|
ab36df |
+let value_single_re = /[^# \t\n\\][^#\n\\]*[^# \t\n\\]|[^# \t\n\\]/
|
|
|
ab36df |
|
|
|
ab36df |
(* View: sto_value_single
|
|
|
ab36df |
Support multiline values with a backslash *)
|
|
|
ab36df |
@@ -61,7 +65,7 @@ let sto_value_single = Util.del_opt_ws ""
|
|
|
ab36df |
. (/\\\\\n/ . value_single_re)*)
|
|
|
ab36df |
|
|
|
ab36df |
(* View: sto_value *)
|
|
|
ab36df |
-let sto_value = store /[^;# \t\n]*[^;# \t\n\\]/
|
|
|
ab36df |
+let sto_value = store /[^# \t\n]*[^# \t\n\\]/
|
|
|
ab36df |
|
|
|
ab36df |
(* Variable: value_sep
|
|
|
ab36df |
Multi-value entries separated by whitespace or backslash and newline *)
|
|
|
ab36df |
@@ -69,7 +73,7 @@ let value_sep = del /[ \t]+|[ \t]*\\\\[ \t]*\n[ \t]*/ " "
|
|
|
ab36df |
|
|
|
ab36df |
(* Variable: value_cmd_re
|
|
|
ab36df |
Don't parse @ and - prefix flags *)
|
|
|
ab36df |
-let value_cmd_re = /[^;#@ \t\n\\-][^;#@ \t\n\\-][^;# \t\n\\]*/
|
|
|
ab36df |
+let value_cmd_re = /[^#@ \t\n\\-][^#@ \t\n\\-][^# \t\n\\]*/
|
|
|
ab36df |
|
|
|
ab36df |
(* Variable: env_key *)
|
|
|
ab36df |
let env_key = /[A-Za-z0-9_]+(\[[0-9]+\])?/
|
|
|
ab36df |
@@ -89,7 +93,7 @@ Supported entry features, selected by key names:
|
|
|
ab36df |
(* View: entry_fn
|
|
|
ab36df |
Prototype for our various key=value lines, with optional comment *)
|
|
|
ab36df |
let entry_fn (kw:regexp) (val:lens) =
|
|
|
ab36df |
- [ key kw . sep . val . (comment|eol) ]
|
|
|
ab36df |
+ [ key kw . sep . val . (eol_comment|eol) ]
|
|
|
ab36df |
|
|
|
ab36df |
(* View: entry_value
|
|
|
ab36df |
Store a value that doesn't contain spaces *)
|
|
|
ab36df |
@@ -127,9 +131,9 @@ let entry_command =
|
|
|
ab36df |
let entry_env =
|
|
|
ab36df |
let envkv (env_val:lens) = key env_key . Util.del_str "=" . env_val
|
|
|
ab36df |
(* bare has no spaces, and is optionally quoted *)
|
|
|
ab36df |
- in let bare = Quote.do_quote_opt (envkv (store /[^;#'" \t\n]*[^;#'" \t\n\\]/)?)
|
|
|
ab36df |
+ in let bare = Quote.do_quote_opt (envkv (store /[^#'" \t\n]*[^#'" \t\n\\]/)?)
|
|
|
ab36df |
(* quoted has at least one space, and must be quoted *)
|
|
|
ab36df |
- in let quoted = Quote.do_quote (envkv (store /[^;#"'\n]*[ \t]+[^;#"'\n]*/))
|
|
|
ab36df |
+ in let quoted = Quote.do_quote (envkv (store /[^#"'\n]*[ \t]+[^#"'\n]*/))
|
|
|
ab36df |
in let envkv_quoted = [ bare ] | [ quoted ]
|
|
|
ab36df |
in entry_fn entry_env_kw ( Build.opt_list envkv_quoted value_sep )
|
|
|
ab36df |
|
|
|
ab36df |
@@ -145,7 +149,7 @@ let entry = entry_single | entry_multi | entry_command | entry_env | comment
|
|
|
ab36df |
(* View: include
|
|
|
ab36df |
Includes another file at this position *)
|
|
|
ab36df |
let include = [ key ".include" . Util.del_ws_spc . sto_value
|
|
|
ab36df |
- . (comment|eol) ]
|
|
|
ab36df |
+ . (eol_comment|eol) ]
|
|
|
ab36df |
|
|
|
ab36df |
(* View: title
|
|
|
ab36df |
An <IniFile.title> *)
|
|
|
ab36df |
diff --git a/lenses/tests/test_systemd.aug b/lenses/tests/test_systemd.aug
|
|
|
ab36df |
index b1574e1..82516b3 100644
|
|
|
ab36df |
--- a/lenses/tests/test_systemd.aug
|
|
|
ab36df |
+++ b/lenses/tests/test_systemd.aug
|
|
|
ab36df |
@@ -307,3 +307,32 @@ test Systemd.entry_command get "ExecStart=/usr/bin/find /var/lib/sudo -exec /usr
|
|
|
ab36df |
{ "7" = "\073" }
|
|
|
ab36df |
}
|
|
|
ab36df |
}
|
|
|
ab36df |
+
|
|
|
ab36df |
+let exec_tmux = "ExecStart=/usr/bin/tmux unbind-key -a; \
|
|
|
ab36df |
+ kill-window -t anaconda:shell; \
|
|
|
ab36df |
+ bind-key ? list-keys\n"
|
|
|
ab36df |
+
|
|
|
ab36df |
+(* Test: Systemd.lns
|
|
|
ab36df |
+ Semicolons are permitted in entry values, e.g. as part of a command *)
|
|
|
ab36df |
+test Systemd.entry_command get exec_tmux =
|
|
|
ab36df |
+ { "ExecStart"
|
|
|
ab36df |
+ { "command" = "/usr/bin/tmux" }
|
|
|
ab36df |
+ { "arguments"
|
|
|
ab36df |
+ { "1" = "unbind-key" }
|
|
|
ab36df |
+ { "2" = "-a;" }
|
|
|
ab36df |
+ { "3" = "kill-window" }
|
|
|
ab36df |
+ { "4" = "-t" }
|
|
|
ab36df |
+ { "5" = "anaconda:shell;" }
|
|
|
ab36df |
+ { "6" = "bind-key" }
|
|
|
ab36df |
+ { "7" = "?" }
|
|
|
ab36df |
+ { "8" = "list-keys" } } }
|
|
|
ab36df |
+
|
|
|
ab36df |
+(* Test: Systemd.lns
|
|
|
ab36df |
+ # and ; are OK for standalone comments, but # only for EOL comments *)
|
|
|
ab36df |
+test Systemd.lns get "[Service]\n# hash\n; semicolon\nExecStart=/bin/echo # hash\n" =
|
|
|
ab36df |
+ { "Service"
|
|
|
ab36df |
+ { "#comment" = "hash" }
|
|
|
ab36df |
+ { "#comment" = "semicolon" }
|
|
|
ab36df |
+ { "ExecStart"
|
|
|
ab36df |
+ { "command" = "/bin/echo" }
|
|
|
ab36df |
+ { "#comment" = "hash" } } }
|