HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib64/python3.6/site-packages/ldap/__pycache__/syncrepl.cpython-36.pyc
3

�`a�H�@s�dZddlmZddlmZmZmZmZmZddl	m
Z
mZddlm
Z
mZmZddlmZmZmZdgZGdd	�d	ej�ZGd
d�dej�ZGdd
�d
ej�ZGdd�dej�ZGdd�de�ZGdd�dej�ZGdd�dej�ZGdd�de�Zeeej <Gdd�dej�Z!Gdd�de�Z"e"ee"j <Gdd�dej�Z#Gdd�dej�Z$Gd d!�d!ej%�Z&Gd"d#�d#ej�Z'Gd$d%�d%ej(�Z)Gd&d'�d'�Z*Gd(d�d�Z+d)S)*zz
ldap.syncrepl - for implementing syncrepl consumer (see RFC 4533)

See https://www.python-ldap.org/ for project details.
�)�UUID)�tag�	namedtype�namedval�univ�
constraint)�encoder�decoder)�__version__�
__author__�__license__)�RequestControl�ResponseControl�KNOWN_RESPONSE_CONTROLS�SyncreplConsumerc@seZdZdZejdd�ZdS)�SyncUUIDz.
    syncUUID ::= OCTET STRING (SIZE(16))
    �N)�__name__�
__module__�__qualname__�__doc__rZValueSizeConstraint�subtypeSpec�rr� /usr/lib64/python3.6/syncrepl.pyrsrc@seZdZdZdS)�
SyncCookiez%
    syncCookie ::= OCTET STRING
    N)rrrrrrrrrsrc@s0eZdZdZejdd�Zejj	e
jdd�Z	dS)	�SyncRequestModez�
           mode ENUMERATED {
               -- 0 unused
               refreshOnly       (1),
               -- 2 reserved
               refreshAndPersist (3)
           },
    �refreshOnly��refreshAndPersist�N)rr)rr)rrrrr�NamedValues�namedValuesr�
Enumeratedrr�SingleValueConstraintrrrrr#s
rc@s@eZdZdZejejde��ejde	��ej
dejd���Z
dS)�SyncRequestValuea:
       syncRequestValue ::= SEQUENCE {
           mode ENUMERATED {
               -- 0 unused
               refreshOnly       (1),
               -- 2 reserved
               refreshAndPersist (3)
           },
           cookie     syncCookie OPTIONAL,
           reloadHint BOOLEAN DEFAULT FALSE
       }
    �mode�cookie�
reloadHintFN)rrrrr�
NamedTypes�	NamedTyper�OptionalNamedTyper�DefaultedNamedTyper�Boolean�
componentTyperrrrr$3s
r$c@s&eZdZdZdZddd�Zd	d
�ZdS)�SyncRequestControlan
    The Sync Request Control is an LDAP Control [RFC4511] where the
    controlType is the object identifier 1.3.6.1.4.1.4203.1.9.1.1 and the
    controlValue, an OCTET STRING, contains a BER-encoded
    syncRequestValue.  The criticality field is either TRUE or FALSE.
    [..]
    The Sync Request Control is only applicable to the SearchRequest
    Message.
    z1.3.6.1.4.1.4203.1.9.1.1rNrFcCs||_||_||_||_dS)N)�criticalityr&r%r')�selfr/r&r%r'rrr�__init__SszSyncRequestControl.__init__cCsXt�}|jdt|j��|jdk	r4|jdt|j��|jrN|jdtj|j��t	j
|�S)Nr%r&r')r$ZsetComponentByNamerr%r&rr'rr,r�encode)r0Zrcvrrr�encodeControlValueYs
z%SyncRequestControl.encodeControlValue)rNrF)rrrr�controlTyper1r3rrrrr.Gs	
r.c@s8eZdZdZejddd
d�Zejj	e
jdddd	�Z	d
S)�SyncStateOpz�
           state ENUMERATED {
               present (0),
               add (1),
               modify (2),
               delete (3)
           },
    �presentr�addr�modify��deleterN)r6r)r7r)r8r9)r:r)rrrrrr r!rr"rrr#rrrrr5csr5c@s<eZdZdZejejde��ejde��ej	de
���ZdS)�SyncStateValuea
       syncStateValue ::= SEQUENCE {
           state ENUMERATED {
               present (0),
               add (1),
               modify (2),
               delete (3)
           },
           entryUUID syncUUID,
           cookie    syncCookie OPTIONAL
       }
    �state�	entryUUIDr&N)rrrrrr(r)r5rr*rr-rrrrr;us
r;c@s eZdZdZdZd
Zdd�Zd	S)�SyncStateControlam
    The Sync State Control is an LDAP Control [RFC4511] where the
    controlType is the object identifier 1.3.6.1.4.1.4203.1.9.1.2 and the
    controlValue, an OCTET STRING, contains a BER-encoded SyncStateValue.
    The criticality is FALSE.
    [..]
    The Sync State Control is only applicable to SearchResultEntry and
    SearchResultReference Messages.
    z1.3.6.1.4.1.4203.1.9.1.2r6r7r8r:cCs�tj|t�d�}|djd�}tt|djd��d�}|djd�}|dk	r`|j�r`t|�|_nd|_|j	j
t|�|_t|�|_
dS)N)�asn1Specrr<r=)�bytesr&)r	�decoder;�getComponentByNamerr@�hasValue�strr&�	__class__�opnames�intr<r=)r0�encodedControlValue�dr<�uuidr&rrr�decodeControlValue�sz#SyncStateControl.decodeControlValueN)r6r7r8r:)rrrrr4rFrKrrrrr>�s	r>c@s4eZdZdZejejde��ejde	j
d���ZdS)�
SyncDoneValuez�
       syncDoneValue ::= SEQUENCE {
           cookie          syncCookie OPTIONAL,
           refreshDeletes  BOOLEAN DEFAULT FALSE
       }
    r&�refreshDeletesFN)rrrrrr(r*rr+rr,r-rrrrrL�srLc@seZdZdZdZdd�ZdS)�SyncDoneControlaT
    The Sync Done Control is an LDAP Control [RFC4511] where the
    controlType is the object identifier 1.3.6.1.4.1.4203.1.9.1.3 and the
    controlValue contains a BER-encoded syncDoneValue.  The criticality
    is FALSE (and hence absent).
    [..]
    The Sync Done Control is only applicable to the SearchResultDone
    Message.
    z1.3.6.1.4.1.4203.1.9.1.3cCsdtj|t�d�}|djd�}|j�r2t|�|_nd|_|djd�}|j�rZt|�|_nd|_dS)N)r?rr&rM)	r	rArLrBrCrDr&�boolrM)r0rHrIr&Zrefresh_deletesrrrrK�sz"SyncDoneControl.decodeControlValueN)rrrrr4rKrrrrrN�s	rNc@s4eZdZdZejejde��ejde	j
d���ZdS)�
RefreshDeletez�
           refreshDelete  [1] SEQUENCE {
               cookie         syncCookie OPTIONAL,
               refreshDone    BOOLEAN DEFAULT TRUE
           },
    r&�refreshDoneTN)rrrrrr(r*rr+rr,r-rrrrrP�srPc@s4eZdZdZejejde��ejde	j
d���ZdS)�RefreshPresentz�
           refreshPresent [2] SEQUENCE {
               cookie         syncCookie OPTIONAL,
               refreshDone    BOOLEAN DEFAULT TRUE
           },
    r&rQTN)rrrrrr(r*rr+rr,r-rrrrrR�srRc@seZdZdZe�ZdS)�	SyncUUIDsz(
    syncUUIDs      SET OF syncUUID
    N)rrrrrr-rrrrrS�srSc@s@eZdZdZejejde��ejde	j
d��ejde���Z
dS)�	SyncIdSetz�
     syncIdSet      [3] SEQUENCE {
         cookie         syncCookie OPTIONAL,
         refreshDeletes BOOLEAN DEFAULT FALSE,
         syncUUIDs      SET OF syncUUID
     }
    r&rMF�	syncUUIDsN)rrrrrr(r*rr+rr,r)rSr-rrrrrT�s
rTc@s�eZdZdZejejde�je	j
e	je	jd�d��ejde
�je	j
e	je	jd�d��ejde�je	j
e	je	jd�d��ejd	e�je	j
e	je	jd
�d���ZdS)�
SyncInfoValuea`
       syncInfoValue ::= CHOICE {
           newcookie      [0] syncCookie,
           refreshDelete  [1] SEQUENCE {
               cookie         syncCookie OPTIONAL,
               refreshDone    BOOLEAN DEFAULT TRUE
           },
           refreshPresent [2] SEQUENCE {
               cookie         syncCookie OPTIONAL,
               refreshDone    BOOLEAN DEFAULT TRUE
           },
           syncIdSet      [3] SEQUENCE {
               cookie         syncCookie OPTIONAL,
               refreshDeletes BOOLEAN DEFAULT FALSE,
               syncUUIDs      SET OF syncUUID
           }
       }
    �	newcookier)ZimplicitTag�
