ProfileList addProfile(): always hand over ProfileStorage

... and make it non-optional

Note that read_profile() in aa.py skips child profiles and hats,
therefore active_profiles for now only contains the main profiles.
This commit is contained in:
Christian Boltz 2024-10-06 19:31:06 +02:00
parent b2f713dd83
commit 792d1a5568
Failed to generate hash of commit
2 changed files with 4 additions and 4 deletions

View file

@ -511,7 +511,7 @@ def autodep(bin_name, pname=''):
if not attachment and pname.startswith('/'):
attachment = pname # use name as name and attachment
active_profiles.add_profile(file, pname, attachment)
active_profiles.add_profile(file, pname, attachment, profile_data[pname])
if os.path.isfile(profile_dir + '/abi/4.0'):
active_profiles.add_abi(file, AbiRule('abi/4.0', False, True))
@ -1675,7 +1675,7 @@ def read_profile(file, active_profile, read_error_fatal=False):
if not attachment and profile.startswith('/'):
attachment = profile # use profile as name and attachment
active_profiles.add_profile(filename, profile, attachment)
active_profiles.add_profile(filename, profile, attachment, profile_data[profile])
else:
for profile in profile_data:

View file

@ -63,7 +63,7 @@ class ProfileList:
for rule in preamble_ruletypes:
self.files[filename][rule] = preamble_ruletypes[rule]['ruleset']()
def add_profile(self, filename, profile_name, attachment, prof_storage=None):
def add_profile(self, filename, profile_name, attachment, prof_storage):
"""Add the given profile and attachment to the list"""
if not filename:
@ -72,7 +72,7 @@ class ProfileList:
if not profile_name and not attachment:
raise AppArmorBug('Neither profile name or attachment given')
if type(prof_storage) is not ProfileStorage and prof_storage is not None:
if type(prof_storage) is not ProfileStorage:
raise AppArmorBug('Invalid profile type: %s' % type(prof_storage))
if profile_name in self.profile_names: