2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 01:57:43 +00:00

utils aa-notify: Add a special case for snap policy

Snap policy is a special case of the unknown profile. Give the user
a slightly better message for these messages.

Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
John Johansen 2025-02-08 22:04:29 -08:00
parent 9cb72734eb
commit 62123c6feb

View File

@ -352,7 +352,6 @@ def parse_logdata(logsource):
# Pre-filter log lines so that we hand over only relevant lines to LibAppArmor parsing
re_log_all = re.compile('(' + '|'.join(re_log_parts) + ')')
for entry in logsource:
# Check the start of the log line and only process lines from AppArmor
@ -760,6 +759,8 @@ def get_aggregated(rl, agg, max_nb_profiles, keys_to_aggregate, special_profiles
if profile not in special_profiles:
if profile_path is not None:
clean_rules_name = _('profile {}:').format(profile)
elif re_snap.match(profile):
clean_rules_name = _('profile "{}" managed by snapd can not be modified:').format(profile)
else:
clean_rules_name = _('# Unknown profile "{}" can not be modified:').format(profile)
else:
@ -801,6 +802,9 @@ def main():
"""
global _, debug_logger, config, args
global debug_docs_url, nobody_user, original_effective_user, timeformat
global re_snap
re_snap = re.compile("^snap[.]")
debug_docs_url = "https://wiki.ubuntu.com/DebuggingApparmor"
nobody_user = "nobody"