MINI MINI MANI MO
ó
o‘P\c           @   s   d  Z  d d l m Z d d l m Z d d l m Z d „  Z d e j f d „  ƒ  YZ d	 „  Z	 d
 d d „  ƒ  YZ
 d „  Z d
 „  Z d d d „  ƒ  YZ
 d S(   sV  
Classes representing basic access.
SELinux - at the most basic level - represents access as
the 4-tuple subject (type or context), target (type or context),
object class, permission. The policy language elaborates this basic
access to faciliate more concise rules (e.g., allow rules can have multiple
source or target types - see refpolicy for more information).
This module has objects for representing the most basic access (AccessVector)
and sets of that access (AccessVectorSet). These objects are used in Madison
in a variety of ways, but they are the fundamental representation of access.
i   (   t	   refpolicy(   t   utiliÿÿÿÿ(   t	   audit2whyc         C   sU   t  |  ƒ d k rM |  d d k rM y t |  d ƒ Wn t k
 rH t SXt St Sd S(   s¬   Determine if an id is a paramater in the form $N, where N is
    an integer.
    Returns:
      True if the id is a paramater
      False if the id is not a paramater
    i   i    t   $N(   t   lent   intt
   ValueErrort   Falset   True(   t   id(    (    s5   /usr/lib64/python2.7/site-packages/sepolgen/access.pyt
   is_idparam'   s    "
t   AccessVectorc           B   sY   e  Z d  Z d	 d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z RS(
   sº  
    An access vector is the basic unit of access in SELinux.
    Access vectors are the most basic representation of access within
    SELinux. It represents the access a source type has to a target
    type in terms of an object class and a set of permissions.
    Access vectors are distinct from AVRules in that they can only
    store a single source type, target type, and object class. The
    simplicity of AccessVectors makes them useful for storing access
    in a form that is easy to search and compare.
    The source, target, and object are stored as string. No checking
    done to verify that the strings are valid SELinux identifiers.
    Identifiers in the form $N (where N is an integer) are reserved as
    interface parameters and are treated as wild cards in many
    circumstances.
    Properties:
     .src_type - The source type allowed access. [String or None]
     .tgt_type - The target type to which access is allowed. [String or None]
     .obj_class - The object class to which access is allowed. [String or None]
     .perms - The permissions allowed to the object class. [IdSet]
     .audit_msgs - The audit messages that generated this access vector [List of strings]
    c         C   s†   | r |  j  | ƒ nZ d  |  _ d  |  _ d  |  _ t j ƒ  |  _ g  |  _ t	 j
 |  _ g  |  _ d  |  _
 d  |  _ d  |  _ d  |  _ d  S(   N(   t	   from_listt   Nonet   src_typet   tgt_typet	   obj_classR    t   IdSett   permst
   audit_msgsR   t   TERULEt   typet   datat   obj_patht	   base_typet   __hash__t
   info_flow_dir(   t   selft	   init_list(    (    s5   /usr/lib64/python2.7/site-packages/sepolgen/access.pyt   __init__R   s    								c         C   sl   t  | ƒ d k  r+ t d t | ƒ ƒ ‚ n  | d |  _ | d |  _ | d |  _ t j | d ƒ |  _ d S(   sx  Initialize an access vector from a list.
        Initialize an access vector from a list treating the list as
        positional arguments - i.e., 0 = src_type, 1 = tgt_type, etc.
        All of the list elements 3 and greater are treated as perms.
        For example, the list ['foo_t', 'bar_t', 'file', 'read', 'write']
        would create an access vector list with the source type 'foo_t',
        target type 'bar_t', object class 'file', and permissions 'read'
        and 'write'.
        This format is useful for very simple storage to strings or disc
        (see to_list) and for initializing access vectors.
        i   s+   List must contain at least four elements %si    i   i   i   N(	   R   R   t   strR   R   R   R    R   R   (   R   t   list(    (    s5   /usr/lib64/python2.7/site-packages/sepolgen/access.pyR   g   s    
c         C   s2   |  j  |  j |  j g } | j t |  j ƒ ƒ | S(   sî   
        Convert an access vector to a list.
        Convert an access vector to a list treating the list as positional
        values. See from_list for more information on how an access vector
        is represented in a list.
        (   R   R   R   t   extendt   sortedR   (   R   t   l(    (    s5   /usr/lib64/python2.7/site-packages/sepolgen/access.pyt   to_list|   s    c         C   s
   |  j  ƒ  S(   N(   t	   to_string(   R   (    (    s5   /usr/lib64/python2.7/site-packages/sepolgen/access.pyt   __str__ˆ   s    c         C   s&