From 19f0ac1773973b922ee922255b47f2f987b46d57 Mon Sep 17 00:00:00 2001 From: Georgia Garcia Date: Wed, 13 Aug 2025 12:33:18 -0300 Subject: [PATCH] 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 --- parser/parser_yacc.y | 2 +- parser/tst/simple_tests/conditional/ok_31.sd | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 parser/tst/simple_tests/conditional/ok_31.sd diff --git a/parser/parser_yacc.y b/parser/parser_yacc.y index 5612359be..b721aaa67 100644 --- a/parser/parser_yacc.y +++ b/parser/parser_yacc.y @@ -1006,7 +1006,7 @@ factor: TOK_DEFINED TOK_SET_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()); $$ = conds; free($2); diff --git a/parser/tst/simple_tests/conditional/ok_31.sd b/parser/tst/simple_tests/conditional/ok_31.sd new file mode 100644 index 000000000..678989e73 --- /dev/null +++ b/parser/tst/simple_tests/conditional/ok_31.sd @@ -0,0 +1,8 @@ +#=DESCRIPTION conditional within profile +#=EXRESULT PASS + +/bin/true { + if defined $UNKNOWN { + /bin/true rix, + } +}