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