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

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