HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //usr/lib/python3.9/site-packages/ipaclient/plugins/__pycache__/dns.cpython-39.pyc
a

}�f^H�@sddlmZddlZddlZddlZddlmZddlmZddl	m
Z
mZmZm
Z
mZddlmZddlmZmZddlmZdd	lmZmZdd
lmZddlmZejr�eZe�ZdZd
Z dZ!d/dd�Z"d0dd�Z#d1dd�Z$Gdd�de�Z%eddd�Gdd�de%��Z&eddd�Gdd�de%��Z'edd�Gdd �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�Gd-d.�d.e��Z/dS)2�)�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|��|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#�9/usr/lib/python3.9/site-packages/ipaclient/plugins/dns.py�__get_part_param4s�r%c
Cs�d}|dur0tt|���}|jj�||�d}i}z|jjd�|���}Wntyd|YS0t	|�
��D]H\}}t|��|jf}||j
vr�qr|r�||}	nd}	t
|||||	�qr|S)N�result�dns{}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,��


r1Fc
Cs�i}z|jjd�|���}Wnty4|YS0|��D]^}t|��|jf}||jvr`q>||vrjq>|j}|r||s|q>|j	fi|��}	t
|||||	�q>|S)Nr')r(r*r+rr,rrrr�get_defaultr%)
rr �kw�prompt_optionalr/r0r!rrr"r#r#r$�prompt_missing_partsZs"

r5cseZdZ�fdd�Z�ZS)�DNSZoneMethodOverridec#s6tt|���D]"}|jdkr*|�|jt�}|VqdS)NZidnsallowdynupdate)�superr6�get_optionsrZclone_retyper)�self�option��	__class__r#r$r8ts
z!DNSZoneMethodOverride.get_options)�__name__�
__module__�__qualname__r8�
__classcell__r#r#r;r$r6ssr6T)�override�no_failc@seZdZdS)�dnszone_addN�r=r>r?r#r#r#r$rC{srCc@seZdZdS)�dnszone_modNrDr#r#r#r$rE�srE)rBc@s0eZdZed�ZdZed�ed�fZdd�ZdS)r)zSplit DNS record to partsTr�valuecs��fdd�}d}t|�}|dvr*|d�}n�|dvr<|d�}n�|dvrN|d	�}n�|d
vr`|d�}nt|dvrp�f}nd|d
kr�t�d�}|���}	|	dur�tdd�|	��D��}n(|dkrԈ�dd�}
t|
�dkr�t|
�}t|d�S)Ncs ���}t|�|krdSt|�S�N)�split�len�tuple)�count�values�rFr#r$�
split_exactly�sz4dnsrecord_split_parts.execute.<locals>.split_exactlyr#)rrZCNAMEZDNAMErr�)ZAFSDBZKXr�)ZCERTZDLVZDSZSRVZTLSA�ZNAPTR�)ZA6ZTXTraR(?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"|]}|dur|��n|VqdSrG)�strip)�.0�xr#r#r$�	<genexpr>�sz0dnsrecord_split_parts.execute.<locals>.<genexpr>ZSSHFP�)r&)	r�re�compile�matchrJ�groupsrHrI�dict)r9rrF�args�optionsrNr&rZregex�mrLr#rMr$�execute�s6



