mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-22 10:07:12 +00:00
parser: fix validation of "defined" boolean variable conditional
"Defined" operations on boolean variables were returning the value of the boolean variable instead of checking if it existed or not. That caused the parser to fail to compile the profile if the boolean variable was not defined, which is the whole purpose of the "defined" operation. Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
This commit is contained in:
parent
f9690cdb6c
commit
19f0ac1773
@ -1006,7 +1006,7 @@ factor: TOK_DEFINED TOK_SET_VAR
|
|||||||
|
|
||||||
factor: TOK_DEFINED TOK_BOOL_VAR
|
factor: TOK_DEFINED TOK_BOOL_VAR
|
||||||
{
|
{
|
||||||
cond_expr *conds = new cond_expr($2, BOOLEAN_OP);
|
cond_expr *conds = new cond_expr($2, DEFINED_OP);
|
||||||
PDEBUG("Matched: defined set expr %s value %d\n", $2, conds->eval());
|
PDEBUG("Matched: defined set expr %s value %d\n", $2, conds->eval());
|
||||||
$$ = conds;
|
$$ = conds;
|
||||||
free($2);
|
free($2);
|
||||||
|
8
parser/tst/simple_tests/conditional/ok_31.sd
Normal file
8
parser/tst/simple_tests/conditional/ok_31.sd
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#=DESCRIPTION conditional within profile
|
||||||
|
#=EXRESULT PASS
|
||||||
|
|
||||||
|
/bin/true {
|
||||||
|
if defined $UNKNOWN {
|
||||||
|
/bin/true rix,
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user