From 469eb444de27fe2c20226b6f15b5b72b12af3ee7 Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Sat, 9 Jun 2018 14:26:18 +0200 Subject: [PATCH] use serialize_profile() for the new profile in (V)iew Changes ... instead of serialize_profile_from_old_profile() This will give a realistic preview of the changes (serialize_profile() is also used when actually writing the profile) and replaces the known-buggy serialize_profile_from_old_profile() with known-working code. It also fixes the issue reported in https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/1528139 which means we no longer need the workaround of catching AttributeError (verified in manual before/after test) References: - https://bugs.launchpad.net/apparmor/+bug/1394788 - https://bugs.launchpad.net/bugs/1528139 - https://bugs.launchpad.net/apparmor/+bug/1404893 --- utils/apparmor/aa.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/utils/apparmor/aa.py b/utils/apparmor/aa.py index 410a3f6aa..4d9482b44 100644 --- a/utils/apparmor/aa.py +++ b/utils/apparmor/aa.py @@ -1893,11 +1893,9 @@ def save_profiles(): else: oldprofile = get_profile_filename(which) - try: - newprofile = serialize_profile_from_old_profile(aa[which], which, '') - except AttributeError: - # see https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/1528139 - newprofile = "###\n###\n### Internal error while generating diff, please use '%s' instead\n###\n###\n" % _('View Changes b/w (C)lean profiles') + serialize_options = {} + serialize_options['METADATA'] = True + newprofile = serialize_profile(aa[which], which, serialize_options) aaui.UI_Changes(oldprofile, newprofile, comments=True)