2
0
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:
Georgia Garcia 2025-08-13 12:33:18 -03:00
parent f9690cdb6c
commit 19f0ac1773
2 changed files with 9 additions and 1 deletions

View File

@ -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);

View File

@ -0,0 +1,8 @@
#=DESCRIPTION conditional within profile
#=EXRESULT PASS
/bin/true {
if defined $UNKNOWN {
/bin/true rix,
}
}