Revonzy Mini Shell

Revonzy Mini Shell

Şuanki Dizin: /lib64/python3.9/site-packages/setools/__pycache__/
Dosya Yükle :
Şuanki Dosya : //lib64/python3.9/site-packages/setools/__pycache__/descriptors.cpython-39.pyc

a

q�qe�&�@s�dZddlZddlmZmZddlmZddlmZddl	m
Z
ddlmZm
Z
mZmZmZmZddlmZd	d
lmZGdd�d�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�d�ZdS)z�
SETools descriptors.

These classes override how a class's attributes are get/set/deleted.
This is how the @property decorator works.

See https://docs.python.org/3/howto/descriptor.html
for more details.
�N)�ABC�abstractmethod)�defaultdict)�
Collection)�Enum)�Any�Callable�MutableMapping�Optional�Type�Union)�WeakKeyDictionary�)�validate_perms_anyc@sXeZdZdZdeeeeeefeee	dd�dd�Z
dd�Zd
dd	�Zd
d�Z
dS)�CriteriaDescriptora�
    Single item criteria descriptor.

    Keyword Parameters:
    name_regex      The name of instance's regex setting attribute;
                    used as name_regex below.  If unset,
                    regular expressions will never be used.
    lookup_function The name of the SELinuxPolicy lookup function,
                    e.g. lookup_type or lookup_boolean.
    default_value   The default value of the criteria.  The default
                    is None.
    enum_class      The class of enumeration which supports a
                    lookup class method.

    Read-only instance attribute use (obj parameter):
    policy          The instance of SELinuxPolicy
    name_regex      This attribute is read to determine if
                    the criteria should be looked up or
                    compiled into a regex.  If the attribute
                    does not exist, False is assumed.
    N)�
name_regex�lookup_function�
enum_class�returncCsN|s|s|sJd��|r$|r$Jd��||_||_||_||_d|_t�|_dS)NzQA simple attribute should be used if there is no regex, lookup function, or enum.z9Lookup functions and enum classes are mutually exclusive.�)�regex�
default_valuerr�namer
�	instances)�selfrrrr�r�9/usr/lib64/python3.9/site-packages/setools/descriptors.py�__init__:s�
�zCriteriaDescriptor.__init__cCs
||_dS�N�r)r�ownerrrrr�__set_name__MszCriteriaDescriptor.__set_name__cCs|dur|S|j�||j�Sr)r�
setdefaultr�r�objZobjtyperrr�__get__PszCriteriaDescriptor.__get__cCs�|s|j|j|<n�|jr8t||jd�r8t�|�|j|<nZ|jrnt|j�rP|j}nt|j|j�}||�|j|<n$|j	r�|j	�
|�|j|<n
||j|<dS)NF)rrr�getattr�re�compiler�callable�policyr�lookup)rr$�valuer+rrr�__set__Vs
zCriteriaDescriptor.__set__)NNNN)N)�__name__�
__module__�__qualname__�__doc__r
�strrrrrrr!r%r-rrrrr"s��
rc@seZdZdZdd�ZdS)�CriteriaSetDescriptorz!Descriptor for a set of criteria.cs�|s�j�j|<n��jr8t|�jd�r8t�|��j|<nv�jr|t�j�rP�j�nt|j�j��t	�fdd�|D���j|<n2�j
r�t	�fdd�|D���j|<nt	|��j|<dS)NFc3s|]}�|�VqdSrr��.0�v)r+rr�	<genexpr>u�z0CriteriaSetDescriptor.__set__.<locals>.<genexpr>c3s|]}�j�|�VqdSr)rr+r4)rrrr7wr8)rrrr&r'r(rr)r*�	frozensetr�rr$r,r)r+rrr-ks
zCriteriaSetDescriptor.__set__N)r.r/r0r1r-rrrrr3gsr3c@s.eZdZdZdeedd�dd�Zdd�ZdS)	�CriteriaPermissionSetDescriptora�
    Descriptor for a set of permissions criteria.

    name_regex      The name of instance's regex setting attribute;
                    used as name_regex below.  If unset,
                    regular expressions will never be used.
    default_value   The default value of the criteria.  The default
                    is None.

    Read-only instance attribute use (obj parameter):
    policy          The instance of SELinuxPolicy
    tclass          If it exists, it will be used to validate the
                    permissions.  See validate_perms_any()
    tclass_regex    If tclass is a regex, the above permission validation
                    will not use tclass: permissions are verified to be in
                    at least one class in the policy but not verified that the
                    permissions are in classes that the regex matches.  Assumes False
                    if the attribute doesn't exist.
    N)rrcCs||_||_d|_t�|_dS)Nr)rrrr
