From 5c48eb7aa7c26bdcc39ded618929d91bce04ba0d Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Sun, 10 May 2020 18:02:29 +0200 Subject: [PATCH] Drop / inline write_rules() The TODO in write_rules() was long solved - remove the safety net type check, it's no longer needed. Without this, the function becomes a simple .get_rules_clean() call which can easily be inlined into write_piece() at the two places where it's called. --- utils/apparmor/aa.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/utils/apparmor/aa.py b/utils/apparmor/aa.py index 159a9b9ce..84a1d335b 100644 --- a/utils/apparmor/aa.py +++ b/utils/apparmor/aa.py @@ -2205,18 +2205,6 @@ def write_header(prof_data, depth, name, embedded_hat, write_flags): return data -def write_rules(prof_data, depth): - if type(prof_data) is not ProfileStorage: - # TODO: find out why prof_data is not a ProfileStorage object in 11 of the libapparmor test_multi testcases - # (mostly seems to affect profiles with child profiles, which could mean the libapparmor test code - # doesn't initialize empty parent profiles.) - # "normal" aa-logprof usage doesn't seem to trigger this - - print('*** WARNING: prof_data is not a ProfileStorage object ***') - return [] - - return prof_data.get_rules_clean(depth) - def write_piece(profile_data, depth, name, nhat, write_flags): pre = ' ' * depth data = [] @@ -2229,7 +2217,7 @@ def write_piece(profile_data, depth, name, nhat, write_flags): name = nhat inhat = True data += write_header(profile_data[name], depth, wname, False, write_flags) - data += write_rules(profile_data[name], depth + 1) + data += profile_data[name].get_rules_clean(depth + 1) pre2 = ' ' * (depth + 1) @@ -2243,7 +2231,7 @@ def write_piece(profile_data, depth, name, nhat, write_flags): else: data += write_header(profile_data[hat], depth + 1, '^' + hat, True, write_flags) - data += write_rules(profile_data[hat], depth + 2) + data += profile_data[hat].get_rules_clean(depth + 2) data.append('%s}' % pre2)