mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-29 13:28:19 +00:00
Merge Make save_profiles() usable for aa-mergeprof
... and replace the aa-mergeprof code that asks about saving the profile with a call to save_profiles(). PR: https://gitlab.com/apparmor/apparmor/-/merge_requests/536 Acked-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
commit
a7a727b1b0
@ -101,36 +101,10 @@ def act(user_file, base_file, merging_profile):
|
|||||||
#Get rid of common/superfluous stuff
|
#Get rid of common/superfluous stuff
|
||||||
mergeprofiles.clear_common()
|
mergeprofiles.clear_common()
|
||||||
|
|
||||||
# if not args.auto:
|
mergeprofiles.ask_merge_questions()
|
||||||
if 1 == 1: # workaround to avoid lots of whitespace changes
|
|
||||||
mergeprofiles.ask_merge_questions()
|
|
||||||
|
|
||||||
q = aaui.PromptQuestion()
|
|
||||||
q.title = _('Changed Local Profiles')
|
|
||||||
q.explanation = _('The following local profiles were changed. Would you like to save them?')
|
|
||||||
q.functions = ['CMD_SAVE_CHANGES', 'CMD_VIEW_CHANGES', 'CMD_ABORT', 'CMD_IGNORE_ENTRY']
|
|
||||||
q.default = 'CMD_VIEW_CHANGES'
|
|
||||||
q.options = [merging_profile]
|
|
||||||
q.selected = 0
|
|
||||||
|
|
||||||
ans = ''
|
|
||||||
arg = None
|
|
||||||
programs = list(mergeprofiles.user.aa.keys())
|
|
||||||
program = programs[0]
|
|
||||||
while ans != 'CMD_SAVE_CHANGES':
|
|
||||||
ans, arg = q.promptUser()
|
|
||||||
if ans == 'CMD_SAVE_CHANGES':
|
|
||||||
apparmor.aa.write_profile_ui_feedback(program)
|
|
||||||
apparmor.aa.reload_base(program)
|
|
||||||
elif ans == 'CMD_VIEW_CHANGES':
|
|
||||||
for program in programs:
|
|
||||||
apparmor.aa.original_aa[program] = apparmor.aa.deepcopy(apparmor.aa.aa[program])
|
|
||||||
#oldprofile = apparmor.serialize_profile(apparmor.original_aa[program], program, {})
|
|
||||||
newprofile = apparmor.aa.serialize_profile(mergeprofiles.user.aa[program], program, {})
|
|
||||||
aaui.UI_Changes(mergeprofiles.user.filename, newprofile, comments=True)
|
|
||||||
elif ans == 'CMD_IGNORE_ENTRY':
|
|
||||||
break
|
|
||||||
|
|
||||||
|
apparmor.aa.changed[merging_profile] = True # force asking to save the profile
|
||||||
|
apparmor.aa.save_profiles(True)
|
||||||
|
|
||||||
class Merge(object):
|
class Merge(object):
|
||||||
def __init__(self, user, base):
|
def __init__(self, user, base):
|
||||||
|
@ -1501,7 +1501,7 @@ def do_logprof_pass(logmark=''):
|
|||||||
|
|
||||||
save_profiles()
|
save_profiles()
|
||||||
|
|
||||||
def save_profiles():
|
def save_profiles(is_mergeprof=False):
|
||||||
# Ensure the changed profiles are actual active profiles
|
# Ensure the changed profiles are actual active profiles
|
||||||
for prof_name in changed.keys():
|
for prof_name in changed.keys():
|
||||||
if not aa.get(prof_name, False):
|
if not aa.get(prof_name, False):
|
||||||
@ -1516,6 +1516,8 @@ def save_profiles():
|
|||||||
q.title = 'Changed Local Profiles'
|
q.title = 'Changed Local Profiles'
|
||||||
q.explanation = _('The following local profiles were changed. Would you like to save them?')
|
q.explanation = _('The following local profiles were changed. Would you like to save them?')
|
||||||
q.functions = ['CMD_SAVE_CHANGES', 'CMD_SAVE_SELECTED', 'CMD_VIEW_CHANGES', 'CMD_VIEW_CHANGES_CLEAN', 'CMD_ABORT']
|
q.functions = ['CMD_SAVE_CHANGES', 'CMD_SAVE_SELECTED', 'CMD_VIEW_CHANGES', 'CMD_VIEW_CHANGES_CLEAN', 'CMD_ABORT']
|
||||||
|
if is_mergeprof:
|
||||||
|
q.functions = ['CMD_SAVE_CHANGES', 'CMD_VIEW_CHANGES', 'CMD_ABORT', 'CMD_IGNORE_ENTRY']
|
||||||
q.default = 'CMD_VIEW_CHANGES'
|
q.default = 'CMD_VIEW_CHANGES'
|
||||||
q.selected = 0
|
q.selected = 0
|
||||||
ans = ''
|
ans = ''
|
||||||
@ -1555,6 +1557,9 @@ def save_profiles():
|
|||||||
|
|
||||||
aaui.UI_Changes(oldprofile, newprofile)
|
aaui.UI_Changes(oldprofile, newprofile)
|
||||||
|
|
||||||
|
elif ans == 'CMD_IGNORE_ENTRY':
|
||||||
|
changed.pop(options[arg])
|
||||||
|
|
||||||
for profile_name in sorted(changed.keys()):
|
for profile_name in sorted(changed.keys()):
|
||||||
write_profile_ui_feedback(profile_name)
|
write_profile_ui_feedback(profile_name)
|
||||||
reload_base(profile_name)
|
reload_base(profile_name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user