r)rrrrrrr�sz(CriteriaPermissionSetDescriptor.__init__cCs�|s|j|j|<n�|jr8t||jd�r8t�|�|j|<nbtdd�|D��}t|dd�r\d}nt|dd�}|r�t|t�s�t|f�}t	|||j
d�||j|<dS)NFcss|]
}|VqdSrrr4rrrr7�r8z:CriteriaPermissionSetDescriptor.__set__.<locals>.<genexpr>Ztclass_regex�tclass)r<r*)rrrr&r'r(r9�
isinstancerrr*)rr$r,Zpermsr<rrrr-�s
�z'CriteriaPermissionSetDescriptor.__set__)NN)r.r/r0r1r
r2rr-rrrrr;|s
r;c@sBeZdZdZedd�dd�Zddd�Zedd	��Zed
d��Z	dS)
�NetworkXGraphEdgeDescriptora'
    Descriptor abstract base class for NetworkX graph edge attributes.

    Parameter:
    name        The edge property name

    Instance class attribute use (obj parameter):
    G           The NetworkX graph
    source      The edge's source node
    target      The edge's target node
    N)�propnamercCs
||_dSrr)rr?rrrr�sz$NetworkXGraphEdgeDescriptor.__init__cCsH|dur|Sz|j|j|j|jWStyBt|j��Yn0dSr)�G�source�targetr�KeyError�AttributeErrorr#rrrr%�sz#NetworkXGraphEdgeDescriptor.__get__cCsdSrrr:rrrr-�sz#NetworkXGraphEdgeDescriptor.__set__cCsdSrr�rr$rrr�
__delete__�sz&NetworkXGraphEdgeDescriptor.__delete__)N)
r.r/r0r1r2rr%rr-rFrrrrr>�s
	
r>c@s eZdZdZdd�Zdd�ZdS)�EdgeAttrDictz7A descriptor for edge attributes that are dictionaries.cCs:|dur&tt�|j|j|j|j<ntd�|j���dS)Nz0{0} dictionaries should not be assigned directly)r�listr@rArBrrD�formatr:rrrr-�s
�zEdgeAttrDict.__set__cCs |j|j|j|j��dSr�r@rArBr�clearrErrrrF�szEdgeAttrDict.__delete__N�r.r/r0r1r-rFrrrrrG�srGc@s eZdZdZdd�Zdd�ZdS)�EdgeAttrIntMaxz�
    A descriptor for edge attributes that are non-negative integers that always
    keep the max assigned value until re-initialized.
    cCs\|dur"d|j|j|j|j<n6|j|j|j|j}t||�|j|j|j|j<dS�Nr)r@rArBr�max)rr$r,Z
current_valuerrrr-�szEdgeAttrIntMax.__set__cCsd|j|j|j|j<dSrN)r@rArBrrErrrrF�szEdgeAttrIntMax.__delete__NrLrrrrrM�srMc@s eZdZdZdd�Zdd�ZdS)�EdgeAttrListz0A descriptor for edge attributes that are lists.cCs6|dur"g|j|j|j|j<ntd�|j���dS)Nz){0} lists should not be assigned directly)r@rArBr�
ValueErrorrIr:rrrr-szEdgeAttrList.__set__cCs |j|j|j|j��dSrrJrErrrrFszEdgeAttrList.__delete__NrLrrrrrPsrPc@s:eZdZdZeed�dd�Zddd�Zdd	�Zd
d�Z	dS)
�PermissionMapDescriptoraN
    Descriptor for Permission Map mappings.

    Parameter:
    name        The map setting name.
    validator   A callable for validating the setting.

    Instance class attribute use (obj parameter):
    _perm_map   The full permission map.
    class_      The mapping's object class
    perm        The mapping's permission
    )r?�	validatorcCs||_||_dSr)rrS)rr?rSrrrr"sz PermissionMapDescriptor.__init__NcCs$|dur|S|j|j|j|jSr)�	_perm_map�class_�permrr#rrrr%&szPermissionMapDescriptor.__get__cCs"|�|�|j|j|j|j<dSr)rSrTrUrVrr:rrrr-,szPermissionMapDescriptor.__set__cCst�dSr)rDrErrrrF/sz"PermissionMapDescriptor.__delete__)N)
r.r/r0r1r2rrr%r-rFrrrrrRs


rR)r1r'�abcrr�collectionsr�collections.abcr�enumr�typingrrr	r
rr�weakrefr
�utilrrr3r;r>rGrMrPrRrrrr�<module>s 
 
E?#

EliteHackz.ORG
Revonzy Mini Shell
root@revonzy.com

Linux 65-254-81-4.cprapid.com 5.14.0-284.11.1.el9_2.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 9 05:49:00 EDT 2023 x86_64
Apache
65.254.81.4