Skip to content

Commit

Permalink
Support m4 quoted strings in interface call arguments
Browse files Browse the repository at this point in the history
Required for escaped strings, that would otherwise be replaced by m4,
e.g. "interface":

    filetrans_pattern(foo_t, bar_run_t, baz_run_t, dir, ``"interface"'')

Replaces: SELinuxProject#289
  • Loading branch information
cgzones committed Aug 24, 2024
1 parent a268f67 commit ed58cb9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
%type<string> arg_list_item
%type<sl> arg
%type<sl> args
%type<sl> arg_m4_quoted
%type<string> mls_range
%type<string> mls_level
%type<string> mls_component
Expand Down Expand Up @@ -801,14 +802,22 @@ arg_list_item:
NUMBER
;

arg_m4_quoted:
QUOTED_STRING { $$ = sl_from_str_consume($1); }
|
mls_range { $$ = sl_from_str_consume($1); }
|
%empty { $$ = sl_from_str(""); }
|
BACKTICK arg_m4_quoted SINGLE_QUOTE { $$ = $2; }
;

arg:
arg_list
|
QUOTED_STRING { $$ = sl_from_str_consume($1); }
|
BACKTICK mls_range SINGLE_QUOTE { $$ = sl_from_str_consume($2); }
|
BACKTICK SINGLE_QUOTE { $$ = sl_from_str(""); }
BACKTICK arg_m4_quoted SINGLE_QUOTE { $$ = $2; }
;

args:
Expand Down
2 changes: 2 additions & 0 deletions tests/sample_policy_files/uncommon.te
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,5 @@ optional_policy(`
call_some_interface(foo_t)
')
')

filetrans_pattern(foo_t, bar_run_t, baz_run_t, dir, ``"interface"'')

0 comments on commit ed58cb9

Please sign in to comment.