%PDF- %PDF-
Mini Shell

Mini Shell

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

�

�I�d�����ddlmZddlmZddlmZddlmZddlm	Z	m
Z
ddlmZddlmZddlZddl
Z
ddlZddlmZmZddlZdd	lmZmZdd
lmZddlmZddlmZmZmZmZdd
lmZm Z ddl!m"Z"m#Z#m$Z$ddl!m%Z%d�Z&Gd�d�Z'd�Z(d�Z)d�Z*d�Z+d�Z,d�Z-d�Z.d�Z/d�Z0d�Z1d�Z2d�Z3d�Z4d �Z5d!�Z6d"�Z7d#�Z8d$�Z9d%�Z:d&�Z;d'�Z<d(�Z=Gd)�d*e�Z>d+�Z?Gd,�d-e�Z@Gd.�d/e�ZAGd0�d1e�ZBGd2�d3e�ZCGd4�d5e�ZDGd6�d7e�ZEGd8�d9e�ZFGd:�d;e�ZGGd<�d=e�ZHGd>�d?e�ZIGd@�dAe�ZJGdB�dCe�ZKy)D�N)�WERRORError)�werror)�pack)�	inet_ntop�	inet_pton)�AF_INET)�AF_INET6)�
ndr_unpack�ndr_pack)�	remove_dc�dsdb_dns)�SamDB)�system_session)�Command�CommandError�Option�SuperCommand)�dnsp�	dnsserver)�record_from_string�
DNSParseError�flag_from_string)�dns_record_matchc��|j�dk(rd}d|z}	tj|||�}|S#t$r}td|�d|����d}~wwxYw)N�	localhostz	127.0.0.1zncacn_ip_tcp:%s[sign]zConnecting to DNS RPC server z
 failed with )�lowerr�RuntimeErrorr)�server�lp�creds�binding_str�dns_conn�es      �2/usr/lib/python3/dist-packages/samba/netcmd/dns.py�dns_connectr%/se��
�|�|�~��$���)�F�2�K�[��&�&�{�B��>���O���[��v�WX�Y�Z�Z��[�s�5�	A�A�Ac
��eZdZdZej
dejdejdejdejdiZ
d�Zd�Zy	)
�DnsConnWrappera^A wrapper around a dnsserver.dnsserver connection that makes it
    harder not to report friendly messages.

    If, rather than

        dns_conn = dns_connect(server, lp, creds)

    you use

        dns_conn = DnsConnWrapper(server, lp, creds)

    then various common errors (for example, misspelled zones) on
    common operations will raise CommandErrors that turn into
    relatively nice messages (when compared to tracebacks).

    In addition, if you provide a messages keyword argument, it will
    override the defaults. Note that providing None will turn off the
    default, letting the original exception shine through.

        messages = {
            werror.WERR_DNS_ERROR_ZONE_DOES_NOT_EXIST: (
                f'Zone {zone} does not exist and so could not be deleted.'),
            werror.WERR_DNS_ERROR_NAME_DOES_NOT_EXIST: None
        }
        res = dns_conn.DnssrvOperation2( # ...
                                        messages=messages)

    This example changes the message for ZONE_DOES_NOT_EXIST and
    avoids catching NAME_DOES_NOT_EXIST.

    Only WERRORErrors are intercepted.
    zCould not contact RPC serverzZone already existszThe record does not existzThe zone does not existzInsufficient permissionsc�(�t|||�|_y�N)r%r")�selfrrr s    r$�__init__zDnsConnWrapper.__init__es��#�F�B��6��
�c�T���t�j|��|dvr�Sdd���fd�
}|S)N>�DnssrvQuery2�DnssrvOperation2�DnssrvEnumRecords2�DnssrvUpdateRecord2�DnssrvComplexOperation2��messagesc����|�i}	�|�S#t$r^}|j\}}||vr|��t||�d|�d�|��|�jvrt�j|�d|�d�|���d}~wwxYw)N� [�])r�argsr�default_messages)r4r8r#�werr�errstr�attrr*s     ��r$�fz%DnsConnWrapper.__getattr__.<locals>.frs��������
��T�{�"���	
� �v�v���f��8�#��|��&�(�4�.�)9��F�8�1�'E�q�I�I��4�0�0�0�&�$�*?�*?��*E�)F�b���PQ�'R�TU�V�V���	
�s��	A3�AA.�.A3)�getattrr")r*�namer=r<s`  @r$�__getattr__zDnsConnWrapper.__getattr__hs6����t�}�}�d�+���'�'��K�"�	�"�r,N)
�__name__�
__module__�__qualname__�__doc__r�WERR_DNS_ERROR_DS_UNAVAILABLE�"WERR_DNS_ERROR_ZONE_ALREADY_EXISTS�$WERR_DNS_ERROR_RECORD_DOES_NOT_EXIST�"WERR_DNS_ERROR_NAME_DOES_NOT_EXIST�WERR_ACCESS_DENIEDr9r+r@�r,r$r'r';sX���D	�,�,�.L��1�1�3H��3�3�5P��1�1�4M��!�!�#=���7�r,r'c�4�|dk(rd}|S|dk(rd}|Sd|z}|S)Nr�FALSE��TRUE�UNKNOWN (0x%x)rJ)�flag�rets  r$�bool_stringrR�s;���q�y���
�J�	
������J���%���Jr,c�L�d}|D]}|t||�k(s�|}n|sd|z}|S)NrO�r>)�module�	enum_defs�valuerQr#s     r$�enum_stringrX�sA��
�C�
����G�F�A�&�&��C������&���Jr,c�P�d}|D]}|t||�zs�|d|zz
}�|sd}|S)N�z%s �NONErT)rU�bitmap_defsrWrQ�bs     r$�
bitmap_stringr^�sB��
�C�
����7�6�1�%�%��5�1�9��C������Jr,c�,�gd�}tt||�S)N)�DNS_BOOT_METHOD_UNINITIALIZED�DNS_BOOT_METHOD_FILE�DNS_BOOT_METHOD_REGISTRY�DNS_BOOT_METHOD_DIRECTORY�rXr)�boot_methodrVs  r$�boot_method_stringrf�s��J�I��y�)�[�9�9r,c�,�gd�}tt||�S)N)�DNS_ALLOW_RFC_NAMES_ONLY�DNS_ALLOW_NONRFC_NAMES�DNS_ALLOW_MULTIBYTE_NAMES�DNS_ALLOW_ALL_NAMESrd)�
check_flagrVs  r$�name_check_flag_stringrm�s��E�I��y�)�Z�8�8r,c�,�gd�}tt||�S)N)�DNS_ZONE_TYPE_CACHE�DNS_ZONE_TYPE_PRIMARY�DNS_ZONE_TYPE_SECONDARY�DNS_ZONE_TYPE_STUB�DNS_ZONE_TYPE_FORWARDER�DNS_ZONE_TYPE_SECONDARY_CACHE�rXr)�	zone_typerVs  r$�zone_type_stringrw�s��M�I��t�Y�	�2�2r,c�,�gd�}tt||�S)N)�DNS_ZONE_UPDATE_OFF�DNS_ZONE_UPDATE_UNSECURE�DNS_ZONE_UPDATE_SECUREru)�zone_updaterVs  r$�zone_update_stringr}�s��+�I��t�Y��4�4r,c�,�gd�}tt||�S)N)�DNS_ZONE_SECSECURE_NO_SECURITY�DNS_ZONE_SECSECURE_NS_ONLY�DNS_ZONE_SECSECURE_LIST_ONLY�DNS_ZONE_SECSECURE_NO_XFERrd)�securityrVs  r$�zone_secondary_security_stringr��s��O�I��y�)�X�6�6r,c�,�gd�}tt||�S)N)�DNS_ZONE_NOTIFY_OFF�DNS_ZONE_NOTIFY_ALL_SECONDARIES�DNS_ZONE_NOTIFY_LIST_ONLYrd)�notify_levelrVs  r$�zone_notify_level_stringr��s��.�I��y�)�\�:�:r,c�,�gd�}tt||�S)N)�DNS_DP_AUTOCREATED�
DNS_DP_LEGACY�DNS_DP_DOMAIN_DEFAULT�DNS_DP_FOREST_DEFAULT�DNS_DP_ENLISTED�DNS_DP_DELETED�r^r)�dp_flagsr\s  r$�dp_flags_stringr��s��Q�K���K��:�:r,c�,�gd�}tt||�S)N)	�DNS_RPC_ZONE_PAUSED�DNS_RPC_ZONE_SHUTDOWN�DNS_RPC_ZONE_REVERSE�DNS_RPC_ZONE_AUTOCREATED�DNS_RPC_ZONE_DSINTEGRATED�DNS_RPC_ZONE_AGING�DNS_RPC_ZONE_UPDATE_UNSECURE�DNS_RPC_ZONE_UPDATE_SECURE�DNS_RPC_ZONE_READONLYr�)�flagsr\s  r$�zone_flags_stringr��s��,�K�
��K��7�7r,c	��g}|s|St|j�D]:}ttt	d|j
|��}|j
|��<|S)N�I)�range�	AddrCountrrr�	AddrArray�append)�arrayrQ�i�addrs    r$�ip4_array_stringr��sV��
�C���
�
�5�?�?�
#�����$�s�E�O�O�A�,>�"?�@���
�
�4����Jr,c���g}|s|St|j�D]�}|j|jddk(rAt	j
dg|j|jdd���}t
t|�}nb|j|jddk(rAt	j
dg|j|jdd���}t
t|�}nd	}|j|���|S)
Nr��4B����16B��UNKNOWN)
r�r�r��MaxSa�structrrrr	r�)r�rQr��xr�s     r$�dns_addr_array_stringr��s���
�C���
�
�5�?�?�
#�	���?�?�1��#�#�A�&�$�.����D�A�5�?�?�1�#5�#;�#;�A�a�#@�A�A��W�a�(�D�
�_�_�Q�
�
%�
%�a�
(�D�
0����E�C�E�O�O�A�$6�$<�$<�Q�r�$B�C�A��X�q�)�D��D��
�
�4��	��Jr,c�`�	t|�S#t$r}t|j��d}~wwxYwr))rrrr8)�rec_typer#s  r$�
dns_type_flagr��s1��$���)�)���$��A�F�F�#�#��$�s�

�	-�(�-c���|j�}|dk(rtj}|S|dk(rtj}|S|dk(rtj}|Std|z��)N�W2K�DOTNET�LONGHORNzUnknown client version %s)�upperr�DNS_CLIENT_VERSION_W2K�DNS_CLIENT_VERSION_DOTNET�DNS_CLIENT_VERSION_LONGHORNr)�cli_version�version�client_versions   r$�dns_client_versionr��sx�����!�G��%��"�9�9����

�H�	�"�<�<��
��	
�J�	�"�>�>�����6��D�E�Er,c��|jd|jz�|jdt|j�z�|jdt	|j
�z�|jdt	|j�z�|jdt	|j�z�|jd|jz�|jd|jz�|tjk7rv|jdt|j�z�|jd	t|j�z�|jd
t|j�z�nu|jdt!|j�z�|jd	t!|j�z�|jd
t!|j�z�|jd|j"z�|jd|j$z�|jd
|j&z�|jd|j(z�|jdt+|j,�z�|jd|j.z�|jd|j0z�|jd|j2z�|jd|j4z�|jd|j6z�|jd|j8z�|jd|j:z�|jd|j<z�|jdt	|j>�z�|jdt	|j@�z�|jdt	|jB�z�|jdt	|jD�z�|jdt	|jF�z�|jdt	|jH�z�|jdt	|jJ�z�|jdt	|jL�z�|jd t	|jN�z�|jd!t	|jP�z�|jd"t	|jR�z�|jd#t	|jT�z�|jd$t	|jV�z�|tjXk7�r�|jd%|jZz�|jd&t!|j\�z�|jd'|j^z�|jd(|j`z�|jd)|jbz�|jd*|jdz�|jd+|jfz�|jd,|jhz�|jd-|jjz�|jd.|jlz�|jd/|jnz�|jd0|jpz�|jd1|jrz�|jd2|jtz�|tjk(r(|jd3t	|jv�z�yy)4Nz%  dwVersion                   : 0x%x
z#  fBootMethod                 : %s
z#  fAdminConfigured            : %s
�#  fAllowUpdate                : %s
z#  fDsAvailable                : %s
z#  pszServerName               : %s
z#  pszDsContainer              : %s
z#  aipServerAddrs              : %s
z#  aipListenAddrs              : %s
z#  aipForwarders               : %s
z#  dwLogLevel                  : %d
z#  dwDebugLevel                : %d
z#  dwForwardTimeout            : %d
z%  dwRpcPrototol               : 0x%x
z#  dwNameCheckFlag             : %s
z#  cAddressAnswerLimit         : %d
z#  dwRecursionRetry            : %d
z#  dwRecursionTimeout          : %d
z#  dwMaxCacheTtl               : %d
z#  dwDsPollingInterval         : %d
z#  dwScavengingInterval        : %d
z#  dwDefaultRefreshInterval    : %d
z#  dwDefaultNoRefreshInterval  : %d
z#  fAutoReverseZones           : %s
z#  fAutoCacheUpdate            : %s
z#  fRecurseAfterForwarding     : %s
z#  fForwardDelegations         : %s
z#  fNoRecursion                : %s
z#  fSecureResponses            : %s
z#  fRoundRobin                 : %s
z#  fLocalNetPriority           : %s
z#  fBindSecondaries            : %s
z#  fWriteAuthorityNs           : %s
z#  fStrictFileParsing          : %s
z#  fLooseWildcarding           : %s
z#  fDefaultAgingState          : %s
�%  dwRpcStructureVersion       : 0x%x
z#  aipLogFilter                : %s
z#  pwszLogFilePath             : %s
z#  pszDomainName               : %s
z#  pszForestName               : %s
z#  pszDomainDirectoryPartition : %s
z#  pszForestDirectoryPartition : %s
z%  dwLocalNetPriorityNetMask   : 0x%x
z#  dwLastScavengeTime          : %d
z#  dwEventLogLevel             : %d
z#  dwLogFileMaxSize            : %d
z#  dwDsForestVersion           : %d
z#  dwDsDomainVersion           : %d
z#  dwDsDsaVersion              : %d
z#  fReadOnlyDC                 : %s
)<�write�	dwVersionrf�fBootMethodrR�fAdminConfigured�fAllowUpdate�fDsAvailable�
pszServerName�pszDsContainerr�DNSSRV_TYPEID_SERVER_INFOr��aipServerAddrs�aipListenAddrs�
aipForwardersr��
dwLogLevel�dwDebugLevel�dwForwardTimeout�
dwRpcProtocolrm�dwNameCheckFlag�cAddressAnswerLimit�dwRecursionRetry�dwRecursionTimeout�
dwMaxCacheTtl�dwDsPollingInterval�dwScavengingInterval�dwDefaultRefreshInterval�dwDefaultNoRefreshInterval�fAutoReverseZones�fAutoCacheUpdate�fRecurseAfterForwarding�fForwardDelegations�fNoRecursion�fSecureResponses�fRoundRobin�fLocalNetPriority�fBindSecondaries�fWriteAuthorityNs�fStrictFileParsing�fLooseWildcarding�fDefaultAgingState�DNSSRV_TYPEID_SERVER_INFO_W2K�dwRpcStructureVersion�aipLogFilter�pwszLogFilePath�
pszDomainName�
pszForestName�pszDomainDirectoryPartition�pszForestDirectoryPartition�dwLocalNetPriorityNetMask�dwLastScavengeTime�dwEventLogLevel�dwLogFileMaxSize�dwDsForestVersion�dwDsDomainVersion�dwDsDsaVersion�fReadOnlyDC)�outf�typeid�
serverinfos   r$�print_serverinfors����J�J�7�*�:N�:N�N�O��J�J�5�8J�:�Ka�Ka�8b�b�c��J�J�5��J�D_�D_�8`�`�a��J�J�5��J�D[�D[�8\�\�]��J�J�5��J�D[�D[�8\�\�]��J�J�5�
�8P�8P�P�Q��J�J�5�
�8Q�8Q�Q�R�
��4�4�4��
�
�9�#�J�$=�$=�>�?�	@��
�
�9�#�J�$=�$=�>�?�	@��
�
�9�#�J�$<�$<�=�>�	?�	
�
�
�9�(��)B�)B�C�D�	E��
�
�9�(��)B�)B�C�D�	E��
�
�9�(��)A�)A�B�C�	D�	�J�J�5�
�8M�8M�M�N��J�J�5�
�8O�8O�O�P��J�J�5�
�8S�8S�S�T��J�J�7�*�:R�:R�R�S��J�J�5�8N�z�Oi�Oi�8j�j�k��J�J�5�
�8V�8V�V�W��J�J�5�
�8S�8S�S�T��J�J�5�
�8U�8U�U�V��J�J�5�
�8P�8P�P�Q��J�J�5�
�8V�8V�V�W��J�J�5�
�8W�8W�W�X��J�J�5�
�8[�8[�[�\��J�J�5�
�8]�8]�]�^��J�J�5��J�D`�D`�8a�a�b��J�J�5��J�D_�D_�8`�`�a��J�J�5��J�Df�Df�8g�g�h��J�J�5��J�Db�Db�8c�c�d��J�J�5��J�D[�D[�8\�\�]��J�J�5��J�D_�D_�8`�`�a��J�J�5��J�DZ�DZ�8[�[�\��J�J�5��J�D`�D`�8a�a�b��J�J�5��J�D_�D_�8`�`�a��J�J�5��J�D`�D`�8a�a�b��J�J�5��J�Da�Da�8b�b�c��J�J�5��J�D`�D`�8a�a�b��J�J�5��J�Da�Da�8b�b�c�
��8�8�8��
�
�;�j�>^�>^�^�_��
�
�9�<Q�R\�Ri�Ri�<j�j�k��
�
�9�J�<V�<V�V�W��
�
�9�J�<T�<T�T�U��
�
�9�J�<T�<T�T�U��
�
�9�J�<b�<b�b�c��
�
�9�J�<b�<b�b�c��
�
�;�j�>b�>b�b�c��
�
�9�J�<Y�<Y�Y�Z��
�
�9�J�<V�<V�V�W��
�
�9�J�<W�<W�W�X��
�
�9�J�<X�<X�X�Y��
�
�9�J�<X�<X�X�Y��
�
�9�J�<U�<U�U�V�
��4�4�4��
�
�9�K�
�H^�H^�<_�_�`�5r,c�(�|jd|jz�|jdt|j�z�|jdt	|j
�z�|jdt
|j�z�|jdt	|j�z�|jdt	|j�z�|jdt	|j�z�|jdt	|j�z�|jd	|jz�|tjk7r(|jd
t|j �z�n'|jd
t#|j �z�|jdt%|j&�z�|jdt)|j*�z�|tjk7rO|jd
t|j,�z�|jdt|j.�z�nN|jd
t#|j,�z�|jdt#|j.�z�|jdt	|j0�z�|jdt	|j2�z�|jdt	|j4�z�|jd|j6z�|jd|j8z�|jd|j:z�|tjk7r(|jdt|j<�z�n'|jdt#|j<�z�|tj>k7�r[|jd|j@z�|jd|jBz�|jd|jDz�|tjk7r(|jdt|jF�z�n'|jdt#|jF�z�|jdtI|jJ�z�|jd|jLz�|jd|jNz�|jd|jPz�|jd|jRz�|tjk(r�|jdt	|jT�z�|jd t	|jV�z�|jd!t	|jX�z�|jd"|jZz�|jd#|j\z�yy)$N�#  pszZoneName                 : %s
z#  dwZoneType                  : %s
z#  fReverse                    : %s
r�z#  fPaused                     : %s
z#  fShutdown                   : %s
z#  fAutoCreated                : %s
z#  fUseDatabase                : %s
z#  pszDataFile                 : %s
z#  aipMasters                  : %s
z#  fSecureSecondaries          : %s
z#  fNotifyLevel                : %s
z#  aipSecondaries              : %s
z#  aipNotify                   : %s
z#  fUseWins                    : %s
z#  fUseNbstat                  : %s
z#  fAging                      : %s
z#  dwNoRefreshInterval         : %d
z#  dwRefreshInterval           : %d
z#  dwAvailForScavengeTime      : %d
z#  aipScavengeServers          : %s
r�z#  dwForwarderTimeout          : %d
z#  fForwarderSlave             : %d
z#  aipLocalMasters             : %s
�#  dwDpFlags                   : %s
�#  pszDpFqdn                   : %s
z#  pwszZoneDn                  : %s
z#  dwLastSuccessfulSoaCheck    : %d
z#  dwLastSuccessfulXfr         : %d
z#  fQueuedForBackgroundLoad    : %s
z#  fBackgroundLoadInProgress   : %s
z#  fReadOnlyZone               : %s
z#  dwLastXfrAttempt            : %d
z#  dwLastXfrResult             : %d
)/r��pszZoneNamerw�
dwZoneTyperR�fReverser}r��fPaused�	fShutdown�fAutoCreated�fUseDatabase�pszDataFiler�DNSSRV_TYPEID_ZONE_INFOr��
aipMastersr�r��fSecureSecondariesr��fNotifyLevel�aipSecondaries�	aipNotify�fUseWins�
fUseNbstat�fAging�dwNoRefreshInterval�dwRefreshInterval�dwAvailForScavengeTime�aipScavengeServers�DNSSRV_TYPEID_ZONE_INFO_W2Kr��dwForwarderTimeout�fForwarderSlave�aipLocalMastersr��	dwDpFlags�	pszDpFqdn�
pwszZoneDn�dwLastSuccessfulSoaCheck�dwLastSuccessfulXfr�fQueuedForBackgroundLoad�fBackgroundLoadInProgress�
fReadOnlyZone�dwLastXfrAttempt�dwLastXfrResult)rr�zoneinfos   r$�print_zoneinfor,Ps����J�J�5��8L�8L�L�M��J�J�5�8H��I\�I\�8]�]�^��J�J�5��H�DU�DU�8V�V�W��J�J�5�8J�8�K`�K`�8a�a�b��J�J�5��H�DT�DT�8U�U�V��J�J�5��H�DV�DV�8W�W�X��J�J�5��H�DY�DY�8Z�Z�[��J�J�5��H�DY�DY�8Z�Z�[��J�J�5��8L�8L�L�M�
��2�2�2��
�
�9�#�H�$7�$7�8�9�	:�	
�
�
�9�(��)<�)<�=�>�	?��J�J�5�8V�W_�Wr�Wr�8s�s�t��J�J�5�8P�QY�Qf�Qf�8g�g�h�
��2�2�2��
�
�9�#�H�$;�$;�<�=�	>��
�
�9�#�H�$6�$6�7�8�	9�	
�
�
�9�(��)@�)@�A�B�	C��
�
�9�(��);�);�<�=�	>��J�J�5��H�DU�DU�8V�V�W��J�J�5��H�DW�DW�8X�X�Y��J�J�5��H�O�O�8T�T�U��J�J�5��8T�8T�T�U��J�J�5��8R�8R�R�S��J�J�5��8W�8W�W�X�
��2�2�2��
�
�9�#�H�$?�$?�@�A�	B�	
�
�
�9�(��)D�)D�E�F�	G���6�6�6��
�
�;�h�>\�>\�\�]��
�
�9�H�<W�<W�W�X��
�
�9�H�<T�<T�T�U��Y�6�6�6��J�J�=�'��(@�(@�A�B�
C�
�J�J�=�,�X�-E�-E�F�G�
H��
�
�9�O�H�L^�L^�<_�_�`��
�
�9�H�<N�<N�N�O��
�
�9�H�<O�<O�O�P��
�
�9�H�<]�<]�]�^��
�
�9�H�<X�<X�X�Y�
��2�2�2��
�
�9�K��Hi�Hi�<j�j�k��
�
�9�K��Hj�Hj�<k�k�l��
�
�9�K��H^�H^�<_�_�`��
�
�9�H�<U�<U�U�V��
�
�9�H�<T�<T�T�U�3r,c���|jd|jz�|jdt|j�z�|jdt	|j
�z�|jd|jz�|tjk7rF|jdt|j�z�|jd|jz�yy)Nrz#  Flags                       : %s
z#  ZoneType                    : %s
z#  Version                     : %s
rr)r�rr��Flagsrw�ZoneType�Versionr�DNSSRV_TYPEID_ZONE_W2Kr�r!r")rr�zones   r$�
print_zoner3�s����J�J�5��8H�8H�H�I��J�J�5�8I�$�*�*�8U�U�V��J�J�5�8H����8W�W�X��J�J�5����D�E�
��1�1�1��
�
�9�O�D�N�N�<[�[�\��
�
�9�D�N�N�J�K�2r,c��|jd|jz�|jD] }|jd�t|||��"y)Nz  %d zone(s) found
�
)r��dwZoneCount�	ZoneArrayr3)rr�zonesr2s    r$�print_enumzonesr9�sE���J�J�%��(9�(9�9�:����'���
�
�4���4���&�'r,c��|jtjk(rd|jz}�n�|jtjk(rd|jz}�n�|jtj
k(rd|jjz}�nw|jtjk(rd|jjz}�n?|jtjk(rd|jjz}�n|jtjk(r�d|jj|jj|jj|jj|jj|jjj|jj jfz}�n<|jtj"k(r:d|jj$j|jj&fz}n�|jtj(k(rdd|jj*j|jj,|jj.|jj0fz}nd|jtj2k(rE|jjD�cgc]}d	|jz��}}d
dj5|�z}nd}|j7d
||j8|j:|j<fz�ycc}w)NzA: %szAAAA: %szPTR: %szNS: %sz	CNAME: %szKSOA: serial=%d, refresh=%d, retry=%d, expire=%d, minttl=%d, ns=%s, email=%szMX: %s (%d)zSRV: %s (%d, %d, %d)z"%s"zTXT: %s�,z	Unknown: z%    %s (flags=%x, serial=%d, ttl=%d)
)�wTyper�
DNS_TYPE_A�data�
DNS_TYPE_AAAA�DNS_TYPE_PTR�str�DNS_TYPE_NS�DNS_TYPE_CNAME�DNS_TYPE_SOA�
dwSerialNo�	dwRefresh�dwRetry�dwExpire�dwMinimumTtl�NamePrimaryServer�ZoneAdministratorEmail�DNS_TYPE_MX�nameExchange�wPreference�DNS_TYPE_SRV�
nameTarget�wPort�	wPriority�wWeight�DNS_TYPE_TXT�joinr��dwFlags�dwSerial�dwTtlSeconds)r�rec�mesgr?�slists     r$�print_dns_recordr\�sO��
�y�y�D�O�O�#��#�(�(�#��	���d�(�(�	(��S�X�X�&��	���d�'�'�	'��C�H�H�L�L�)��	���d�&�&�	&��3�8�8�<�<�(��	���d�)�)�	)��c�h�h�l�l�+��	���d�'�'�	'�\��H�H�'�'��H�H�&�&��H�H�$�$��H�H�%�%��H�H�)�)��H�H�.�.�2�2��H�H�3�3�7�7�`9�9��

���d�&�&�	&����� 5� 5� 9� 9�3�8�8�;O�;O�P�P��	���d�'�'�	'�%����)<�)<�)@�)@�#�(�(�.�.�),���);�);�S�X�X�=M�=M�)O�O��	���d�'�'�	'�/2�x�x�|�|�<�t��$�(�(�"�<��<��3�8�8�E�?�*�����J�J�7��c�k�k�3�<�<��1A�1A�;C�C�D��	=s�Mc���|jD]^}|jd|jj|j|j
fz�|jD]}t||���`y)Nz#  Name=%s, Records=%d, Children=%d
)rYr��dnsNodeNamerA�wRecordCount�dwChildCount�recordsr\)rrarY�dns_recs    r$�print_dnsrecordsrc�sl���{�{�0���
�
�9��O�O�'�'��$�$��$�$�=&�&�	'��{�{�	0�G� ��w�/�	0�0r,c�h�	t||�}|S#t$r}t|j�d�d}~wwxYwr))rrrr8)�record_typer>rYr#s    r$�data_to_dns_recordrf�s=��.� ��d�3���J���.��A�F�F�#��-��.�s��	1�,�1c��eZdZdZdZdgZejejejd�Z
eddddgd	�d
��gZ		dd
�Z
y)�cmd_serverinfozQuery for Server information.�%prog <server> [options]r��	sambaopts�versionopts�credopts�--client-version�Client Version�longhorn�w2k|dotnet|longhorn��w2k�dotnetrp�cli_ver��help�default�metavar�choices�destNc�$�|j�|_|j|j�|_t	||j|j�}t|�}|j
|d|dd�\}}	t|j||	�y)Nr�
ServerInfo)	�get_loadparmr�get_credentialsr r'r�r.rr)
r*rrurkrmrlr"r�r�ress
          r$�runzcmd_serverinfo.run�sx���(�(�*����-�-�d�g�g�6��
�!�&�$�'�'�4�:�:�>��+�G�4���+�+�N�A�v�,0�,�@��������F�C�0r,�NNN�rArBrCrD�synopsis�
takes_args�options�SambaOptions�VersionOptions�CredentialsOptions�takes_optiongroupsr�
takes_optionsr�rJr,r$rhrh�sg��'�)�H���J��)�)��-�-��.�.���	�!�(8�!�+@�4�9�	F��M�=A��
1r,rhc
��|D]X\}}}}d|j�z}t||�d|�d|�d�d|��}|j|�|j||||f��Zy)z$Generate options for cmd_zoneoptionsz--r6�-r7�int)rw�typer{N)rrr�)	�tabler��integer_properties�k�doc�_min�_max�o�opts	         r$�_add_integer_optionsr��sy��#�6���3��d��1�7�7�9����a�!�U�"�T�F�!�D�6��3� ����	���S�!��!�!�1�d�D�!�"4�5�6r,c
��eZdZdZdZddgZejejejd�Z
edddd	gd
�d��ed
dd��eddd��eddd��edddd��gZgZ
egd�ee
�					d"d�Zd�Zd�Zd �Zd!�Zy)#�cmd_zoneoptionszChange zone aging options.�%prog <server> <zone> [options]rr2rjrnrorprqrrrurvz--mark-old-records-staticz
YYYY-MM-DDz0Make records older than this (YYYY-MM-DD) static)ryrwz--mark-records-static-regex�REGEXPz4Make records matching this regular expression staticz--mark-records-dynamic-regexz5Make records matching this regular expression dynamicz-nz	--dry-run�
store_truez,Don't change anything, say what would happen)�actionrw))�AgingzEnable record agingrrM)�NoRefreshIntervalz3Aging no refresh interval in hours (0: use default)r�0V)�RefreshIntervalz0Aging refresh interval in hours (0: use default)rr�Nc��|j�|_|j|j�|_t	||j|j�}t|�}
tj}|jD]�\}}}}|j|���||}|�||krt|�d|����|�||kDrt|�d|����t
j�}||_||_
|r!td|�d|�d|��|j����	|j!|
d||dd||�td
|�d|��|j����d}||	|
fD]
}|��|dz
}�|dkDrtd��|�|j%||||�|	�|j'|||	|�|
�|j)|||
|�yy#t"$r}td	|�d|���d�d}~wwxYw)
Nz must be at least z can't exceed z
would set z to z for ��filer�ResetDwordPropertyzCould not set zSet rMz(Multiple --mark-* options will not work
)r~rrr r'r�r�DNSSRV_TYPEID_NAME_AND_PARAMr��getr�DNS_RPC_NAME_AND_PARAM�dwParam�pszNodeName�printrr/r�mark_old_records_static�mark_records_static_regex�mark_records_dynamic_regex)r*rr2rurkrmrl�dry_runr�r�r��kwargsr"r��nap_typer�r�r�r��v�
name_paramr#�n_mark_optionsr�s                        r$r�zcmd_zoneoptions.run5s;���(�(�*����-�-�d�g�g�6��
�!�&�$�'�'�4�:�:�>��+�G�4���9�9�� $� 7� 7�	5��A�t�T�1��z�z�!�}�$���q�	�A���A��H�"�a�S�(:�4�&�#A�B�B���A��H�"�a�S��t�f�#=�>�>�"�9�9�;�J�!"�J��%&�J�"���
�1�#�T�!��E�$��8�t�y�y�I��

J��)�)�.�*+�*0�*.�*+�*>�*2�*4�6�
�D���4��s�#�$�)�)�4�7	5�@��)�+�,�.�	$�A��}��!�#��		$��A���J�K�K�"�.��(�(���)@�)0�
2�%�0��*�*�6�+/�+D�+2�
4�
&�1��+�+�F�,0�,F�,3�
5�2��;�
J�"�^�A�3�d�1�#�#>�?�T�I��
J�s�F0�0	G�9G�Gc���td|zt�|j|j��}d|�d|j	���}|j|tjdddg��}||fS)	N�	ldap://%s��url�session_info�credentialsrzDC=z#,CN=MicrosoftDNS,DC=DomainDNSZones,z/(&(objectClass=dnsNode)(!(dNSTombstoned=TRUE)))�	dnsRecordr?)�base�scope�
expression�attrs)rrr r�get_default_basedn�search�ldb�
SCOPE_SUBTREE)r*r�	zone_name�samdb�zone_dn�nodess      r$�_get_dns_nodeszcmd_zoneoptions._get_dns_nodes~s����+��.�#1�#3�"&�*�*����:�����#F��.�.�0�1�3�����'�#&�#4�#4�*D�$/��#8�	�:��
�e�|�r,c��	tj|d�}tj|�}tjt|��}|j||�\}	}
|
D�]E}d|vr�	t|d�}d}
t|�D]Y\}}ttj|�}|j|ks�0|jdk7s�@d|_t|�||<|
dz
}
�[|
dk(r��|ddj!�}|r.t#d|
�d	t%|��d
|�d|�d�	|j&����t(j*j-|	|j.|d
�t(j0�}|	j3|�t#d|
�d	t%|��d
|�d|�d�	|j&����Hy#t$r}t	d|�d���d}~wwxYw)Nz%Y-%m-%dz
Invalid date z: should be YYY-MM-DDr�rrMr?�would make �/� records static on �.r���dnr��made )�time�strptime�mktime�
ValueErrorrr
�unix_to_dns_timestampr�r��list�	enumerater
r�DnssrvRpcRecord�dwTimeStampr�decoder��lenrr��Message�	from_dictr��FLAG_MOD_REPLACE�modify)r*rr��date_stringr��ts�tr#�	thresholdr�r��node�values�changesr�r�rYr?�msgs                   r$r�z'cmd_zoneoptions.mark_old_records_static�s���	S����{�J�7�B����B��A��2�2�3�q�6�:�	��*�*�6�9�=���u��	:�D��$�&���$�{�+�,�F��G�!�&�)�
!���1� ��!5�!5�q�9���?�?�Y�.�3�?�?�a�3G�&'�C�O� (��
�F�1�I��q�L�G�
!��!�|����<��?�)�)�+�D����G�9�A�c�&�k�]�;� �6��9�+�Q�0�6:�i�i�A���+�+�'�'��/3�w�w�6<�)*�),�(<�(<�	>�C�

�L�L����E�'��!�C��K�=�0C��F�!�I�;�a�)�/3�y�y�
:�;	:��
�	S���{�m�;P�Q�R�R��	S�s�+F,�,	G	�5G�G	c��tj|�}|j||�\}}|D�]V}|ddj�}	|j	|	�s�,d|vr�1t|d�}
t
|
�dk(r�Nd}t|
�D]I\}}
ttj|
�}|jdk7s�0d|_t|�|
|<|dz
}�K|dk(r��|r.td|�dt
|
��d|	�d|�d�	|j�	���tj j#||j$|
d
�tj&�}|j)|�td|�dt
|
��d|	�d|�d�	|j�	���Yy)
z>Make the records of nodes with matching names static.
        r?rr�rMr�r�r�r�r�r�r�N)�re�compiler�r�r�r�r�r�r
rr�r�rr�rr�r�r�r�r�r�)r*rr��regexr��rr�r�r�r?r�r�r�r�rYr�s                r$r�z)cmd_zoneoptions.mark_records_static_regex�s���
�J�J�u����*�*�6�9�=���u��"	:�D���<��?�)�)�+�D��8�8�D�>���$�&���$�{�+�,�F��6�{�a����G�!�&�)�
!���1� ��!5�!5�q�9���?�?�a�'�&'�C�O� (��
�F�1�I��q�L�G�
!��!�|�����G�9�A�c�&�k�]�;� �6��9�+�Q�0�6:�i�i�A���+�+�'�'��/3�w�w�6<�)*�),�(<�(<�	>�C�

�L�L����E�'��!�C��K�=�0C��F�!�I�;�a�)�/3�y�y�
:�C"	:r,c���tj|�}|j||�\}}tj�}t	j
t
|��}	tjtjtjh}
|D�]e}|ddj�}|j|�s�,d|vr�1t|d�}
t|
�dk(r�Nd}t|
�D]X\}}t!tj"|�}|j$|
vs�/|j&dk(s�?|	|_t)|�|
|<|dz
}�Z|dk(r��|r.t+d|�dt|
��d|�d|�d�	|j,�	���t.j0j3||j4|
d
�t.j6�}|j9|�t+d|�dt|
��d|�d|�d�	|j,�	���hy)
z�Make the records of nodes with matching names dynamic, with a
        current timestamp. In this case we only adjust the A, AAAA,
        and TXT records.
        r?rr�rMr�r�z records dynamic on r�r�r�r�N)r�r�r�r�r
r�r�rr=r?rTr�r�r�r�r�r
r�r<r�rr�rr�r�r�r�r�r�)r*rr�r�r�r�r�r��now�
dns_timestamp�safe_wtypesr�r?r�r�r�r�rYr�s                   r$r�z*cmd_zoneoptions.mark_records_dynamic_regex�s���

�J�J�u����*�*�6�9�=���u��i�i�k�� �6�6�s�3�x�@�
��O�O�������
���"	:�D���<��?�)�)�+�D��8�8�D�>���$�&���$�{�+�,�F��6�{�a����G�!�&�)�
!���1� ��!5�!5�q�9���9�9��+����1�0D�&3�C�O� (��
�F�1�I��q�L�G�
!��!�|�����G�9�A�c�&�k�]�;� �6��9�+�Q�0�6:�i�i�A���+�+�'�'��/3�w�w�6<�)*�),�(<�(<�	>�C�

�L�L����E�'��!�C��K�=�0D��F�!�I�;�a�)�/3�y�y�
:�C"	:r,)NNNFNNN)rArBrCrDr�r�r�r�r�r�r�rr�r�r�r�r�r�r�r�rJr,r$r�r�s���$�0�H��F�#�J��)�)��-�-��.�.���	�!�(8�!�+@�4�9�	F�	�*�L�F�	H��,�h�J�	L��-�x�K�	M��t�[��B�	D��M����	�'�+�-�CG�&+�$(�&*�'+�	F5�R
�(:�T(:�T1:r,r�c��eZdZdZdZddgZejejejd�Z
edddd	gd
�d��gZ		dd�Z
y
)�cmd_zoneinfozQuery for zone information.r�rr2rjrnrorprqrrrurvNc�$�|j�|_|j|j�|_t	||j|j�}t|�}|j
|d||d�\}	}
t|j|	|
�y)Nr�ZoneInfo)	r~rrr r'r�r.r,r)r*rr2rurkrmrlr"r�rr�s           r$r�zcmd_zoneinfo.run(sw���(�(�*����-�-�d�g�g�6��
�!�&�$�'�'�4�:�:�>��+�G�4���+�+�N�A�v�t�,6�8�����t�y�y�&�#�.r,r�r�rJr,r$r�r�sk��%�0�H��F�#�J��)�)��-�-��.�.���	�!�(8�!�+@�4�9�	F��M�CG��
/r,r�c�B�eZdZdZdZdgZejejejd�Z
eddddgd	�d
��edd
dd��edddd��edddd��edddd��edddd��edddd��ed d!dd"��ed#d$dd%��g	Z			d(d'�Z
y&))�cmd_zonelistzQuery for zones.rirrjrnrorprqrrrurvz	--primaryzList primary zones (default)r��primary�rwr�r{z--secondaryzList secondary zones�	secondary�--cachezList cached zones�cachez--autoz List automatically created zones�autoz	--forwardzList forward zones�forwardz	--reversezList reverse zones�reversez--dszList directory integrated zones�dsz--non-dszList non-directory zones�nondsNc	�*�d}|r|tjz}|r|tjz}|r|tjz}|r|tjz}|r|tj
z}|r|tjz}|	r|tjz}|
r|tjz}|dk(rtj}|j�|_
|j|j�|_t||j|j�}t|�}|j|d|ddtj |�\}}|tj"k(rtj$}ntj&}t)|j*||�y)Nr�	EnumZones)r�DNS_ZONE_REQUEST_PRIMARY�DNS_ZONE_REQUEST_SECONDARY�DNS_ZONE_REQUEST_CACHE�DNS_ZONE_REQUEST_AUTO�DNS_ZONE_REQUEST_FORWARD�DNS_ZONE_REQUEST_REVERSE�DNS_ZONE_REQUEST_DS�DNS_ZONE_REQUEST_NON_DSr~rrr r'r�r2�DNSSRV_TYPEID_DWORDr�r1�DNSSRV_TYPEID_ZONEr9r)r*rrur�r�r�r�r�r�rrrkrmrl�request_filterr"r�rr�s                   r$r�zcmd_zonelist.runXs]������i�@�@�@�N���i�B�B�B�N���i�>�>�>�N���i�=�=�=�N���i�@�@�@�N���i�@�@�@�N�
��i�;�;�;�N���i�?�?�?�N��Q��&�?�?�N��(�(�*����-�-�d�g�g�6��
�!�&�$�'�'�4�:�:�>��+�G�4���6�6�~�78�&�$�7B�7@�7T�7T�7E�	G�����Y�=�=�=��5�5�F��1�1�F���	�	�6�3�/r,)FFFFFFFFNNNr�rJr,r$r�r�5s����)�H���J��)�)��-�-��.�.���	�!�(8�!�+@�4�9�	F�	�{�!?�"��	4��}�#9�"��	6��y�2�"��	2��x�@�"��	1��{�!5�"��	4��{�!5�"��	4��v�=�"��	/��z� :�"��	2�%�M�,JO�FK�7;�)0r,r�c	��eZdZdZdZddgZejejejd�Z
edddd	gd
�d��ed
dddddgd��gZ			dd�Z
y)�cmd_zonecreatezCreate a zone.r�rr2rjrnrorprqrrrurvz--dns-directory-partitionz�Specify the naming context for the new zone, which affects the replication scope (domain or forest wide replication, default: domain).�domainz
domain|forest�forest�dns_dpNc���|j�|_|j|j�|_t	||j|j�}|j�}tj}	|dk(rtj}	t|�}
|
tjk(rVtj}t
j�}||_
tj|_d|_d|_d|_n�|
tj(k(r]tj*}t
j,�}||_
tj|_d|_d|_d|_|	|_n\tj0}t
j2�}||_
tj|_d|_d|_d|_|	|_|j5|
d|ddd||�tj6}t
j8�}
d|
_tj<|
_t@jBd|�d�i}|j5|
d||dd||
|�	�	|jDjGd
|z�y)NrrrM�
ZoneCreate�AllowUpdatezZone "z" already exists.r�r3zZone %s created successfully
)$r~rrr r'rrr�r�r�r��DNSSRV_TYPEID_ZONE_CREATE_W2K�DNS_RPC_ZONE_CREATE_INFO_W2Krrrpr	r�
fDsIntegrated�
fLoadExistingr�� DNSSRV_TYPEID_ZONE_CREATE_DOTNET�DNS_RPC_ZONE_CREATE_INFO_DOTNETr!�DNSSRV_TYPEID_ZONE_CREATE�!DNS_RPC_ZONE_CREATE_INFO_LONGHORNr/r�r�r�r{r�rrFrr�)r*rr2rurrkrmrlr"�dns_directorypartitionr�r�zone_create_info�name_and_paramr4s               r$r�zcmd_zonecreate.run�s=���(�(�*����-�-�d�g�g�6��
�!�&�$�'�'�4�:�:�>���z�z�|��!*�!@�!@���X��%.�%D�%D�"�+�G�4���Y�=�=�=��<�<�F�(�E�E�G��+/��(�*.�*D�*D��'�&'��#�-.��*�-.��*�
�y�B�B�
B��?�?�F�(�H�H�J��+/��(�*.�*D�*D��'�&'��#�-.��*�-.��*�)?��&��8�8�F�(�J�J�L��+/��(�*.�*D�*D��'�&'��#�-.��*�-.��*�)?��&��!�!�.�!�V�T�"#�\�6�"2�	4��7�7��"�9�9�;��%2��"�!%�!<�!<���
�5�5����/�0�
��
	�!�!�.�!�V�T�"#�%9�6�"0�8�	"�	E�	
�	�	���8�4�?�@r,r�r�rJr,r$rr�s����0�H��F�#�J��)�)��-�-��.�.���	�!�(8�!�+@�4�9�	F�	�*�5� �&� �(�+��	�	�M�&���@Ar,rc�p�eZdZdZdZddgZejejejd�Z
		dd�Zy)	�cmd_zonedeletezDelete a zone.r�rr2rjNc��|j�|_|j|j�|_t	||j|j�}|j�}tjd|�d�i}|jtjd||ddtjd|��	}|jjd|z�y)N�Zone z, does not exist and so could not be deleted.r�DeleteZoneFromDsr3zZone %s deleted successfully
)r~rrr r'rr�"WERR_DNS_ERROR_ZONE_DOES_NOT_EXISTr/rr��DNSSRV_TYPEID_NULLrr�)	r*rr2rkrmrlr"r4r�s	         r$r�zcmd_zonedelete.run�s����(�(�*����-�-�d�g�g�6��
�!�&�$�'�'�4�:�:�>���z�z�|��
�5�5���v�I�J�
���'�'�	�(M�(M�()�6�4��<N�(1�(D�(D�(,�x�(�A��
	
�	�	���8�4�?�@r,r��rArBrCrDr�r�r�r�r�r�r�r�rJr,r$r#r#�sG���0�H��F�#�J��)�)��-�-��.�.���:>��Ar,r#c��eZdZdZdZgd�Zejejejd�Z
edddd�	�ed
ddd�	�ed
ddd�	�edddd�	�edddd�	�edddd�	�edddd�	�gZ				dd�Z
y)�	cmd_queryz
Query a name.zO%prog <server> <zone> <name> <A|AAAA|PTR|CNAME|MX|NS|SOA|SRV|TXT|ALL> [options])rr2r?�rtyperjz--authorityz&Search authoritative records (default)r��	authorityr�r�zSearch cached recordsr�z--gluezSearch glue records�gluez--rootzSearch root hints�rootz--additionalzList additional records�
additionalz
--no-childrenzDo not list children�no_childrenz--only-childrenzList only children�
only_childrenNc
���t|�}|jd�dk7r|jjd|z�d}|r|tj
z}|r|tjz}|r|tjz}|r|tjz}|	r|tjz}|
r|tjz}|r|tjz}|dk(rtj
}|tjk(rI|jjd�|jjd�|tj
z}|j�|_
|
j|j�|_t!||j|j�}t"j$di}|j'tj(d|||d||dd|��\}}t+|j|�y)	N�*���z-use "@" to dump entire domain, looking up %s
rz>Specify either --authority or --root along with --additional.
zAssuming --authority.
�Record or zone does not exist.r3)r��findrr�r�DNS_RPC_VIEW_AUTHORITY_DATA�DNS_RPC_VIEW_CACHE_DATA�DNS_RPC_VIEW_GLUE_DATA�DNS_RPC_VIEW_ROOT_HINT_DATA�DNS_RPC_VIEW_ADDITIONAL_DATA�DNS_RPC_VIEW_NO_CHILDREN�DNS_RPC_VIEW_ONLY_CHILDRENr~rrr r'rrHr0r�rc)r*rr2r?r,r-r�r.r/r0r1r2rkrmrlre�select_flagsr"r4�buflenr�s                     r$r�z
cmd_query.run#s���$�E�*���9�9�S�>�R���I�I�O�O�L� �!�
"�����I�A�A�A�L���I�=�=�=�L���I�<�<�<�L���I�A�A�A�L���I�B�B�B�L���I�>�>�>�L���I�@�@�@�L��1��$�@�@�L��9�A�A�A��I�I�O�O�]�^��I�I�O�O�5�6��I�A�A�A�L��(�(�*����-�-�d�g�g�6��
�!�&�$�'�'�4�:�:�>��
�5�5�0�
���1�1��1�1�1�f�d�D��+�|�T�4��2�����
	����C�(r,)
FFFFFFFNNNr�rJr,r$r+r+s����E�H�5�J��)�)��-�-��.�.���	�}�#K�"��	6��y�6�"��	2��x�3�"��	1��x�1�"��	1��~�$=�"��	7���%;�"��	8�� �';�"��	:��M�"EJ�BG�:>��/)r,r+c�p�eZdZdZdZddgZejejejd�Z
		dd�Zy)	�
cmd_roothintszQuery root hints.z!%prog <server> [<name>] [options]rzname?rjNc��tj}tjtjz}|j�|_|j|j�|_t||j|j�}|jtjd|d|d||dd�
\}	}
t|j|
�y)Nrz..RootHints)rrBrr;r<r~rrr r'r0r�rcr)r*rr?rkrmrlrer?r"r@r�s           r$r�zcmd_roothints.runbs����&�&��!�=�=�!�>�>�?���(�(�*����-�-�d�g�g�6��
�!�&�$�'�'�4�:�:�>���1�1��1�1�1�f�m��$��\�4��?����	����C�(r,)r�NNNr)rJr,r$rBrBUsG���2�H��G�$�J��)�)��-�-��.�.���>B��
)r,rBc�p�eZdZdZdZgd�Zejejejd�Z
		dd�Zy)�cmd_add_recordakAdd a DNS record

       For each type data contents are as follows:
         A      ipv4_address_string
         AAAA   ipv6_address_string
         PTR    fqdn_string
         CNAME  fqdn_string
         NS     fqdn_string
         MX     "fqdn_string preference"
         SRV    "fqdn_string port priority weight"
         TXT    "'string1' 'string2' ..."
    �D%prog <server> <zone> <name> <A|AAAA|PTR|CNAME|NS|MX|SRV|TXT> <data>�rr2r?r,r>rjNc	
�6�|j�dvrtd|z��t|�}	t|	|�}
|j	�|_|j
|j
�|_t||j
|j�}tj�}|
|_tjd|�d|��tjd|�d|�d�i}
|jtj d||||d|
��|j"j%d	�y)
N��A�AAAA�PTR�CNAME�NS�MX�SRV�TXTz)Adding record of type %s is not supportedz5Zone does not exist; record could not be added. zone[�] name[z7Record already exists; record could not be added. zone[r7rr3zRecord added successfully
�r�rr�rfr~rrr r'r�DNS_RPC_RECORD_BUFrYrrH�$WERR_DNS_ERROR_RECORD_ALREADY_EXISTSr1r�rr�)r*rr2r?r,r>rkrmrlrerYr"�add_rec_bufr4s              r$r�zcmd_add_record.run�s���;�;�=� W�W��J�U�R�S�S�#�E�*�� ��d�3���(�(�*����-�-�d�g�g�6��
�!�&�$�'�'�4�:�:�>���2�2�4�����
�5�5���v�W�T�F�,��7�7���v�W�T�F�!�-�
��	�$�$�Y�%J�%J�%&���d�K��.6�	%�	8�	
�	�	���5�6r,r�r)rJr,r$rErErsG���V�H�<�J��)�)��-�-��.�.���>B�'+�7r,rEc�n�eZdZdZdZgd�Zejejejd�Z
	dd�Zy)�cmd_update_recorda�Update a DNS record

       For each type data contents are as follows:
         A      ipv4_address_string
         AAAA   ipv6_address_string
         PTR    fqdn_string
         CNAME  fqdn_string
         NS     fqdn_string
         MX     "fqdn_string preference"
         SOA    "fqdn_dns fqdn_email serial refresh retry expire minimumttl"
         SRV    "fqdn_string port priority weight"
         TXT    "'string1' 'string2' ..."
    zU%prog <server> <zone> <name> <A|AAAA|PTR|CNAME|NS|MX|SOA|SRV|TXT> <olddata> <newdata>)rr2r?r,�olddata�newdatarjNc

��|j�}|dvrtd|z��	|dk(rtt|�n|dk(rtt|�t
|�}t||�}|j�|_	|j|j�|_t||j|j�}
	t|
j|||||�}|std��|j"|_|j$|_|j&|_|j(|_t+j,�}||_t+j,�}||_t0j2d|�d	�i}|
j5t*j6d
||||||��|j8j;d�y#t
$r}
td|�d|
����d}
~
wwxYw#t$r}
t|
j �d�d}
~
wwxYw)
N)	rJrKrLrMrNrO�SOArPrQz+Updating record of type %s is not supportedrJrKz
bad data for z: r6r%z- does not exist; record could not be updated.rr3zRecord updated successfully
)r�rrrr	�OSErrorr�rfr~rrr r'rr"rr8rVrWrXr�rrTrYrrHr1r�rr�)r*rr2r?r,rYrZrkrmrlr#rerYr"�	rec_matchrV�del_rec_bufr4s                  r$r�zcmd_update_record.run�s������
���V�V��L�u�T�U�U�	?���|��'�7�+��&���(�G�,�$�E�*�� ��g�6���(�(�*����-�-�d�g�g�6��
�!�&�$�'�'�4�:�:�>��	2�(��):�):�F�D�)-�{�G�E�I�
��?�@�@� �'�'��� �)�)���$�1�1���#�/�/����2�2�4������2�2�4��#���
�5�5���v�J�K�
��
	�$�$�Y�%J�%J�%&�%+�%)�%)�%0�%0�.6�	%�	8�	
�	�	���7�8��[�	?���u�g�R��u�=�>�>��	?���	2�����'�T�1��	2�s/�+F7�=G�7	G�G�G�	G:�"G5�5G:r�r)rJr,r$rXrX�sC���g�H�J�J��)�)��-�-��.�.���8<�99r,rXc�l�eZdZdZdZgd�Zejejejd�Z
dd�Zy)�cmd_delete_recordanDelete a DNS record

       For each type data contents are as follows:
         A      ipv4_address_string
         AAAA   ipv6_address_string
         PTR    fqdn_string
         CNAME  fqdn_string
         NS     fqdn_string
         MX     "fqdn_string preference"
         SRV    "fqdn_string port priority weight"
         TXT    "'string1' 'string2' ..."
    rFrGrjNc	
�6�|j�dvrtd|z��t|�}	t|	|�}
|j	�|_|j
|j
�|_t||j
|j�}tj�}|
|_tjd|�d|��tjd|�d|�d�i}
|jtj d|||d||
��|j"j%d	�y)
NrIz+Deleting record of type %s is not supportedz7Zone does not exist; record could not be deleted. zone[rRz9Record already exists; record could not be deleted. zone[r7rr3zRecord deleted successfully
rS)r*rr2r?r,r>rkrmrlrerYr"r_r4s              r$r�zcmd_delete_record.runs���;�;�=� W�W��L�u�T�U�U�#�E�*�� ��d�3���(�(�*����-�-�d�g�g�6��
�!�&�$�'�'�4�:�:�>���2�2�4�����
�5�5���v�W�T�F�,��7�7���v�W�T�F�!�-�
��	�$�$�Y�%J�%J�%&�%+�%)�%)�%)�%0�.6�	%�	8�	
�	�	���7�8r,r�r)rJr,r$rara�s>���V�H�<�J��)�)��-�-��.�.��� 9r,rac��eZdZdZdZddgZejejejd�Z
edddd	�
�eddd
d	�
�gZ		dd�Z
y)�cmd_cleanup_recorda\Cleanup DNS records for a DNS host.

    example:

        samba-tool dns cleanup dc1 dc1.samdom.test.site -U USER%PASSWORD

    NOTE: This command in many cases will only mark the `dNSTombstoned` attr
    as `TRUE` on the DNS records. Querying will no longer return results but
    there may still be some placeholder entries in the database.
    z%prog <server> <dnshostname>r�dnshostnamerjz-vz	--verbosez
Be verboser�)rwr�z-qz--quietzBe quietNc���|j�}|j|�}	|j||��}
td|zt	�|	|��}tj||
|d��y)N)�verbose�quietr�r�T)�ignore_no_name)r~r�
get_loggerrrr�remove_dns_references)r*rrerkrmrlrgrhrr �loggerr�s            r$r�zcmd_cleanup_record.runTsg��
�
#�
#�
%���(�(��,��������>���+��.�#1�#3�"'�B�0��	�'�'��v�{�7;�	=r,)NNNFFr�rJr,r$rdrd9sq��	�.�H��M�*�J��)�)��-�-��.�.���	�t�[�|�L�I��t�Y�Z��E��M�
AE�38�=r,rdc��eZdZdZiZe�ed<e�ed<e�ed<e�ed<e	�ed<e
�ed<e�ed<e�ed	<e
�ed
<e�ed<e�ed<e�ed
<y)�cmd_dnsz%Domain Name Service (DNS) management.r�zoneoptionsr+�zonelist�
zonecreate�
zonedelete�query�	roothints�add�update�delete�cleanupN)rArBrCrD�subcommandsrhr�r�r�rr#r+rBrErXrardrJr,r$rnrncs���/��K� .� 0�K���!0�!2�K�
��*�n�K�
��*�n�K�
�� .� 0�K��� .� 0�K���$�;�K���,��K���'�)�K���-�/�K���-�/�K���/�1�K�	�r,rn)L�samba.getopt�getoptr��sambarrr�r�socketrrrr	r�r��	samba.ndrr
rr�rr
�samba.samdbr�
samba.authr�samba.netcmdrrrr�samba.dcerpcrr�samba.dnsserverrrrrr%r'rRrXr^rfrmrwr}r�r�r�r�r�r�r�r�rr,r3r9r\rcrfrhr�r�r�r�rr#r+rBrErXrardrnrJr,r$�<module>r�s���$����'���
��
�*�	�%��%���)�O�O�,�	�H�H�V���:�9�3�5�7�;�;�8���"$�
�Ea�P>V�BL�'�D�D0��1�W�1�@	6�M:�g�M:�`/�7�/�@L0�7�L0�^[A�W�[A�|A�W�A�DN)��N)�b)�G�)�:47�W�47�nR9��R9�j89��89�v'=��'=�T2�l�2r,

Zerion Mini Shell 1.0