From e12f71e82f523513c249dbe5a2e35c1916370992 Mon Sep 17 00:00:00 2001 From: Vit Mojzis Date: Fri, 22 Jan 2021 16:25:52 +0100 Subject: [PATCH] python/sepolgen: allow any policy statement in if(n)def "ifdef/ifndef" statements can be used to conditionally define an interface, but this syntax is not recognised by sepolgen-ifgen. Fix sepolgen-ifgen to allow any policy statement inside an "ifdef/ifndef" statement. Fixes: $ cat < i.if ifndef(`apache_manage_pid_files',` interface(`apache_manage_pid_files',` manage_files_pattern($1, httpd_var_run_t, httpd_var_run_t) ') ') #sepolgen-ifgen --interface=i.if i.if: Syntax error on line 2 interface [type=INTERFACE] i.if: Syntax error on line 4 ' [type=SQUOTE] Signed-off-by: Vit Mojzis [OM: s/fidef/ifdef/] Signed-off-by: Ondrej Mosnacek --- python/sepolgen/src/sepolgen/refparser.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/sepolgen/src/sepolgen/refparser.py b/python/sepolgen/src/sepolgen/refparser.py index 9f850990..e611637f 100644 --- a/python/sepolgen/src/sepolgen/refparser.py +++ b/python/sepolgen/src/sepolgen/refparser.py @@ -433,9 +433,9 @@ def p_ifelse(p): def p_ifdef(p): - '''ifdef : IFDEF OPAREN TICK IDENTIFIER SQUOTE COMMA TICK interface_stmts SQUOTE CPAREN optional_semi - | IFNDEF OPAREN TICK IDENTIFIER SQUOTE COMMA TICK interface_stmts SQUOTE CPAREN optional_semi - | IFDEF OPAREN TICK IDENTIFIER SQUOTE COMMA TICK interface_stmts SQUOTE COMMA TICK interface_stmts SQUOTE CPAREN optional_semi + '''ifdef : IFDEF OPAREN TICK IDENTIFIER SQUOTE COMMA TICK statements SQUOTE CPAREN optional_semi + | IFNDEF OPAREN TICK IDENTIFIER SQUOTE COMMA TICK statements SQUOTE CPAREN optional_semi + | IFDEF OPAREN TICK IDENTIFIER SQUOTE COMMA TICK statements SQUOTE COMMA TICK statements SQUOTE CPAREN optional_semi ''' x = refpolicy.IfDef(p[4]) if p[1] == 'ifdef':