From cd95d46397e5c6769f856dfd43cb544cd2e61b4f Mon Sep 17 00:00:00 2001 From: John Johansen Date: Sat, 11 May 2024 23:46:49 -0700 Subject: [PATCH] parser: split parse boolean into boolean and integer the parser front end boolean is used for both boolean and integer values. This is confusing when integer values different than 1 or 0 are being assigned to and from boolean. Split its uses into the correct semantic boolean and integer cases. Signed-off-by: John Johansen --- parser/parser_yacc.y | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/parser/parser_yacc.y b/parser/parser_yacc.y index f94a5808f..c8fa67df5 100644 --- a/parser/parser_yacc.y +++ b/parser/parser_yacc.y @@ -222,7 +222,8 @@ static void abi_features(char *filename, bool search); struct value_list *val_list; struct cond_entry *cond_entry; struct cond_entry_list cond_entry_list; - int boolean; + bool boolean; + int integer; owner_t owner; struct prefixes prefix; IncludeCache_t *includecache; @@ -270,7 +271,7 @@ static void abi_features(char *filename, bool search); %type opt_subset_flag %type opt_audit_flag %type opt_owner_flag -%type opt_profile_flag +%type opt_profile_flag %type opt_flags %type opt_rule_mode %type opt_id @@ -294,7 +295,7 @@ static void abi_features(char *filename, bool search); %type unix_rule %type opt_target %type opt_named_transition -%type opt_exec_mode +%type opt_exec_mode %type opt_file %type userns_perm %type userns_perms @@ -588,13 +589,13 @@ flags: { /* nothing */ $$ = fv; }; -opt_flags: { /* nothing */ $$ = 0; } +opt_flags: { /* nothing */ $$ = false; } | TOK_CONDID TOK_EQUALS { if (strcmp($1, "flags") != 0) yyerror("expected flags= got %s=", $1); free($1); - $$ = 1; + $$ = true; } flags: opt_flags TOK_OPENPAREN flagvals TOK_CLOSEPAREN @@ -1011,8 +1012,8 @@ opt_exec_mode: { /* nothing */ $$ = EXEC_MODE_EMPTY; } | TOK_UNSAFE { $$ = EXEC_MODE_UNSAFE; }; | TOK_SAFE { $$ = EXEC_MODE_SAFE; }; -opt_file: { /* nothing */ $$ = 0; } - | TOK_FILE { $$ = 1; } +opt_file: { /* nothing */ $$ = false; } + | TOK_FILE { $$ = true; } frule: id_or_var file_perms opt_named_transition TOK_END_OF_RULE {