%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/samba/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/samba/__pycache__/sd_utils.cpython-312.pyc

�

�I�dw ��v�dZddlZddlmZmZmZddlmZmZddlm	Z	m
Z
mZddlm
Z
ddlmZGd�d	e�Zy)
z5Utility methods for security descriptor manipulation.�N)�Message�MessageElement�Dn)�FLAG_MOD_REPLACE�
SCOPE_BASE)�ndr_pack�
ndr_unpack�ndr_deepcopy)�security)�NT_STATUS_OBJECT_NAME_NOT_FOUNDc�^�eZdZdZd�Zd
d�Zd
d�Zd�Z		dd�Zd
d�Z	d	�Z
d
d
�Zd
d�Zd
d�Z
y)�SDUtilszCSome utilities for manipulation of security descriptors on objects.c�v�||_tj|jj��|_y�N)�ldbr�dom_sid�get_domain_sid�
domain_sid)�self�samdbs  �0/usr/lib/python3/dist-packages/samba/sd_utils.py�__init__zSDUtils.__init__"s(�����"�*�*�4�8�8�+B�+B�+D�E���Nc��t�}t|t�r||_nt|j|�|_t|t
�st|tj�sJ�t|t
�r+tjj||j�}nt|tj�r|}tt�td�|d<|jj||�y)zfModify security descriptor using either SDDL string
            or security.descriptor object
        �nTSecurityDescriptorN)r�
isinstancer�dnr�strr�
descriptor�	from_sddlrrrr�modify)r�	object_dn�sd�controls�m�tmp_descs      r�modify_sd_on_dnzSDUtils.modify_sd_on_dn&s���
�I���i��$��A�D��d�h�h�	�*�A�D��"�c�"�j��X�5H�5H�&I�J�I��b�#���*�*�4�4�R����I�H�
��H�/�/�
0��H�$2�8�H�3E�3C�3I�%K��
 �!�	
������8�$rc��|jj|tddg|��}|ddd}ttj
|�S)Nr�r$r)r�searchrr	rr)rr"r$�res�descs     r�
read_sd_on_dnzSDUtils.read_sd_on_dn;sO���h�h�o�o�i��T�5�6���K���1�v�,�-�a�0���(�-�-�t�4�4rc�~�|jj|�}ttj|ddd�S)Nr�	objectSid)rr*r	rr)rr"r+s   r�get_object_sidzSDUtils.get_object_sidAs5���h�h�o�o�i�(���(�*�*�C��F�;�,?��,B�C�Crc���|�g}|�g}�fd�}|��|�dtjzg}�j||��}|jtjzs�t|j�}|jD]2}	|	jtjzs�!	|j|	��4ng|�g}�jj!|t"d|g|��}t%|d|d�}tj&j)|�j*�}d}
g}g}g}|D]�}	t-|	t$�r||	�}	t-|	tj.�sJ�|	jtjzr|j1|	��f|	|jjvr|j1|	���|j|	�|
dz
}
��|D]�}	d}t-|	t2�rd|	vr|	d}|	d}	t-|	t$�r||	�}	t-|	tj.�sJ�|	jtjzr|j1|	���|	|jjvr|j1|	���|j5|	|�|
dz
}
��|
dk(r|||fS|��j7|||��nl|j9�j*�}t;�}||_t?|jAd	�tB|�||<�jjE||��|||fS#tj$r#}
|
jdtk7r|
�Yd}
~
���d}
~
wwxYw)
Nc����tjjd|z�j�}t	|j
j�dk(sJ�|j
jdS)N�D:�r)rrr r�len�dacl�aces)�ace_sddl�ace_sdrs  �r�
ace_from_sddlz2SDUtils.update_aces_in_dacl.<locals>.ace_from_sddlLsU����(�(�2�2�4�(�?�D�O�O�T�F��v�{�{�'�'�(�!�+�,�+��;�;�#�#�A�&�&rz
sd_flags:1:%dr)rr4����idx�ace�ascii)#r�SECINFO_DACLr-�type�SEC_DESC_DACL_PROTECTEDr
r6r7�flags�SEC_ACE_FLAG_INHERITED_ACE�dacl_del_ace�samba�
NTSTATUSError�argsrrr*rrrr rrr=�append�dict�dacl_addr'�as_sddlrrr�encoderr!)rr�del_aces�add_aces�	sddl_attrr$r:r#�	dacl_copyr=�errr+�old_sddl�num_changes�del_ignored�add_ignored�inherited_ignored�add_idx�new_sddlr%s`                   r�update_aces_in_daclzSDUtils.update_aces_in_daclEs?������H����H�	'�
����)�H�,A�,A�A�B���#�#�B��#�:�B��7�7�X�=�=�=�)����1�	�$�>�>�	!�C��y�y�8�#F�#F�F�!��O�O�C�0�	!������(�(�/�/�"�j�$�#,�+��"�B�C��3�q�6�)�,�Q�/�0�H��$�$�.�.�x����I�B����������	�C��#�s�#�#�C�(���c�8�<�<�0�1�0��y�y�8�>�>�>�!�(�(��-���"�'�'�,�,�&��"�"�3�'���O�O�C� ��1��K�	� �	�C��G��#�t�$��C�<�!�%�j�G��%�j���#�s�#�#�C�(���c�8�<�<�0�1�0��y�y�8�>�>�>�!�(�(��-���b�g�g�l�l�"��"�"�3�'���K�K��W�%��1��K�'	�*�!����->�>�>���� � ��R�(� �;��z�z�$�/�/�2�H��	�A��A�D�)�(�/�/�'�*B�*:�*3�5�A�i�L�
�H�H�O�O�A��O�1��K�):�:�:��M %�2�2�!�"�x�x��{�.M�M�&)�	�!��!�s�L$�$M�7M�Mc��tjjd|z|j�}g}d}|jj
D]}|j
||d��|dz
}�|j|||��\}}	}
|	|
fS)zCPrepend an ACE (or more) to an objects security descriptor
        r3r)r<r=r4�rNr$�rrr rr6r7rHrY)rr"r7r$r9rNrWr=�_�ai�iis           r�dacl_prepend_aceszSDUtils.dacl_prepend_aces�s����$�$�.�.�t�d�{�D�O�O�L�������;�;�#�#�	�C��O�O�G�C�8�9��q�L�G�	��*�*�9�x�4<�+�>���"�R��2�v�
rc�4�|j||dg��\}}y)z?Add an ACE (or more) to an objects security descriptor
        �show_deleted:1r)N)r`)rr"r=r]s    r�dacl_add_acezSDUtils.dacl_add_ace�s(���$�$�Y��/?�.@�%�B���!rc���tjjd|z|j�}g}|jj
D]}|j
|��|j|||��\}}}	||	fS)zBAppend an ACE (or more) to an objects security descriptor
        r3r[r\)
rr"r7r$r9rNr=r]r^r_s
          r�dacl_append_aceszSDUtils.dacl_append_aces�sy���$�$�.�.�t�d�{�D�O�O�L�����;�;�#�#�	!�C��O�O�C� �	!��*�*�9�x�4<�+�>���"�R��2�v�
rc���tjjd|z|j�}g}|jj
D]}|j
|��|j|||��\}}}	||	fS)zBDelete an ACE (or more) to an objects security descriptor
        r3)rMr$r\)
rr"r7r$�del_sdrMr=�dir]r_s
          r�dacl_delete_aceszSDUtils.dacl_delete_aces�sy���$�$�.�.�t�d�{�D�O�O�L�����;�;�#�#�	!�C��O�O�C� �	!��*�*�9�x�4<�+�>���1�R��2�v�
rc�l�|�g}|j||dgz�}|j|j�S)z:Return object nTSecurityDescriptor in SDDL format
        rb)r-rKr)rr"r$r,s    r�get_sd_as_sddlzSDUtils.get_sd_as_sddl�s=�����H��!�!�)�X�9I�8J�-J�K���|�|�D�O�O�,�,rr)NNNN)�__name__�
__module__�__qualname__�__doc__rr'r-r0rYr`rcrerirk�rrrrsE��M�F�%�*5�D�?C�59�a;�F�B�	�	�-rr)rorErrrrrr�	samba.ndrrr	r
�samba.dcerpcr�samba.ntstatusr�objectrrprr�<module>rus2��&<��+�+�,�8�8�!��
x-�f�x-r

Zerion Mini Shell 1.0