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: //usr/lib/python3.6/site-packages/ipaclient/plugins/__pycache__/dns.cpython-36.opt-1.pyc
3

�d[e^H�@sddlmZddlZddlZddlZddlmZddlmZddl	m
Z
mZmZm
Z
mZddlmZddlmZmZddlmZdd	lmZmZdd
lmZddlmZejr�eZe�Zd2Zd3Z d4Z!d5dd�Z"d6dd�Z#d7dd�Z$Gdd�de�Z%eddd�Gdd�de%��Z&eddd�Gdd �d e%��Z'edd!�Gd"d#�d#e��Z(eddd�Gd$d%�d%e��Z)eddd�Gd&d'�d'e��Z*eddd�Gd(d)�d)e��Z+eddd�Gd*d+�d+e��Z,eddd�Gd,d-�d-e��Z-eddd�Gd.d/�d/e��Z.eddd�Gd0d1�d1e��Z/dS)8�)�print_functionN)�MethodOverride)�errors)�get_record_rrtype�has_cli_options�iterate_rrparams_by_parts�part_name_format�record_name_format)�Command)�Bool�Str)�Registry)�_�ngettext)�util)�DNSName�A�AAAA�PTR�NS�MX�LOCcCsBt|j�|jf}t|j|j�}|j}|j|||d�||<dS)N)�optional�label)r�lower�name�unicode�paramsr�requiredZprompt_param)�rrtype�cmd�partZ	output_kw�defaultrrr�r#�/usr/lib/python3.6/dns.py�__get_part_param4sr%c
Cs�d}|dk	r0tt|j��}|jjj||�d}i}y|jjdj|j��}Wntk
rb|SXxXt	|j
��D]H\}}t|j�|jf}||j
kr�qr|r�||}	nd}	t
|||||	�qrW|S)N�resultzdns{}record)r	rr�apir
�dnsrecord_split_parts�Object�format�KeyError�	enumeraterrrr%)
rr �mod_dnsvalueZ	mod_partsr�user_options�rrobjZpart_idr!r"r#r#r$�prompt_parts>s&

r0Fc
Cs�i}y|jjdj|j��}Wntk
r2|SXxh|j�D]\}t|j�|jf}||jkr`q>||krjq>|j}|r~|r~q>|j	f|�}	t
|||||	�q>W|S)Nzdns{}record)r'r)r*rr+rrrrZget_defaultr%)
rr �kw�prompt_optionalr.r/r!rrr"r#r#r$�prompt_missing_partsZs"

r3cseZdZ�fdd�Z�ZS)�DNSZoneMethodOverridec#s:x4tt|�j�D]"}|jdkr,|j|jt�}|VqWdS)NZidnsallowdynupdate)�superr4�get_optionsrZclone_retyper)�selfZoption)�	__class__r#r$r6ts
z!DNSZoneMethodOverride.get_options)�__name__�
__module__�__qualname__r6�
__classcell__r#r#)r8r$r4ssr4T)�override�no_failc@seZdZdS)�dnszone_addN)r9r:r;r#r#r#r$r?{sr?c@seZdZdS)�dnszone_modN)r9r:r;r#r#r#r$r@�sr@)r>c@s0eZdZed�ZdZed�ed�fZdd�ZdS)r(zSplit DNS record to partsTr�valuecs��fdd�}f}t|�}|dkr*|d	�}n�|d kr<|d
�}n�|d!krN|d�}n�|dkr`|d�}nt|d"krp�f}nd|dkr�tjd�}|j��}	|	dk	r�tdd�|	j�D��}n(|dkrԈjdd
�}
t|
�dkr�t|
�}t|d�S)#Ncs �j�}t|�|krdSt|�S)N)�split�len�tuple)�count�values)rAr#r$�
split_exactly�sz4dnsrecord_split_parts.execute.<locals>.split_exactlyrr�CNAME�DNAMErr��AFSDB�KXr��CERT�DLV�DS�SRV�TLSA�ZNAPTR��A6�TXTraR(?P<d1>\d{1,2}\s+)(?:(?P<m1>\d{1,2}\s+)(?P<s1>\d{1,2}(?:\.\d{1,3})?\s+)?)?(?P<dir1>[NS])\s+(?P<d2>\d{1,3}\s+)(?:(?P<m2>\d{1,2}\s+)(?P<s2>\d{1,2}(?:\.\d{1,3})?\s+)?)?(?P<dir2>[WE])\s+(?P<alt>-?\d{1,8}(?:\.\d{1,2})?)m?(?:\s+(?P<siz>\d{1,8}(?:\.\d{1,2})?)m?(?:\s+(?P<hp>\d{1,8}(?:\.\d{1,2})?)m?(?:\s+(?P<vp>\d{1,8}(?:\.\d{1,2})?)m?\s*)?)?)?$css"|]}|dk	r|j�n|VqdS)N)�strip)�.0�xr#r#r$�	<genexpr>�sz0dnsrecord_split_parts.execute.<locals>.<genexpr>ZSSHFP�)r&)rrrHrIrr)rKrLr)rNrOrPrQrR)rUrV)	r�re�compile�matchrD�groupsrBrC�dict)r7rrA�args�optionsrGr&rZregex�mrFr#)rAr$�execute�s2




