diff --git a/utils/aa-mergeprof b/utils/aa-mergeprof index d5700dbd2..8988e1956 100755 --- a/utils/aa-mergeprof +++ b/utils/aa-mergeprof @@ -126,8 +126,8 @@ def act(files, merging_profile): elif ans == 'CMD_VIEW_CHANGES': for program in programs: apparmor.aa.original_aa[program] = apparmor.aa.deepcopy(apparmor.aa.aa[program]) - #oldprofile = apparmor.serialize_profile(apparmor.original_aa[program], program, '') - newprofile = apparmor.aa.serialize_profile(mergeprofiles.user.aa[program], program, '') + #oldprofile = apparmor.serialize_profile(apparmor.original_aa[program], program, {}) + newprofile = apparmor.aa.serialize_profile(mergeprofiles.user.aa[program], program, {}) aaui.UI_Changes(mergeprofiles.user.filename, newprofile, comments=True) elif ans == 'CMD_IGNORE_ENTRY': break diff --git a/utils/apparmor/aa.py b/utils/apparmor/aa.py index faa22deca..ccc81ea27 100644 --- a/utils/apparmor/aa.py +++ b/utils/apparmor/aa.py @@ -501,7 +501,7 @@ def get_profile(prof_name): inactive_profile[prof_name][prof_name].pop('filename') profile_hash[uname]['username'] = uname profile_hash[uname]['profile_type'] = 'INACTIVE_LOCAL' - profile_hash[uname]['profile'] = serialize_profile(inactive_profile[prof_name], prof_name, None) + profile_hash[uname]['profile'] = serialize_profile(inactive_profile[prof_name], prof_name, {}) profile_hash[uname]['profile_data'] = inactive_profile existing_profiles.pop(prof_name) # remove profile filename from list to force storing in /etc/apparmor.d/ instead of extra_profile_dir @@ -732,7 +732,6 @@ def sync_profile(): repo_profiles = [] changed_profiles = [] new_profiles = [] - serialize_opts = dict() status_ok, ret = fetch_profiles_by_user(cfg['repository']['url'], cfg['repository']['distro'], user) if not status_ok: @@ -741,7 +740,7 @@ def sync_profile(): aaui.UI_Important(_('WARNING: Error synchronizing profiles with the repository:\n%s\n') % ret) else: users_repo_profiles = ret - serialize_opts['NO_FLAGS'] = True + serialize_opts = {'FLAGS': False} for prof in sorted(aa.keys()): if is_repo_profile([aa[prof][prof]]): repo_profiles.append(prof) @@ -1892,15 +1891,14 @@ def save_profiles(): else: oldprofile = get_profile_filename(which) - serialize_options = {} - serialize_options['METADATA'] = True + serialize_options = {'METADATA': True} newprofile = serialize_profile(aa[which], which, serialize_options) aaui.UI_Changes(oldprofile, newprofile, comments=True) elif ans == 'CMD_VIEW_CHANGES_CLEAN': - oldprofile = serialize_profile(original_aa[which], which, '') - newprofile = serialize_profile(aa[which], which, '') + oldprofile = serialize_profile(original_aa[which], which, {}) + newprofile = serialize_profile(aa[which], which, {}) aaui.UI_Changes(oldprofile, newprofile) @@ -2666,15 +2664,13 @@ def write_piece(profile_data, depth, name, nhat, write_flags): def serialize_profile(profile_data, name, options): string = '' - include_metadata = False - include_flags = True data = [] - if options: # and type(options) == dict: - if options.get('METADATA', False): - include_metadata = True - if options.get('NO_FLAGS', False): - include_flags = False + if type(options) is not dict: + raise AppArmorBug('serialize_profile(): options is not a dict: %s' % options) + + include_metadata = options.get('METADATA', False) + include_flags = options.get('FLAGS', True) if include_metadata: string = '# Last Modified: %s\n' % time.asctime() @@ -2737,8 +2733,7 @@ def write_profile(profile): #os.chmod(newprof.name, permission_600) pass - serialize_options = {} - serialize_options['METADATA'] = True + serialize_options = {'METADATA': True} profile_string = serialize_profile(aa[profile], profile, serialize_options) newprof.write(profile_string) diff --git a/utils/apparmor/tools.py b/utils/apparmor/tools.py index 6123b9995..c812158dc 100644 --- a/utils/apparmor/tools.py +++ b/utils/apparmor/tools.py @@ -223,8 +223,8 @@ class aa_tools: apparmor.write_profile_ui_feedback(program) self.reload_profile(filename) elif ans == 'CMD_VIEW_CHANGES': - #oldprofile = apparmor.serialize_profile(apparmor.original_aa[program], program, '') - newprofile = apparmor.serialize_profile(apparmor.aa[program], program, '') + #oldprofile = apparmor.serialize_profile(apparmor.original_aa[program], program, {}) + newprofile = apparmor.serialize_profile(apparmor.aa[program], program, {}) aaui.UI_Changes(filename, newprofile, comments=True) else: apparmor.write_profile_ui_feedback(program) diff --git a/utils/test/test-libapparmor-test_multi.py b/utils/test/test-libapparmor-test_multi.py index a5bf5882c..642d874b9 100644 --- a/utils/test/test-libapparmor-test_multi.py +++ b/utils/test/test-libapparmor-test_multi.py @@ -260,7 +260,7 @@ def logfile_to_profile(logfile): apparmor.aa.filelist = apparmor.aa.hasher() apparmor.aa.filelist[profile_dummy_file]['profiles'][profile] = True - new_profile = apparmor.aa.serialize_profile(log_dict[aamode][profile], profile, None) + new_profile = apparmor.aa.serialize_profile(log_dict[aamode][profile], profile, {}) return profile, new_profile