�
�
zdnsrecord_split_parts.executeN)	r=r>r?r�__doc__ZNO_CLIrZ
takes_argsr`r#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.c
Cs,zZt|||j�i}t||dd�D](}t|j�}t|||dd�}|�|�q"|�|�WdStjynYn0zt	|d�}Wn6t
y�}ztjdt|�d��WYd}~n
d}~00zt	|d�}Wn8t
�y}ztjdt|�d��WYd}~n
d}~00|�
��rd�t�}	n |���r.d�t�}	n
d�t�}	|jj�td	��|jj�td
�|	�d}
|
�s|jj�td��}|du�r�dS|��}z,t|��}|j|}d|jv�r�t��WnLttf�y
d�d
d�|��D��}
|jj�td�|
�Y�qdYn0d}
�qdt||�}|�|�dS)NT)Z
skip_extraF)r4�idnsname)r�error�dnszoneidnsname�, 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|jvrt|j�VqdS)rgN)rr�flags�rT�pr#r#r$rVs

�z<dnsrecord_add.interactive_prompt_callback.<locals>.<genexpr>z3Invalid or unsupported type. Allowed values are: %s) r�
no_option_msgrrrr5�updater�OptionErrorr�	ExceptionZValidationErrorrZis_empty�join�_zone_top_record_typesZ
is_reverse�_rev_top_record_types�_top_record_types�Backend�textui�print_plainr�prompt�upperr	rrrh�
ValueErrorr,r1)r9r3Znew_kwZrrparamrr/rc�eZzonenameZcommon_types�okr�paramZ	all_typesr#r#r$�interactive_prompt_callback�sh�

�
((


�



�
z)dnsrecord_add.interactive_prompt_callbackN�r=r>r?rkr|r#r#r#r$rb�srbc@seZdZdZdd�ZdS)�
dnsrecord_modz0No options to modify a specific record provided.c	Cs�zt|||jd�Wntjy(Yn0dS|jjd|d|d�d}|jj�t	d��|jj�t	d��g}|D]p}z|j
|}Wnty�YqxYn0t|j
�}|s�qx|�||f�d�||j
�}|jj�d	|j|f�qx|jj�d
�|D]�\}}t||j
�}||j
D]�}	|�|	�|jjjt	d�t|j|	d�d
d�}
|
du�rt|||	d�}|	g||j
<|�|�|�r|jj�tddd�tt|�|d��q��qq�dS)NT�dnsrecord_showrercr&z-No option to modify specific record provided.�Current DNS record contents:
rf�%s: %s�zModify %(name)s '%(value)s'?�rrFF�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)rK�type)rrkrrmr(r
rsrtrurrr,rr�appendror�list�remove�prompt_yesnor\r1rlrrI)r9r3�
dns_recordZ
record_params�attrr{r�rec_type_contentZ
rec_values�	rec_valueZ	mod_valuer/r#r#r$r|sV


�
�

��z)dnsrecord_mod.interactive_prompt_callbackNr}r#r#r#r$r~
sr~c@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.c	Cs�|�dd�rdSzt|||j�Wntjy6Yn0dS|jjd|d|d�d}|jj�	t
d��|jjjt
d�dd	�}|d
ur�d
|d<dS|jj�	t
d��g}|D]h}z|j|}Wnt
y�Yq�Yn0t|j�s�q�|�|�d�||j�}|jj�	d
|j|f�q�|jj�	d�|D]h}g}||jD]>}	|jjjt
d�t|j|	d�dd	�}
|
d
u�r>|�|	��q>|�r,t|�||j<�q,dS)NZdel_allFrrercr&z-No option to delete specific record provided.zDelete all?r�Tr�rfr�r�zDelete %(name)s '%(value)s'?r�)�getrrkrrmr(r
rsrtrurr�rr,rrr�rorr\rJ)r9r3r�Zuser_del_allZpresent_paramsr�r{r�Zdeleted_valuesr�Zuser_del_valuer#r#r$r|LsN


��
z)dnsrecord_del.interactive_prompt_callbackN)r=r>r?rrkr|r#r#r#r$r�Gsr�c@seZdZdd�ZdS)�
dnsconfig_modcCs4|�dd�r0|jj�td��|jj�td��dS�N�idnsforwardersF�#Server will check DNS forwarder(s).�(This may take some time, please wait ...�r�rsrtrur�r9r3r#r#r$r|�s��z)dnsconfig_mod.interactive_prompt_callbackN�r=r>r?r|r#r#r#r$r��sr�c@seZdZdd�ZdS)�dnsforwardzone_addcCs`d|vr,|�d�dkr,|jj�td��|d<|�dd�r\|jj�td��|jj�td��dS)Nr�ZidnsforwardpolicyZnonez
DNS forwarderFr�r�)r�rsrtrvrrur�r#r#r$r|�s����z.dnsforwardzone_add.interactive_prompt_callbackNr�r#r#r#r$r��sr�c@seZdZdd�ZdS)�dnsforwardzone_modcCs4|�dd�r0|jj�td��|jj�td��dSr�r�r�r#r#r$r|�s��z.dnsforwardzone_mod.interactive_prompt_callbackNr�r#r#r#r$r��sr�csPeZdZdZedded�d�fZdd�Zdd	�Z�fd
d�Z	�fdd
�Z
�ZS)�dns_update_system_records)�ipa_records�location_recordszout?Zcliz,file to store DNS records in nsupdate format)Zinclude�doccCs\|jD]P}|�|�r|jd�||�dd�t||�D]}|j|dd�q8|�d�qdS)z?Print output in standard format common across the other pluginsz{}:rO)�indentrPr�N)�
record_groupsr�Zprint_indentedr+�sortedZ
print_line)r9rtr&�labels�key�valr#r#r$�_standard_output�s

