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,8 +587,8 @@ def autodep(bin_name, pname=''):
|
||||
|
||||
attachment = profile_data[pname]['attachment']
|
||||
if not attachment and pname.startswith('/'):
|
||||
active_profiles.add_profile(file, pname, pname) # use name as name and attachment
|
||||
else:
|
||||
attachment = pname # use name as name and attachment
|
||||
|
||||
active_profiles.add_profile(file, pname, attachment)
|
||||
|
||||
if os.path.isfile(profile_dir + '/abi/3.0'):
|
||||
@@ -1742,8 +1742,8 @@ def read_profile(file, active_profile):
|
||||
filename = profile_data[profile]['filename']
|
||||
|
||||
if not attachment and profile.startswith('/'):
|
||||
active_profiles.add_profile(filename, profile, profile) # use profile as name and attachment
|
||||
else:
|
||||
attachment = profile # use profile as name and attachment
|
||||
|
||||
active_profiles.add_profile(filename, profile, attachment)
|
||||
|
||||
else:
|
||||
@@ -1752,8 +1752,8 @@ def read_profile(file, active_profile):
|
||||
filename = profile_data[profile]['filename']
|
||||
|
||||
if not attachment and profile.startswith('/'):
|
||||
extra_profiles.add_profile(filename, profile, profile, profile_data[profile]) # use profile as name and attachment
|
||||
else:
|
||||
attachment = profile # use profile as name and attachment
|
||||
|
||||
extra_profiles.add_profile(filename, profile, attachment, profile_data[profile])
|
||||
|
||||
def attach_profile_data(profiles, profile_data):
|
||||
|
Reference in New Issue
Block a user