2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 10:07:12 +00:00

fix regression in {get,set}_profile_flags()

Since the latest change, calling {get,set}_profile_flags() with the
profile name failed when attachment was specified ("profile foo /bar").

Catched by the unittests.

Also fix a whitespace issue.
This commit is contained in:
Christian Boltz 2018-04-14 21:45:39 +02:00 committed by Christian Boltz
parent 059adcdf76
commit f472b6bb34

View File

@ -617,7 +617,7 @@ def get_profile_flags(filename, program):
else:
profile_glob = AARE(matches['profile'], True)
flags = matches['flags']
if (program is not None and profile_glob.match(program)) or program is None:
if (program is not None and profile_glob.match(program)) or program is None or program == matches['profile']:
return flags
raise AppArmorException(_('%s contains no profile') % filename)
@ -674,10 +674,11 @@ def set_profile_flags(prof_filename, program, newflags):
profile_glob = AARE(matches['attachment'], True)
else:
profile_glob = AARE(matches['profile'], True)
if (program is not None and profile_glob.match(program)) or program is None:
if (program is not None and profile_glob.match(program)) or program is None or program == matches['profile']:
found = True
if program is not None and program != profile:
aaui.UI_Info(_('Warning: profile %s represents multiple programs') % profile)
aaui.UI_Info(_('Warning: profile %s represents multiple programs') % profile)
header_data = {
'attachment': matches['attachment'] or '',
'flags': newflags,