mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-09-03 07:45:50 +00:00
deduplicate code in read_profile() and autodep()
if a profile doesn't have an attachment specified and the profile name starts with '/', set the attachment to the profile name. This allows to have one add_profile() call instead of two very similar ones.
This commit is contained in:
@@ -587,9 +587,9 @@ def autodep(bin_name, pname=''):
|
|||||||
|
|
||||||
attachment = profile_data[pname]['attachment']
|
attachment = profile_data[pname]['attachment']
|
||||||
if not attachment and pname.startswith('/'):
|
if not attachment and pname.startswith('/'):
|
||||||
active_profiles.add_profile(file, pname, pname) # use name as name and attachment
|
attachment = pname # use name as name and attachment
|
||||||
else:
|
|
||||||
active_profiles.add_profile(file, pname, attachment)
|
active_profiles.add_profile(file, pname, attachment)
|
||||||
|
|
||||||
if os.path.isfile(profile_dir + '/abi/3.0'):
|
if os.path.isfile(profile_dir + '/abi/3.0'):
|
||||||
active_profiles.add_abi(file, AbiRule('abi/3.0', False, True))
|
active_profiles.add_abi(file, AbiRule('abi/3.0', False, True))
|
||||||
@@ -1742,9 +1742,9 @@ def read_profile(file, active_profile):
|
|||||||
filename = profile_data[profile]['filename']
|
filename = profile_data[profile]['filename']
|
||||||
|
|
||||||
if not attachment and profile.startswith('/'):
|
if not attachment and profile.startswith('/'):
|
||||||
active_profiles.add_profile(filename, profile, profile) # use profile as name and attachment
|
attachment = profile # use profile as name and attachment
|
||||||
else:
|
|
||||||
active_profiles.add_profile(filename, profile, attachment)
|
active_profiles.add_profile(filename, profile, attachment)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
for profile in profile_data:
|
for profile in profile_data:
|
||||||
@@ -1752,9 +1752,9 @@ def read_profile(file, active_profile):
|
|||||||
filename = profile_data[profile]['filename']
|
filename = profile_data[profile]['filename']
|
||||||
|
|
||||||
if not attachment and profile.startswith('/'):
|
if not attachment and profile.startswith('/'):
|
||||||
extra_profiles.add_profile(filename, profile, profile, profile_data[profile]) # use profile as name and attachment
|
attachment = profile # use profile as name and attachment
|
||||||
else:
|
|
||||||
extra_profiles.add_profile(filename, profile, attachment, profile_data[profile])
|
extra_profiles.add_profile(filename, profile, attachment, profile_data[profile])
|
||||||
|
|
||||||
def attach_profile_data(profiles, profile_data):
|
def attach_profile_data(profiles, profile_data):
|
||||||
profile_data = merged_to_split(profile_data)
|
profile_data = merged_to_split(profile_data)
|
||||||
|
Reference in New Issue
Block a user