refreshDeleter�refreshPresentr9�	syncIdSetrN)rrrrrr(r)r�subtyperZTagZtagClassContextZtagFormatSimplerPrRrTr-rrrrrV�s$rVc@seZdZdZdZdd�ZdS)�SyncInfoMessagea	
    The Sync Info Message is an LDAP Intermediate Response Message
    [RFC4511] where responseName is the object identifier
    1.3.6.1.4.1.4203.1.9.1.4 and responseValue contains a BER-encoded
    syncInfoValue.  The criticality is FALSE (and hence absent).
    z1.3.6.1.4.1.4203.1.9.1.4cCs"tj|t�d�}d|_d|_d|_d|_|dj�}|dj�}|dk	oN|j	��r|dkrht
|�|_dSi}|jd�}|j	�r�t
|�|d<|jd�r�t
|jd��|d<nj|dk�rg}|jd�}x6tt|��D]&}	tt|j|	��d	�}
|jt
|
��q�W||d<t
|jd
��|d
<t|||�dS)N)r?rrWr&ZrefreshrQrZrU)r@rM)r	rArVrWrXrYrZZgetNameZgetComponentrCrDrB�
startswithrO�range�lenrr@ZgetComponentByPosition�append�setattr)r0ZencodedMessagerI�attr�comp�valr&�uuidsZids�irJrrrr16s4




