Skip to content

Commit

Permalink
Allow fullprivileges command flag
Browse files Browse the repository at this point in the history
This commit allows the "+"(fullprivileges) command flag along with
"-" and "@" flags.

Fixes: hercules-team#839

Signed-off-by: Cosmin Tupangiu <[email protected]>
Reported-by: Yongkui Guo <[email protected]>
  • Loading branch information
tupyy committed Aug 14, 2024
1 parent 8018934 commit 73b7453
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lenses/systemd.aug
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ let sto_value = store /[^# \t\n]*[^# \t\n\\]/
let value_sep = del /[ \t]+|[ \t]*\\\\[ \t]*\n[ \t]*/ " "

(* Variable: value_cmd_re
Don't parse @ and - prefix flags *)
let value_cmd_re = /[^#@ \t\n\\-][^#@ \t\n\\-][^# \t\n\\]*/
Don't parse @, - and + prefix flags *)
let value_cmd_re = /[^#@+ \t\n\\-][^#@+ \t\n\\-][^# \t\n\\]*/

(* Variable: env_key *)
let env_key = /[A-Za-z0-9_]+(\[[0-9]+\])?/
Expand Down Expand Up @@ -111,11 +111,12 @@ let entry_multi = entry_fn entry_multi_kw
. Build.opt_list entry_value value_sep )?

(* View: entry_command_flags
Exec* flags "@" and "-". Order is important, see systemd.service(8) *)
Exec* flags "@", "-" and "+". Order is important, see systemd.service(8) *)
let entry_command_flags =
let exit = [ label "ignoreexit" . Util.del_str "-" ]
let fullprivileges = [ label "fullprivileges" . Util.del_str "+" ]
in let exit = [ label "ignoreexit" . Util.del_str "-" ]
in let arg0 = [ label "arg0" . Util.del_str "@" ]
in exit? . arg0?
in fullprivileges? . exit? . arg0?

(* View: entry_command
Entry that takes a command, arguments and the optional prefix flags *)
Expand Down
9 changes: 9 additions & 0 deletions lenses/tests/test_systemd.aug
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,12 @@ test Systemd.lns get "[Service]\nExecStart= /usr/bin/find\nEnvironment= TERM=li
{ "command" = "/usr/bin/find" } }
{ "Environment"
{ "TERM" = "linux" } } }

(* Test: Systemd.lns
+ and - are OK for command prefixes *)
test Systemd.lns get "[Service]\nExecStart=+-/bin/echo\n" =
{ "Service"
{ "ExecStart"
{ "fullprivileges" }
{ "ignoreexit" }
{ "command" = "/bin/echo" }} }

0 comments on commit 73b7453

Please sign in to comment.