z*dns_update_system_records._standard_outputc	Cs�dd�}dd�|��D�}t�}|jD]�}|�|�r&|�d�||��t||�D]J}||�}||vr�|�|�|�dj|d|dd	��|�d
�|��qT|�d�q&dS)
z%Store data in nsupdate format in filecSs|�dd�}|d|dfS)z9Get rname and rtype from textual representation of record� rQrrW)rH)�record�lr#r#r$�parse_rname_rtype�szJdns_update_system_records._nsupdate_output_file.<locals>.parse_rname_rtypecSsi|]}|jt|j��qSr#�rrrrir#r#r$�
<dictcomp>�szCdns_update_system_records._nsupdate_output_file.<locals>.<dictcomp>z; {}
zupdate delete {rname} {rtype}
rrO)ZrnameZrtypezupdate add {}
zsend

N)�
output_params�setr�r��writer+r��add)	r9Zout_fr&r�r�Zalready_removedr�r�Zr_name_typer#r#r$�_nsupdate_output_file�s"�


�z/dns_update_system_records._nsupdate_output_filec
s�|�dd�}|rt�|�tt|�j|i|��}|r�d|vr�z>t|d�� }|�||d�Wd�n1sn0YWn8tt	fy�}zt
jt|�d��WYd}~n
d}~00|S)N�outr&�w)�reason)
�poprZcheck_writable_filer7r��forward�openr��OSError�IOErrorrZ	FileErrorr)r9�keysr^r��res�fryr;r#r$r��s
2&z!dns_update_system_records.forwardc	s�t�|�}|�di�}|�dd�|�dd�tt|�j||g|�Ri|��dd�|��D�}|�di�}|�|||�t	|d�S)Nr&r�r�cSsi|]}|jt|j��qSr#r�rir#r#r$r��sz<dns_update_system_records.output_for_cli.<locals>.<dictcomp>rF)
�copy�deepcopyr�r�r7r��output_for_clir�r��int)	r9rt�outputr]r^Zoutput_superZ	super_resr�r&r;r#r$r��s"

����z(dns_update_system_records.output_for_cli)r=r>r?r�rrZ
takes_optionsr�r�r�r�r@r#r#r;r$r��s��	r�)N)N)F)0Z
__future__rZsixr�rXZipaclient.frontendrZipalibrZ
ipalib.dnsrrrrr	Zipalib.frontendr
Zipalib.parametersrrZipalib.plugabler
rrrZipapython.dnsutilrZPY3�strr�registerrrrqrpr%r1r5r6rCrEr)rbr~r�r�r�r�r�r#r#r#r$�<module>sT





8
L
9
8