zSyncInfoMessage.__init__N)rrrr�responseNamer1rrrrr\-sr\c@sVeZdZdZddd�Zddd	�Zd
d�Zdd
�Zddd�Zdd�Z	dd�Z
dd�ZdS)rz;
    SyncreplConsumer - LDAP syncrepl consumer object.
    rNcKsX|dkr|j�}t||d�}d|kr8|d|g7<n
|g|d<d|_|j||f|�S)a�
        Starts syncrepl search operation.

        base, scope, and search_args are passed along to
        self.search_ext unmodified (aside from adding a Sync
        Request control to any serverctrls provided).

        mode provides syncrepl mode. Can be 'refreshOnly'
        to finish after synchronization, or
        'refreshAndPersist' to persist (continue to
        receive updates) after synchronization.

        cookie: an opaque value representing the replication
        state of the client.  Subclasses should override
        the syncrepl_set_cookie() and syncrepl_get_cookie()
        methods to store the cookie appropriately, rather than
        passing it.

        Only a single syncrepl search may be active on a SyncreplConsumer
        object.  Multiple concurrent syncrepl searches require multiple
        separate SyncreplConsumer objects and thus multiple connections
        (LDAPObject instances).
        N)r&r%ZserverctrlsF)�syncrepl_get_cookier.�_SyncreplConsumer__refreshDoneZ
