[apparmor] [patch] [3/7] Copy code to ask for adding includes to aa.py ask_the_questions()

Seth Arnold seth.arnold at canonical.com
Tue Jan 17 20:48:48 UTC 2017


On Sun, Jan 15, 2017 at 04:24:09PM +0100, Christian Boltz wrote:
> Hello,
> 
> $subject.
> 
> This is an exact copy of the code in aa-mergeprof (with whitespace changed).
> 
> 
> 
> [ 03-aa.py-ask-for-includes.diff ]

Acked-by: Seth Arnold <seth.arnold at canonical.com>

Thanks

> 
> --- utils/apparmor/aa.py	2017-01-11 22:59:32.112384000 +0100
> +++ utils/apparmor/aa.py	2017-01-14 22:56:12.081131108 +0100
> @@ -1,6 +1,6 @@
>  # ----------------------------------------------------------------------
>  #    Copyright (C) 2013 Kshitij Gupta <kgupta8592 at gmail.com>
> -#    Copyright (C) 2014-2016 Christian Boltz <apparmor at cboltz.de>
> +#    Copyright (C) 2014-2017 Christian Boltz <apparmor at 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 @@
>                      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!
> 
> 
> 
> 
> 
> Regards,
> 
> Christian Boltz
> -- 
> [Fontlinge für Linux 0.0.2] Warte nur ab, die 0.0.3 funktioniert sogar,
> wenn man nicht "ratti" heisst. ;-)                              [Ratti]



> -- 
> AppArmor mailing list
> AppArmor at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20170117/3d49523e/attachment-0001.pgp>


More information about the AppArmor mailing list