diff --git a/utils/aa-mergeprof b/utils/aa-mergeprof index 585727368..2e7447581 100755 --- a/utils/aa-mergeprof +++ b/utils/aa-mergeprof @@ -51,19 +51,13 @@ if profiledir: if not os.path.isdir(apparmor.aa.profile_dir): raise AppArmorException(_("%s is not a directory.") %profiledir) -def reset_aa(): - apparmor.aa.aa = apparmor.aa.hasher() - apparmor.aa.include = dict() - apparmor.aa.active_profiles = apparmor.aa.ProfileList() - apparmor.aa.original_aa = apparmor.aa.hasher() - def find_profiles_from_files(files): profile_to_filename = dict() for file_name in files: apparmor.aa.read_profile(file_name, True) for profile_name in apparmor.aa.active_profiles.profiles_in_file(file_name): profile_to_filename[profile_name] = file_name - reset_aa() + apparmor.aa.reset_aa() return profile_to_filename @@ -74,7 +68,7 @@ def find_files_from_profiles(profiles): for profile_name in profiles: profile_to_filename[profile_name] = apparmor.aa.get_profile_filename_from_profile_name(profile_name, True) - reset_aa() + apparmor.aa.reset_aa() return profile_to_filename @@ -92,7 +86,7 @@ def main(): act(user_file, base_file, profile_name) - reset_aa() + apparmor.aa.reset_aa() def act(user_file, base_file, merging_profile): mergeprofiles = Merge(user_file, base_file) @@ -110,7 +104,7 @@ class Merge(object): apparmor.aa.read_profile(base, True) self.base = cleanprofile.Prof(base) - reset_aa() + apparmor.aa.reset_aa() #Read and parse user profile apparmor.aa.read_profile(user, True) diff --git a/utils/apparmor/aa.py b/utils/apparmor/aa.py index 85b7a5966..bb81f1de4 100644 --- a/utils/apparmor/aa.py +++ b/utils/apparmor/aa.py @@ -110,6 +110,18 @@ created = [] helpers = dict() # Preserve this between passes # was our ### logprof ends +def reset_aa(): + ''' Reset the most important global variables + + Used by aa-mergeprof and some tests. + ''' + + global aa, include, active_profiles, original_aa + + aa = hasher() + include = dict() + active_profiles = ProfileList() + original_aa = hasher() def on_exit(): """Shutdowns the logger and records exit if debugging enabled"""