mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
[3/7] Copy code to ask for adding includes to aa.py ask_the_questions()
This is an exact copy of the code in aa-mergeprof (with whitespace changed). Acked-by: Seth Arnold <seth.arnold@canonical.com>
This commit is contained in:
parent
ca093f7223
commit
cfa0a37e58
1 changed files with 34 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
# ----------------------------------------------------------------------
|
||||
# Copyright (C) 2013 Kshitij Gupta <kgupta8592@gmail.com>
|
||||
# Copyright (C) 2014-2016 Christian Boltz <apparmor@cboltz.de>
|
||||
# Copyright (C) 2014-2017 Christian Boltz <apparmor@cboltz.de>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of version 2 of the GNU General Public
|
||||
|
@ -1520,6 +1520,39 @@ def ask_the_questions():
|
|||
debug_logger.debug("Ignoring events for non-existing profile %s" % combine_name(profile, hat))
|
||||
continue
|
||||
|
||||
#Add the includes from the other profile to the user profile
|
||||
done = False
|
||||
|
||||
options = []
|
||||
for inc in log_dict[aamode][profile][hat]['include'].keys():
|
||||
if not inc in aa[profile][hat]['include'].keys():
|
||||
options.append('#include <%s>' %inc)
|
||||
|
||||
default_option = 1
|
||||
|
||||
q = aaui.PromptQuestion()
|
||||
q.options = options
|
||||
q.selected = default_option - 1
|
||||
q.headers = [_('File includes'), _('Select the ones you wish to add')]
|
||||
q.functions = ['CMD_ALLOW', 'CMD_IGNORE_ENTRY', 'CMD_ABORT', 'CMD_FINISHED']
|
||||
q.default = 'CMD_ALLOW'
|
||||
|
||||
while not done and options:
|
||||
ans, selected = q.promptUser()
|
||||
if ans == 'CMD_IGNORE_ENTRY':
|
||||
done = True
|
||||
elif ans == 'CMD_ALLOW':
|
||||
selection = options[selected]
|
||||
inc = re_match_include(selection)
|
||||
deleted = apparmor.aa.delete_duplicates(aa[profile][hat], inc)
|
||||
aa[profile][hat]['include'][inc] = True
|
||||
options.pop(selected)
|
||||
aaui.UI_Info(_('Adding %s to the file.') % selection)
|
||||
if deleted:
|
||||
aaui.UI_Info(_('Deleted %s previous matching profile entries.') % deleted)
|
||||
elif ans == 'CMD_FINISHED':
|
||||
return
|
||||
|
||||
for ruletype in ruletypes:
|
||||
for rule_obj in log_dict[aamode][profile][hat][ruletype].rules:
|
||||
# XXX aa-mergeprof also has this code - if you change it, keep aa-mergeprof in sync!
|
||||
|
|
Loading…
Add table
Reference in a new issue