AlkantarClanX12

Your IP : 18.191.165.192


Current Path : /proc/self/root/usr/lib/python3.6/site-packages/isc/__pycache__/
Upload File :
Current File : //proc/self/root/usr/lib/python3.6/site-packages/isc/__pycache__/dnskey.cpython-36.pyc

3

���f @�@sJddlZddlZddlZddlmZmZGdd�de�ZGdd�d�ZdS)�N)�Popen�PIPEcseZdZ�fdd�Z�ZS)�TimePastcstt|�jd|||f�dS)Nz'%s time for key %s (%d) is already past)�superr�__init__)�self�key�prop�value)�	__class__��/usr/lib/python3.6/dnskey.pyrszTimePast.__init__)�__name__�
__module__�__qualname__r�
__classcell__rr)rr
rsrc@s�eZdZdZdqZdrZdsZdtd!d"�Zd#d$�Zd%d&�Z	e
dud'd(��Zd)d*�Ze
d+d,��Ze
d-d.��Zdvd/d0�Ze
d1d2��Ze
d3d4��Ze
d5d6��Ze
d7d8��Zd9d:�Zd;d<�Zd=d>�Zd?d@�ZdAdB�ZdCdD�Zej�fdEdF�ZdGdH�Zej�fdIdJ�ZdKdL�Zej�fdMdN�Z dOdP�Z!ej�fdQdR�Z"dSdT�Z#ej�fdUdV�Z$dWdX�Z%ej�fdYdZ�Z&d[d\�Z'ej�fd]d^�Z(d_d`�Z)dadb�Z*dcdd�Z+dedf�Z,dgdh�Z-didj�Z.dwdkdl�Z/dxdmdn�Z0e
dodp��Z1dS)y�dnskeyztAn individual DNSSEC key.  Identified by path, name, algorithm, keyid.
    Contains a dictionary of metadata events.�Created�Publish�Activate�Inactive�Delete�Revoke�	DSPublish�SyncPublish�
SyncDeleteN�-P�-A�-I�-D�-R�-Psync�-Dsync�RSAMD5�DH�DSA�ECC�RSASHA1�NSEC3DSA�NSEC3RSASHA1�	RSASHA256�	RSASHA512�ECCGOST�ECDSAP256SHA256�ECDSAP384SHA384�ED25519�ED448cCs�t|t�r:t|�dkr:|pd|_|\}}}|j||||�|pLtjj|�pLd|_tjj|�}|j	d�\}}}|dd�}t
|�}t
|j	d�d�}|j||||�dS)N��.�+�r���)�
isinstance�tuple�len�_dir�	fromtuple�os�path�dirname�basename�split�int)rrZ	directory�keyttl�name�alg�keyidrrr
r&s

zdnskey.__init__cs�|jd�r|}|jd�}n|d}d|||f}|j|jr@tjpBd|d}|j|jr^tjp`d|d}||_||_t|�|_t|�|_	||_
t|d�}	x�|	D]z��ddkr�q��j�}
|
s�q�|
d	j
�dkr�d
}||_nd}|s�t|
d	�n||_t|
|�d	@d	k�rd|_q�d|_q�W|	j�t|d�}t�|_t�|_t�|_t�|_t�|_t�|_t�|_d|_x�|D]���j����sv�ddk�r��qv�fdd�dD�t��g}
tdd�|
D��}�d|�j�}�|d�jd�j�}||j|<�qvWx�tjD]�}d|j|<||jk�rn|j|j|�}||j|<|j |�|j|<|j!|�|j|<|j||j|<n(d|j|<d|j|<d|j|<d|j|<�qW|j�dS)Nr2z
K%s+%03d+%05d�z.keyz.private�rr�;r4�in�ch�hsr1�TFZrUz!#csg|]}�j|��qSr)�find)�.0�c)�linerr
�
<listcomp>lsz$dnskey.fromtuple.<locals>.<listcomp>z:= cSsg|]}|dkr|�qS)r4r5r)rM�posrrr
rPms)rHrIrJ)"�endswith�rstripr9r;�sep�keystrrBr@rCrD�fullname�openr?�lower�ttl�close�dictZmetadata�_changed�_delete�_times�_fmttime�_timestamps�	_original�_origttl�stripr8�min�lstripr�_PROPS�	parsetime�
formattime�
epochfromtime)rrBrCrDrArVrUZkey_fileZprivate_fileZkfp�tokensZseptokenZpfpZpunctuation�foundr
r	�tr)rOr
r:5sv












zdnskey.fromtuplecKsr|jdd�}g}d}|jdk	r0|dt|j�g7}xlttjtj�D]Z\}}|s@|j|r\q@d}||j	krx|j	|rxd}|r�dn|j
|}	|||	g7}d}q@W|�rn|d|jg||jg}
|s�t
ddj|
��y0t|
ttd	�}|j�\}}
|
�rtt|
���Wn8tk
�r:}ztd
|t|�f��WYdd}~XnXd|_x*tjD] }|j||j|<d|j|<�qJWdS)N�quietFTz-LZnonez-Kz# � )�stdout�stderrzunable to run %s: %s)�getrb�strrY�ziprrf�_OPTSr\r]r_r9rU�print�joinrr�communicate�	Exceptionr`ra)rZsettime_bin�kwargsrm�cmd�firstr	�opt�deleteZwhenZfullcmd�prorp�errr
�commit�s<
"z
dnskey.commitcKsL|jdd�}|dd|dt|�g}
|r0|
d|g7}
|r>|
jd�|rN|
d|g7}
|rb|
d	t|�g7}
|	r�tj|	�}|
d
tj|�g7}
|
r�tj|
�}|
dtj|
�g7}
|
j|�|s�tdd
j|
��t|
t	t	d�}|j
�\}}|r�tdt|���y"|j�dj
d�}t|||�}|Stk
�rF}ztdt|���WYdd}~XnXdS)NrmFz-qz-Kz-Lz-rz-fkz-az-bz-Pz-Az# rn)rorpzunable to generate key: r�asciiz!unable to parse generated key: %s)rqrr�appendr�
timefromepochrhrurvrrrwrx�
splitlines�decode)�cls�
keygen_bin�	randomdevZkeys_dirrBrCZkeysizerTrY�publish�activateryrm�
keygen_cmdrlr~rorprU�newkeyrrrr
�generate�s:



zdnskey.generatec
Ks�|jdd�}|j�s td|��|dd|jd|jg}|jrL|dt|j�g7}|r\|d|g7}|rp|d	t|�g7}|s�td
dj|��t	|t
t
d�}|j�\}}	|	r�td
|	��y&|j�dj
d�}
t|
|j|j�}|Std|��YnXdS)NrmFz'predecessor key %s has no inactive datez-qz-Kz-Sz-Lz-rz-iz# rn)rorpzunable to generate key: rr�z'unable to generate successor for key %s)rq�inactiverxr9rUrYrrrurvrrrwr�r�r)rr�r�Z
prepublishryrmr�r~rorprUr�rrr
�generate_successor�s,zdnskey.generate_successorcCs0d}|tttj��kr tj|}|r(|Sd|S)Nz%03d)�ranger8r�	_ALGNAMES)rCrBrrr
�algstr�s
z
dnskey.algstrcCs6|sdS|j�}ytjj|�Stk
r0dSXdS)N)�upperrr��index�
ValueError)rCrrr
�algnum�sz
dnskey.algnumcCs|j|p|j�S)N)r�rC)rrCrrr
�algnameszdnskey.algnamecCs
tj|�S)N)�timeZgmtime)�secsrrr
r�szdnskey.timefromepochcCstj|d�S)Nz%Y%m%d%H%M%S)r�Zstrptime)�stringrrr
rgszdnskey.parsetimecCs
tj|�S)N)�calendarZtimegm)rlrrr
riszdnskey.epochfromtimecCstjd|�S)Nz%Y%m%d%H%M%S)r�Zstrftime)rlrrr
rhszdnskey.formattimecKs�|jdd�}|j||krdS|j|dk	rR|j||krR|rRt|||j|��|dkr�|j|dkrldnd|j|<d|j|<d|j|<d|j|<d|j|<dS|j|�}||j|<||j|<|j	|�|j|<|j||j|kr�dnd|j|<dS)N�forceFT)
rqr`rarr\r]r^r_r�rh)rr	r��nowryr�rlrrr
�setmetas$






zdnskey.setmetacCs
|j|S)N)r^)rr	rrr
�gettime2szdnskey.gettimecCs
|j|S)N)r_)rr	rrr
�
getfmttime5szdnskey.getfmttimecCs
|j|S)N)r`)rr	rrr
�gettimestamp8szdnskey.gettimestampcCs
|jdS)Nr)r`)rrrr
�created;szdnskey.createdcCs
|jdS)Nr)r`)rrrr
�syncpublish>szdnskey.syncpublishcKs|jd||f|�dS)Nr)r�)rr�r�ryrrr
�setsyncpublishAszdnskey.setsyncpublishcCs
|jdS)Nr)r`)rrrr
r�Dszdnskey.publishcKs|jd||f|�dS)Nr)r�)rr�r�ryrrr
�
setpublishGszdnskey.setpublishcCs
|jdS)Nr)r`)rrrr
r�Jszdnskey.activatecKs|jd||f|�dS)Nr)r�)rr�r�ryrrr
�setactivateMszdnskey.setactivatecCs
|jdS)Nr)r`)rrrr
�revokePsz
dnskey.revokecKs|jd||f|�dS)Nr)r�)rr�r�ryrrr
�	setrevokeSszdnskey.setrevokecCs
|jdS)Nr)r`)rrrr
r�Vszdnskey.inactivecKs|jd||f|�dS)Nr)r�)rr�r�ryrrr
�setinactiveYszdnskey.setinactivecCs
|jdS)Nr)r`)rrrr
r}\sz
dnskey.deletecKs|jd||f|�dS)Nr)r�)rr�r�ryrrr
�	setdelete_szdnskey.setdeletecCs
|jdS)Nr)r`)rrrr
�
syncdeletebszdnskey.syncdeletecKs|jd||f|�dS)Nr)r�)rr�r�ryrrr
�
setsyncdeleteeszdnskey.setsyncdeletecCsR|dks|j|krdS|jdkr0|j|_||_n|j|krHd|_||_n||_dS)N)rYrb)rrYrrr
�setttlhs