search_ext)r0�baseZscoper%r&Zsearch_argsZsyncreqrrr�syncrepl_searchas
z SyncreplConsumer.syncrepl_searchrrcCs��x�|j||dddd�\}}}}}}	|dkrrx@|D]8}
|
jjdkrDq2|jd|
jd�|
jdk	r2|j|
j�q2WdS|d	k�r,x�|D]�}|\}}
}x�|D]�}
|
jjd
kr�q�|
jdkr�|j|
jg�nD|
jdkr�|j	|
jg�n*|j
||
|
j�|jdk�r|j|
jg�|
jdk	�r|j|
j�Pq�Wq�W�nX|d
k�r��xJ|D�]@}|\}}}|tj
k�r^�q>t|�}|jdk	�r�|j|j�n�|jdk	�r�|jddd�d|jk�r�|j|jd�|jd�r~d|_|j�n�|jdk	�r$|jddd�d|jk�r|j|jd�|jd�r~d|_|j�nZ|jdk	�r>|jddk�rR|j	|jd�n|j|jd�d|jk�r>|j|jd��q>W|dkrdSqWdS)a�
        polls for and processes responses to the syncrepl_search() operation.
        Returns False when operation finishes, True if it is in progress, or
        raises an exception on error.

        If timeout is specified, raises ldap.TIMEOUT in the event of a timeout.

        If all is set to a nonzero value, poll() will return only when finished
        or when an exception is raised.

        rr)�msgid�timeoutZadd_intermediatesZ	add_ctrls�all�erNN)rMF�dr>r6r:�yr&rQTrMrU)Zresult4rEr�syncrepl_presentrMr&�syncrepl_set_cookier<r=�syncrepl_delete�syncrepl_entryrir\rgrWrY�syncrepl_refreshdonerXrZ)r0rlrmrn�type�msgZmidZctrls�n�v�c�m�dn�attrsZrnameZrespZsimrrr�
syncrepl_poll�sz











zSyncreplConsumer.syncrepl_pollcCsdS)zY
        Called by syncrepl_poll() to store a new cookie provided by the server.
        Nr)r0r&rrrrs�sz$SyncreplConsumer.syncrepl_set_cookiecCsdS)zd
        Called by syncrepl_search() to retrieve the cookie stored by syncrepl_set_cookie()
        Nr)r0rrrrh�sz$SyncreplConsumer.syncrepl_get_cookieFcCsdS)aF
        Called by syncrepl_poll() whenever entry UUIDs are presented to the client.
        syncrepl_present() is given a list of entry UUIDs (uuids) and a flag
        (refreshDeletes) which indicates whether the server explicitly deleted
        non-present entries during the refresh operation.

        If called with a list of uuids, the syncrepl_present() implementation
        should record those uuids as present in the directory.

        If called with uuids set to None and refreshDeletes set to False,
        syncrepl_present() should delete all non-present entries from the local
        mirror, and reset the list of recorded uuids.

        If called with uuids set to None and refreshDeletes set to True,
        syncrepl_present() should reset the list of recorded uuids, without
        deleting any entries.
        Nr)r0rerMrrrrr�sz!SyncreplConsumer.syncrepl_presentcCsdS)z�
        Called by syncrepl_poll() to delete entries. A list
        of UUIDs of the entries to be deleted is given in the
        uuids parameter.
        Nr)r0rerrrrtsz SyncreplConsumer.syncrepl_deletecCsdS)z�
        Called by syncrepl_poll() for any added or modified entries.

        The provided uuid is used to identify the provided entry in
        any future modification (including dn modification), deletion,
        and presentation operations.
        Nr)r0r}r~rJrrrruszSyncreplConsumer.syncrepl_entrycCsdS)z�
        Called by syncrepl_poll() between refresh and persist phase.

        It indicates that initial synchronization is done and persist phase
        follows.
        Nr)r0rrrrvsz%SyncreplConsumer.syncrepl_refreshdone)rN���)r�Nr)F)rrrrrkrrsrhrrrtrurvrrrrr\s
%
Z

N),rrJrZpyasn1.typerrrrrZpyasn1.codec.berrr	Zldap.pkginfor
rrZ
ldap.controlsr
rr�__all__ZOctetStringrrr"r�Sequencer$r.r5r;r>r4rLrNrPrRZSetOfrSrTZChoicerVr\rrrrr�<module>s2




//