zdnsrecord_split_parts.executeN)	r9r:r;r�__doc__ZNO_CLIrZ
takes_argsrdr#r#r#r$r(�s

r(c@seZdZdZdd�ZdS)�
dnsrecord_addzkNo options to add a specific record provided.
Command help may be consulted for all supported record types.c0Cs0y\t|||j�i}x:t||dd�D](}t|j�}t|||dd�}|j|�q$W|j|�dStjk
rrYnXyt	|d�}Wn4t
k
r�}ztjdt|�d��WYdd}~XnXyt	|d�}Wn6t
k
�r}ztjdt|�d��WYdd}~XnX|j
��rdjt�}	n |j��r.djt�}	n
djt�}	|jjjtd	��|jjjtd
�|	�d}
x�|
�s|jjjtd��}|dk�r�dS|j�}y,t|j�}|j|}d|jk�r�t��WnLttfk
�rdjd
d�|j�D��}
|jjjtd�|
��wfYnXd}
�qfWt||�}|j|�dS)NT)Z
skip_extraF)r2�idnsname)r�error�dnszoneidnsnamez, z7Please choose a type of DNS resource record to be addedz4The most common types for this type of zone are: %s
zDNS resource record type�	no_optioncss,|]$}t|j�rd|jkrt|j�VqdS)rjN)rr�flags)rX�pr#r#r$rZs
z<dnsrecord_add.interactive_prompt_callback.<locals>.<genexpr>z3Invalid or unsupported type. Allowed values are: %s) r�
no_option_msgrrrr3�updater�OptionErrorr�	ExceptionZValidationErrorrZis_empty�join�_zone_top_record_typesZ
is_reverse�_rev_top_record_types�_top_record_types�Backend�textui�print_plainr�prompt�upperr	rrrk�
ValueErrorr+r0)r7r1Znew_kwZrrparamrr.rg�eZzonenameZcommon_types�okr�paramZ	all_typesr#r#r$�interactive_prompt_callback�s`

$$









z)dnsrecord_add.interactive_prompt_callbackN)r9r:r;rmr~r#r#r#r$rf�srfc@seZdZdZdd�ZdS)�
dnsrecord_modz0No options to modify a specific record provided.cCs�yt|||jd�Wntjk
r*YnXdS|jjd|d|d�d}|jjjt	d��|jjjt	d��g}xx|D]p}y|j
|}Wntk
r�w|YnXt|j
�}|s�q||j||f�dj||j
�}|jjjd	|j|f�q|W|jjjd
�x�|D]�\}}t||j
�}x�||j
D]�}	|j|	�|jjjt	d�t|j|	d�d
d�}
|
dk�r&t|||	d�}|	g||j
<|j|�|�r&|jjjtddd�tt|�|d��P�q&W�qWdS)NT�dnsrecord_showrirgr&z-No option to modify specific record provided.zCurrent DNS record contents:
z, z%s: %s�zModify %(name)s '%(value)s'?)rrAF)r")r-zb%(count)d %(type)s record skipped. Only one value per DNS record type can be modified at one time.zc%(count)d %(type)s records skipped. Only one value per DNS record type can be modified at one time.r)rE�type)rrmrror'r
rurvrwrrr+rr�appendrqr�list�remove�prompt_yesnor`r0rnrrC)r7r1�
dns_recordZ
record_params�attrr}r�rec_type_contentZ
rec_values�	rec_valueZ	mod_valuer.r#r#r$r~sL





z)dnsrecord_mod.interactive_prompt_callbackN)r9r:r;rmr~r#r#r#r$r
src@seZdZed�Zdd�ZdS)�
dnsrecord_delz�Neither --del-all nor options to delete a specific record provided.
Command help may be consulted for all supported record types.cCs�|jdd�rdSyt|||j�Wntjk
r8YnXdS|jjd|d|d�d}|jjj	t
d��|jjjt
d�dd	�}|d
kr�d
|d<dS|jjj	t
d��g}xp|D]h}y|j|}Wnt
k
r�w�YnXt|j�s�q�|j|�dj||j�}|jjj	d
|j|f�q�W|jjj	d�xt|D]l}g}xL||jD]>}	|jjjt
d�t|j|	d�dd	�}
|
d
k�rH|j|	��qHW|�r4t|�||j<�q4WdS)NZdel_allFr�rirgr&z-No option to delete specific record provided.zDelete all?)r"TzCurrent DNS record contents:
z, z%s: %sr�zDelete %(name)s '%(value)s'?)rrA)�getrrmrror'r
rurvrwrr�rr+rrr�rqrr`rD)r7r1r�Zuser_del_allZpresent_paramsr�r}r�Zdeleted_valuesr�Zuser_del_valuer#r#r$r~LsH