z
dnskey.setttlcCs|jr
dSdS)N�KSK�ZSK)rT)rrrr
�keytypetszdnskey.keytypecCsd|j|j�|jfS)Nz
%s/%s/%05d)rBr�rD)rrrr
�__str__wszdnskey.__str__cCs"d|j|j�|j|jrdndfS)Nz%s/%s/%05d (%s)r�r�)rBr�rDrT)rrrr
�__repr__{szdnskey.__repr__cCs|j�p|j�p|j�S)N)r�r�r�)rrrr
�date�szdnskey.datecCs@|j|jkr|j|jkS|j|jkr0|j|jkS|j�|j�kS)N)rBrCr�)r�otherrrr
�__lt__�s
z
dnskey.__lt__cCs�dd�}|s|}ttj��}|j�}|j�}|s4dS|sT||krP|dt|��dS||krh||krhdS||kr�|dt|�tj|j�p�df�dS||kr�|dt|��dS|jdk	r�|||jkr�|d	t|�tj|j�p�df�dSdS)
Nc_sdS)Nr)�argsryrrr
�noop�sz!dnskey.check_prepub.<locals>.noopFzFWARNING: Key %s is scheduled for
	 activation but not for publication.Tz�WARNING: %s is scheduled to be
	 published and activated at the same time. This
	 could result in a coverage gap if the zone was
	 previously signed. Activation should be at least
	 %s after publication.zone DNSKEY TTLz0WARNING: Key %s is active before it is publishedz�WARNING: Key %s is activated too soon
	 after publication; this could result in coverage 
	 gaps due to resolver caches containing old data.
	 Activation should be at least %s after
	 publication.)r@r�r�r��reprr�durationrY)r�outputr�r��ar~rrr
�check_prepub�s<zdnskey.check_prepubcCs�dd�}|dkr|}|dkr"|j}|dkr>|dt|��d}tj�}|j�}|j�}|s^dS|s~||krz|dt|��dS||kr�||kr�dS||kr�|d	t|��dS|||kr�|d
t|�tj|�f�dSdS)
Nc_sdS)Nr)r�ryrrr
r��sz"dnskey.check_postpub.<locals>.noopz"WARNING: Key %s using default TTL.�<�FzEWARNING: Key %s is scheduled for
	 deletion but not for inactivation.Tz@WARNING: Key %s is scheduled for
	 deletion before inactivation.z�WARNING: Key %s scheduled for
	 deletion too soon after deactivation; this may 
	 result in coverage gaps due to resolver caches
	 containing old data.  Deletion should be at least
	 %s after inactivation.ii�Q)rYr�r�r}r�rr�)rr�Ztimespanr�r��d�irrr
�
check_postpub�s:zdnskey.check_postpubcCsz|sdSddddddg}g}xR|D]J}||d||d}}|dkr"|jd
||d|dkrbdndf�q"Wdj|�S) N�yearr�r�im�month��day�hour�minute�secondr4rz%d %s%s�srEz, ii�Q�3�)r�r�ii�Q��')r�r�i�Q)r�r��)r�r�)r�r�)r�r4)r�rv)r�Zunitsr�Zunit�vrrr
r��s
(zdnskey.duration)	rrrrrrrrr)	Nrrrrr Nr!r")Nr#r$r%r&r'r(r)r*Nr+Nr,r-r.r/r0)NN)NN)N)N)NN)2rrr�__doc__rfrtr�rr:r��classmethodr�r��staticmethodr�r�r�r�rgrirhr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r}r�r�r�r�r�r�r�r�r�r�r�r�rrrr
rsb
M%* 


1
-r)	r;r�r��
subprocessrrrxrrrrrr
�<module>s