[apparmor] [patch] [02/38] check_and_split_list: optionally allow empty list

Kshitij Gupta kgupta8592 at gmail.com
Sun Sep 11 20:36:23 UTC 2016


On Sat, Aug 13, 2016 at 2:14 AM, Christian Boltz <apparmor at cboltz.de> wrote:
> Hello,
>
> $subject.
>
> File permissions can be an empty list (if only exec permissions are
> specified). This patch adds the optional allow_empty_list parameter so
> that the function can handle this case.
>
>
>
> [ 02-check_and_split_list-optionally-allow-empty-list.diff ]
>
> --- utils/apparmor/rule/__init__.py     2016-01-07 20:41:32.718787664 +0100
> +++ utils/apparmor/rule/__init__.py     2016-01-15 23:00:18.765000352 +0100
> @@ -431,14 +431,14 @@
>          raise NotImplementedError("get_glob_ext is not available for this rule type!")
>
>
> -def check_and_split_list(lst, allowed_keywords, all_obj, classname, keyword_name):
> +def check_and_split_list(lst, allowed_keywords, all_obj, classname, keyword_name, allow_empty_list=False):
>      '''check if lst is all_obj or contains only items listed in allowed_keywords'''
>
>      if lst == all_obj:
>          return None, True, None
>      elif type_is_str(lst):
>          result_list = {lst}
> -    elif (type(lst) == list or type(lst) == tuple) and len(lst) > 0:
> +    elif (type(lst) == list or type(lst) == tuple) and (len(lst) > 0 or allow_empty_list):
this is a bit funny, result list is actually a set and param list can
actually be list or tuple ;-)
(Yeah the usage in param and result means simple list not the keyword
but still.)

>          result_list = set(lst)
>      else:
>          raise AppArmorBug('Passed unknown %(type)s object to %(classname)s: %(unknown_object)s' %
>
>
Acked-by: Kshitij Gupta <kgupta8592 at gmail.com>

>
> Regards,
>
> Christian Boltz
> --
> Eine Sig ist genauso überflüssig wie beim Einkaufen die Hose. In
> irgendeinem abstrakten Sinne käme man natürlich ohne aus, wenn man
> sein Portemonnaie in die Jeansjacke steckt. Aber es wäre mächtig
> kühl, und man hätte das unangenehme Gefühl, daß untenrum irgendwas
> Wichtiges fehlt. [Peter `g' Bouillon in dafu]
>
> --
> AppArmor mailing list
> AppArmor at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
>



-- 
Regards,

Kshitij Gupta



More information about the AppArmor mailing list