Blame SOURCES/0035-python-sepolgen-allow-any-policy-statement-in-if-n-d.patch

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