From d11055aa0ceed55bcc88736fc67561b797bff3d4 Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Tue, 14 Oct 2014 12:54:39 +0200 Subject: [PATCH] Fix "Invalid mode found: /usr/lib64/firefox/firefox.sh" After several hours of debugging on IRC and flooding paste.opensuse.org ;-) I finally found the reason - reading(!) from log_dict with a wrong key caused the creation of that strange mode in log_dict.keys(). While finding that bug was very hard, the fix is easy - just replace "profile" with "aamode". (That probably makes one char per hour of debugging...) To improve that ratio, also add a warning to common.py so that this interesting[tm] behaviour of hasher() is at least documented. Acked-by: Steve Beattie --- utils/apparmor/aa.py | 2 +- utils/apparmor/common.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/apparmor/aa.py b/utils/apparmor/aa.py index 815e691f3..e67de5321 100644 --- a/utils/apparmor/aa.py +++ b/utils/apparmor/aa.py @@ -1938,7 +1938,7 @@ def ask_the_questions(): # for family in sorted(log_dict[aamode][profile][hat]['netdomain'].keys()): # severity handling for net toggles goes here - for sock_type in sorted(log_dict[profile][profile][hat]['netdomain'][family].keys()): + for sock_type in sorted(log_dict[aamode][profile][hat]['netdomain'][family].keys()): if profile_known_network(aa[profile][hat], family, sock_type): continue default_option = 1 diff --git a/utils/apparmor/common.py b/utils/apparmor/common.py index a94b78780..208589fc0 100644 --- a/utils/apparmor/common.py +++ b/utils/apparmor/common.py @@ -200,6 +200,8 @@ def readkey(): def hasher(): '''A neat alternative to perl's hash reference''' # Creates a dictionary for any depth and returns empty dictionary otherwise + # WARNING: when reading non-existing sub-dicts, empty dicts will be added. + # This might cause strange effects when using .keys() return collections.defaultdict(hasher) def convert_regexp(regexp):