Skip to content

Commit

Permalink
sepolgen: parse gen_tunable as bool
Browse files Browse the repository at this point in the history
Currently sepolgen-ifgen parses a gen_tunable statement as interface
and reports in verbose mode:

    Missing interface definition for gen_tunable

Add grammar for gen_tunable statements in the refparser

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
  • Loading branch information
cgzones authored and bachradsusi committed Jun 18, 2020
1 parent ddcd6d1 commit 5adc269
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions python/sepolgen/src/sepolgen/refparser.py
Expand Up @@ -126,6 +126,7 @@
'GEN_REQ',
'TEMPLATE',
'GEN_CONTEXT',
'GEN_TUNABLE',
# m4
'IFELSE',
'IFDEF',
Expand Down Expand Up @@ -192,6 +193,7 @@
'gen_require' : 'GEN_REQ',
'template' : 'TEMPLATE',
'gen_context' : 'GEN_CONTEXT',
'gen_tunable' : 'GEN_TUNABLE',
# M4
'ifelse' : 'IFELSE',
'ifndef' : 'IFNDEF',
Expand Down Expand Up @@ -518,6 +520,7 @@ def p_policy_stmt(p):
| range_transition_def
| role_transition_def
| bool
| gen_tunable
| define
| initial_sid
| genfscon
Expand Down Expand Up @@ -844,6 +847,17 @@ def p_bool(p):
b.state = False
p[0] = b

def p_gen_tunable(p):
'''gen_tunable : GEN_TUNABLE OPAREN TICK IDENTIFIER SQUOTE COMMA TRUE CPAREN
| GEN_TUNABLE OPAREN TICK IDENTIFIER SQUOTE COMMA FALSE CPAREN'''
b = refpolicy.Bool()
b.name = p[4]
if p[7] == "true":
b.state = True
else:
b.state = False
p[0] = b

def p_conditional(p):
''' conditional : IF OPAREN cond_expr CPAREN OBRACE interface_stmts CBRACE
| IF OPAREN cond_expr CPAREN OBRACE interface_stmts CBRACE ELSE OBRACE interface_stmts CBRACE
Expand Down

0 comments on commit 5adc269

Please sign in to comment.