diff --git a/utils/apparmor/rule/mount.py b/utils/apparmor/rule/mount.py index 64e9cbdd5..64417832c 100644 --- a/utils/apparmor/rule/mount.py +++ b/utils/apparmor/rule/mount.py @@ -51,13 +51,13 @@ join_valid_fs = '|'.join(valid_fs) sep = r"\s*[\s,]\s*" fs_type_pattern = r"\b(?Pfstype|vfstype)\b\s*(?P=|in)\s*"\ - r"(?P\(\s*(" + join_valid_fs + ")(" + sep + "(" + join_valid_fs + "))*\s*\)|"\ + r"(?P\(\s*(" + join_valid_fs + ")(" + sep + "(" + join_valid_fs + r"))*\s*\)|"\ r"\{\s*(" + join_valid_fs + ")(" + sep + "(" + join_valid_fs + r"))*\s*\}|(\s*" + join_valid_fs + "))"\ option_pattern = r"\s*(\boption(s?)\b\s*(?P=|in)\s*"\ r"(?P\(\s*(" + join_valid_flags + ")(" + sep + "(" + join_valid_flags + r"))*\s*\)|" \ - "(\s*" + join_valid_flags + ")"\ + r"(\s*" + join_valid_flags + ")"\ "))?" mount_condition_pattern = rf"({fs_type_pattern})?\s*({option_pattern})?" @@ -103,13 +103,7 @@ class MountRule(BaseRule): raise AppArmorException(_('Passed unknown options keyword to %s: %s') % (type(self).__name__, ' '.join(unknown_items))) self.is_options_equal = options[0] if not self.all_options else None - if source != self.ALL and source[0].isalpha(): - self.source = source - self.all_source = False - self.source_is_path = False - else: - self.source_is_path = True - self.source, self.all_source = self._aare_or_all(source, 'source', is_path=self.source_is_path, log_event=log_event) + self.source, self.all_source = self._aare_or_all(source, 'source', is_path=False, log_event=log_event) if not self.all_fstype and self.is_fstype_equal not in ("=", "in"): raise AppArmorBug(f'Invalid is_fstype_equal : {self.is_fstype_equal}') @@ -223,12 +217,7 @@ class MountRule(BaseRule): return False if not self._is_covered_list(self.options, self.all_options, other_rule.options, other_rule.all_options, 'options'): return False - if not self.source_is_path and not other_rule.source_is_path: - if self.source != other_rule.source: - return False - elif self.source_is_path != other_rule.source_is_path: - return False - elif not self._is_covered_aare(self.source, self.all_source, other_rule.source, other_rule.all_source, 'source'): + if not self._is_covered_aare(self.source, self.all_source, other_rule.source, other_rule.all_source, 'source'): return False if not self._is_covered_aare(self.dest, self.all_dest, other_rule.dest, other_rule.all_dest, 'dest'): return False @@ -244,12 +233,7 @@ class MountRule(BaseRule): return False if self.fstype != rule_obj.fstype or self.options != rule_obj.options: return False - if not self.source_is_path and not rule_obj.source_is_path: - if self.source != rule_obj.source: - return False - elif self.source_is_path != rule_obj.source_is_path: - return False - elif not self._is_equal_aare(self.source, self.all_source, rule_obj.source, rule_obj.all_source, 'source'): + if not self._is_equal_aare(self.source, self.all_source, rule_obj.source, rule_obj.all_source, 'source'): return False if not self._is_equal_aare(self.dest, self.all_dest, rule_obj.dest, rule_obj.all_dest, 'dest'): return False