z)dnsrecord_del.interactive_prompt_callbackN)r9r:r;rrmr~r#r#r#r$r�Gsr�c@seZdZdd�ZdS)�
dnsconfig_modcCs4|jdd�r0|jjjtd��|jjjtd��dS)N�idnsforwardersFz#Server will check DNS forwarder(s).z(This may take some time, please wait ...)r�rurvrwr)r7r1r#r#r$r~�s

z)dnsconfig_mod.interactive_prompt_callbackN)r9r:r;r~r#r#r#r$r��sr�c@seZdZdd�ZdS)�dnsforwardzone_addcCs`d|kr,|jd�dkr,|jjjtd��|d<|jdd�r\|jjjtd��|jjjtd��dS)Nr�ZidnsforwardpolicyZnonez
DNS forwarderFz#Server will check DNS forwarder(s).z(This may take some time, please wait ...)r�rurvrxrrw)r7r1r#r#r$r~�s
z.dnsforwardzone_add.interactive_prompt_callbackN)r9r:r;r~r#r#r#r$r��sr�c@seZdZdd�ZdS)�dnsforwardzone_modcCs4|jdd�r0|jjjtd��|jjjtd��dS)Nr�Fz#Server will check DNS forwarder(s).z(This may take some time, please wait ...)r�rurvrwr)r7r1r#r#r$r~�s

z.dnsforwardzone_mod.interactive_prompt_callbackN)r9r:r;r~r#r#r#r$r��sr�csPeZdZdZedded�d�fZdd�Zd	d
�Z�fdd�Z	�fd
d�Z
�ZS)�dns_update_system_records�ipa_records�location_recordszout?Zcliz,file to store DNS records in nsupdate format)�include�doccCsdx^|jD]T}|j|�r|jdj||�dd�x"t||�D]}|j|dd�q<W|jd�qWdS)z?Print output in standard format common across the other pluginsz{}:rJ)�indentrMr�N)�
record_groupsr�Zprint_indentedr*�sortedZ
print_line)r7rvr&�labels�key�valr#r#r$�_standard_output�s
z*dns_update_system_records._standard_outputc	Cs�dd�}dd�|j�D�}t�}x�|jD]�}|j|�r(|jdj||��xZt||�D]J}||�}||kr�|j|�|jdj|d|dd	��|jd
j|��qXW|jd�q(WdS)
z%Store data in nsupdate format in filecSs|jdd�}|d|dfS)z9Get rname and rtype from textual representation of record� rSrr[)rB)�record�lr#r#r$�parse_rname_rtype�szJdns_update_system_records._nsupdate_output_file.<locals>.parse_rname_rtypecSsi|]}t|j�|j�qSr#)rrr)rXrlr#r#r$�
<dictcomp>�szCdns_update_system_records._nsupdate_output_file.<locals>.<dictcomp>z; {}
zupdate delete {rname} {rtype}
rrJ)ZrnameZrtypezupdate add {}
zsend

N)�
output_params�setr�r��writer*r��add)	r7Zout_fr&r�r�Zalready_removedr�r�Zr_name_typer#r#r$�_nsupdate_output_file�s

z/dns_update_system_records._nsupdate_output_filecs�|jdd�}|rtj|�tt|�j||�}|r�d|kr�y*t|d��}|j||d�WdQRXWn6tt	fk
r�}zt
jt|�d��WYdd}~XnX|S)N�outr&�w)�reason)
�poprZcheck_writable_filer5r��forward�openr��OSError�IOErrorrZ	FileErrorr)r7�keysrbr��res�fr{)r8r#r$r��s
"z!dns_update_system_records.forwardc	s�tj|�}|jdi�}|jdd�|jdd�tt|�j||f|�|�dd�|j�D�}|jdi�}|j|||�t	|d�S)Nr&r�r�cSsi|]}t|j�|j�qSr#)rrr)rXrlr#r#r$r��sz<dns_update_system_records.output_for_cli.<locals>.<dictcomp>rA)
�copy�deepcopyr�r�r5r��output_for_clir�r��int)	r7rv�outputrarbZoutput_superZ	super_resr�r&)r8r#r$r��s

z(dns_update_system_records.output_for_cli)r�r�)r9r:r;r�rrZ
takes_optionsr�r�r�r�r<r#r#)r8r$r��s	r�)rr)r)rrr)N)N)F)0Z
__future__rZsixr�r\Zipaclient.frontendrZipalibrZ
ipalib.dnsrrrrr	Zipalib.frontendr
Zipalib.parametersrrZipalib.plugabler
rrrZipapython.dnsutilrZPY3�strr�registerrtrsrrr%r0r3r4r?r@r(rfrr�r�r�r�r�r#r#r#r$�<module>sT



8L98