Skip to content

Commit

Permalink
sepolgen-ifgen: allow M4 escaped filenames
Browse files Browse the repository at this point in the history
When a file name in type transition rule used in an interface is same as
a keyword, it needs to be M4 escaped so that the keyword is not expanded
by M4, e.g.

-	filetrans_pattern($1, virt_var_run_t, virtinterfaced_var_run_t, dir, "interface")
+	filetrans_pattern($1, virt_var_run_t, virtinterfaced_var_run_t, dir, ``"interface"'')

But sepolgen-ifgen could not parse such string:

    # sepolgen-ifgen
    Illegal character '`'

This change allows M4 escaping inside quoted strings and fixed described
problem.

https://bugzilla.redhat.com/show_bug.cgi?id=2254206

Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
Acked-by: James Carter <jwcart2@gmail.com>
  • Loading branch information
bachradsusi authored and jwcart2 committed Dec 17, 2024
1 parent adf2e60 commit 2fc29ae
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion python/sepolgen/src/sepolgen/refparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def p_interface_call_param(p):
| nested_id_set
| TRUE
| FALSE
| FILENAME
| quoted_filename
'''
# Intentionally let single identifiers pass through
# List means set, non-list identifier
Expand Down Expand Up @@ -1027,6 +1027,11 @@ def p_optional_semi(p):
| empty'''
pass

def p_quoted_filename(p):
'''quoted_filename : TICK quoted_filename SQUOTE
| FILENAME
'''
p[0] = p[1]

#
# Interface to the parser
Expand Down

0 comments on commit 2fc29ae

Please sign in to comment.