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 <[email protected]>
  • Loading branch information
bachradsusi committed Nov 28, 2024
1 parent 7e8d67e commit d95931c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion python/sepolgen/src/sepolgen/refparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def t_IDENTIFIER(t):
return t

def t_FILENAME(t):
r'\"[a-zA-Z0-9_\-\+\.\$\*~ :\[\]]+\"'
r'\"`*[a-zA-Z0-9_\-\+\.\$\*~ :\[\]]+\'*\"'
# Handle any keywords
t.type = reserved.get(t.value,'FILENAME')
return t
Expand Down

0 comments on commit d95931c

Please sign in to comment.