From f09676f5f9f6bd3acaf7fa1bb8529109c30e2bc0 Mon Sep 17 00:00:00 2001 From: John Johansen Date: Tue, 28 Mar 2023 14:35:24 -0700 Subject: [PATCH] parser: fixup gen_flag_rules gen_flag_rules has a boolean vs bit and case where parenthesis are helpful to express the intended order of operations. It also doesn't handle the case where there are no matches. Fix this by causing that case to fail. also improve the debug of option extraction. Signed-off-by: John Johansen --- parser/mount.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/parser/mount.cc b/parser/mount.cc index d499e73e9..4716c3049 100644 --- a/parser/mount.cc +++ b/parser/mount.cc @@ -413,7 +413,8 @@ static struct cond_entry *extract_options(struct cond_entry **conds, int eq) strcmp(entry->name, "option") == 0) && entry->eq == eq) { list_remove_at(*conds, prev, entry); - PDEBUG(" extracting option %s\n", entry->name); + PDEBUG(" extracting %s %s\n", entry->name, entry->eq ? +"=" : "in"); list_append(entry, list); list = entry; } else @@ -980,12 +981,12 @@ int mnt_rule::gen_flag_rules(Profile &prof, int &count, unsigned int flags, && !dev_type && !opts) { return gen_policy_move_mount(prof, count, flags, opt_flags); } else if ((allow & AA_MAY_MOUNT) && - (flags | opt_flags) & ~MS_CMDS) { + ((flags | opt_flags) & ~MS_CMDS)) { /* generic mount if flags are set that are not covered by * above commands */ return gen_policy_new_mount(prof, count, flags, opt_flags); - } + } /* else must be RULE_OK for some rules */ return RULE_OK; }