Sh3ll
OdayForums


Server : Apache
System : Linux server1.cgrithy.com 3.10.0-1160.95.1.el7.x86_64 #1 SMP Mon Jul 24 13:59:37 UTC 2023 x86_64
User : nobody ( 99)
PHP Version : 8.1.23
Disable Function : NONE
Directory :  /usr/lib/python2.7/site-packages/firewall/core/io/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/lib/python2.7/site-packages/firewall/core/io/ipset.pyo
�
�c�`c@sgdZdddgZddljZddlZddlZddlZddlmZddl	m
Z
mZmZm
Z
mZmZmZmZmZddlmZmZmZmZdd	lmZmZdd
lmZmZmZmZddl m!Z!ddlm"Z"dd
l#m$Z$defd��YZ%defd��YZ&d�Z'e(d�Z)dS(s$ipset io XML handler, reader, writertIPSettipset_readertipset_writeri����N(tconfig(	tcheckIPtcheckIP6tcheckIPnMaskt
checkIP6nMaskt
u2b_if_py2t	check_mact
check_porttcheckInterfacet
checkProtocol(tPY2t	IO_ObjecttIO_Object_ContentHandlertIO_Object_XMLGenerator(tIPSET_TYPEStIPSET_CREATE_OPTIONS(tcheck_icmp_nametcheck_icmp_typetcheck_icmpv6_nametcheck_icmpv6_type(tlog(terrors(t
FirewallErrorcBs�eZdddddidd6fddgffZdZdd	d
dgZidd6dd6dgd6d
gd6dd6Zidgd6dgd6Zd�Zd�Z	d�Z
ed��Zd�Z
d�ZRS(tversionttshorttdescriptionttypetoptionstentriess
(ssssa{ss}as)t_t-t:t.tipsettnametoptiontentrytvaluecCsVtt|�j�d|_d|_d|_d|_g|_i|_t	|_
dS(NR(tsuperRt__init__RRRRR RtFalsetapplied(tself((s:/usr/lib/python2.7/site-packages/firewall/core/io/ipset.pyR+Cs						cCsEd|_d|_d|_d|_|j2|jj�t|_dS(NR(	RRRRR RtclearR,R-(R.((s:/usr/lib/python2.7/site-packages/firewall/core/io/ipset.pytcleanupMs				
cCs�t|j�|_t|j�|_t|j�|_t|j�|_d�|jj�D�|_g|jD]}t|�^qn|_dS(s� HACK. I haven't been able to make sax parser return
            strings encoded (because of python 2) instead of in unicode.
            Get rid of it once we throw out python 2 support.cSs+i|]!\}}t|�t|��qS((R(t.0tktv((s:/usr/lib/python2.7/site-packages/firewall/core/io/ipset.pys
<dictcomp>^s	N(RRRRRRtitemsR (R.te((s:/usr/lib/python2.7/site-packages/firewall/core/io/ipset.pytencode_stringsVsc
Cs�d}d|kr.|ddkr.d}q.n|jd�sVttjd|��n|djd�}|jd�}t|�t|�ks�t|�d	kr�ttjd
||f��nx'tt|��D]}||}||}|dkr�d|kr�|dkr�|d	kr@ttjd
|||f��n|jd�}	t|	�dkr�ttjd||||f��nx�|	D]]}
|dkr�t|
�s�|dkr�t	|
�r�ttjd|
|||f��q�q�Wq�|dkrL|dkr.ttjd||||f��n|dkrCt
}qRt}nt	}||�s�ttjd||||f��q�q�|dkrbd|kr�|jd�}	t|	�dkr�ttjd||||f��n|dkrt|	d�s|dkrGt	|	d�rGttjd|	d|||f��n|dkrdt
|	d	�s�|dkr_t|	d	�r_ttjd|	d	|||f��q_q�|jd�r|dko�|dko�|dksttjd||||f��qn|dkr!t
|�s:|dkr�t|�r�ttjd||||f��q�q�|dkr�t
|�s�|dkr�ttjd||f��q�q�|dkr�d|kr{|jd�}	t|	�dkr�ttjd|��n|	ddkr~|dkr6ttjd||f��nt|	d	�rxt|	d	�rxttjd|	d	|f��qxq�|	dd1kr|dkr�ttjd||f��nt|	d	�rxt|	d	�rxttjd!|	d	|f��qxq�|	dd2krEt|	d�rEttjd&|	d|f��q�t|	d	�s�ttjd'|	d	|f��q�q�t|�s�ttjd(||f��q�q�|d)kr�|jd*�r
yt|d+�}WqJtk
rttjd,||f��qJXn@yt|�}Wn-tk
rIttjd,||f��nX|dksb|d-kr�ttjd,||f��q�q�|d.kr�t|�s�t|�d/kr�ttjd0||f��q�q�ttjd|��q�WdS(3Ntipv4tfamilytinet6tipv6shash:sipset type '%s' not usableit,is)entry '%s' does not match ipset type '%s'tipR"s invalid address '%s' in '%s'[%d]is.invalid address range '%s' in '%s' for %s (%s)s(invalid address '%s' in '%s' for %s (%s)s0.0.0.0itnets/0shash:net,ifacetmacs00:00:00:00:00:00s invalid mac address '%s' in '%s'tportR#sinvalid port '%s'ticmps(invalid protocol for family '%s' in '%s'sinvalid icmp type '%s' in '%s'ticmpv6s	ipv6-icmps invalid icmpv6 type '%s' in '%s'ttcptsctptudptudplitesinvalid protocol '%s' in '%s'sinvalid port '%s'in '%s'sinvalid port '%s' in '%s'tmarkt0xisinvalid mark '%s' in '%s'I����tifaceisinvalid interface '%s' in '%s'(RAs	ipv6-icmp(RBRCRDRE(t
startswithRRt
INVALID_IPSETtsplittlent
INVALID_ENTRYtrangeRRRRtendswithR	RRRRRR
tintt
ValueErrorR(
R(Rt
ipset_typeR8tflagsR4titflagtitemtsplitst_splittip_checktint_val((s:/usr/lib/python2.7/site-packages/firewall/core/io/ipset.pytcheck_entrybs@	*


 		 


	cCs>|dkr4|tkr4ttjd|��q4n|dkr:x�|j�D]�}|tkrxttjd|��n|dkr�yt||�}Wn1tk
r�ttj	d|||f��nX|d	kr3ttj	d
|||f��q3qM|dkrM||dkrMttj
||��qMqMWndS(NRs'%s' is not valid ipset typeRsipset invalid option '%s'ttimeoutthashsizetmaxelems)Option '%s': Value '%s' is not an integeris#Option '%s': Value '%s' is negativeR8tinetR9(R\R]R^(R_sinet6(RRRtINVALID_TYPEtkeysRRJRPRQt
INVALID_VALUEtINVALID_FAMILY(R.RRVtkeyt	int_value((s:/usr/lib/python2.7/site-packages/firewall/core/io/ipset.pyt
_check_configs2		
cCs�d|dkrO|dddkrOt|d�dkrOttj��qOnx-|dD]!}tj||d|d�qZWtt|�j|�dS(NR\it0iii(RLRRtIPSET_WITH_TIMEOUTRR[R*t
import_config(R.RR(((s:/usr/lib/python2.7/site-packages/firewall/core/io/ipset.pyRi3s$(sversionR(sshortR(sdescriptionR(stypeRN(t__name__t
__module__tIMPORT_EXPORT_STRUCTUREtDBUS_SIGNATUREtADDITIONAL_ALNUM_CHARStNonetPARSER_REQUIRED_ELEMENT_ATTRStPARSER_OPTIONAL_ELEMENT_ATTRSR+R0R6tstaticmethodR[RfRi(((s:/usr/lib/python2.7/site-packages/firewall/core/io/ipset.pyR,s.




	
			�	tipset_ContentHandlercBseZd�Zd�ZRS(cCs�tj|||�|jj||�|dkr�d|kr~|dtkrkttjd|d��n|d|j_nd|kr�|d|j_	q�n�|dkr�n�|dkr�n�|dkr�d}d	|kr�|d	}n|d
dkrttj
d|d
��n|jjdkra|d
dkrattj
d|d
|jjf��n|d
dkr�|r�ttj
d|d
��n|d
dkryt|�}Wn1tk
r�ttj
d|d
|f��nX|dkrttj
d|d
|f��qn|d
dkrL|dkrLttj|��n|d
|jjkry||jj|d
<q�tjd|d
�ndS(NR%Rs%sRRRR'RR)R&R8R\R]R^sUnknown option '%s'shash:macs%Unsupported option '%s' for type '%s's&Missing mandatory value of option '%s's)Option '%s': Value '%s' is not an integeris#Option '%s': Value '%s' is negativeR_R9s Option %s already set, ignoring.(sfamilystimeoutshashsizesmaxelem(sfamily(sfamilystimeoutshashsizesmaxelem(stimeoutshashsizesmaxelem(sinetsinet6(RtstartElementRVtparser_check_element_attrsRRRR`RRtINVALID_OPTIONRPRQRbRcRRtwarning(R.R&tattrsR)Re((s:/usr/lib/python2.7/site-packages/firewall/core/io/ipset.pyRt>sd
	"
cCs9tj||�|dkr5|jjj|j�ndS(NR((Rt
endElementRVR tappendt_element(R.R&((s:/usr/lib/python2.7/site-packages/firewall/core/io/ipset.pyRyus(RjRkRtRy(((s:/usr/lib/python2.7/site-packages/firewall/core/io/ipset.pyRs=s	7c	Cs�t�}|jd�s1ttjd|��n|d |_|j|j�||_||_|j	t
j�rxtnt
|_|j|_t|�}tj�}|j|�d||f}t|d��i}tjd�}|j|�y|j|�Wn2tjk
r5}ttjd|j���nXWdQX~~d|jkr�|jddkr�t|j�d	kr�tj d
|j�|j2nd	}	t!�}
x�|	t|j�kru|j|	|
kr�tj d|j|	�|jj"|	�q�y$|j#|j|	|j|j$�Wn3tk
rS}tj d|�|jj"|	�q�X|
j%|j|	�|	d
7}	q�W~
t&r�|j'�n|S(Ns.xmls'%s' is missing .xml suffixi����s%s/%strbsnot a valid ipset file: %sR\Rgis6ipset '%s': timeout option is set, entries are ignoredsEntry %s already set, ignoring.s
%s, ignoring.i((RRORRtINVALID_NAMER&t
check_nametfilenametpathRIRt
ETC_FIREWALLDR,tTruetbuiltintdefaultRstsaxtmake_parsertsetContentHandlertopentInputSourceRot
setByteStreamtparsetSAXParseExceptionRJtgetExceptionRRLR RRwtsettpopR[RtaddR
R6(RR�R%thandlertparserR&tftsourcetmsgRTtentries_setR5((s:/usr/lib/python2.7/site-packages/firewall/core/io/ipset.pyRzs^		
		!

	"	

	$
c
Csg|r|n|j}|jr4d||jf}nd||jf}tjj|�r�ytj|d|�Wq�tk
r�}tj	d||�q�Xntjj
|�}|jtj
�rtjj|�rtjjtj
�s�tjtj
d�ntj|d�ntj|dddd	�}t|�}|j�i|jd
6}|jr{|jdkr{|j|d<n|jd
|�|jd�|jr�|jdkr�|jd�|jdi�|j|j�|jd�|jd�n|jr\|jdkr\|jd�|jdi�|j|j�|jd�|jd�nx{|jj�D]j\}	}
|jd�|
dkr�|jdi|	d6|
d6�n|jdi|	d6�|jd�qlWxU|jD]J}|jd�|jdi�|j|�|jd�|jd�q�W|jd
�|jd�|j�|j �~dS(Ns%s/%ss	%s/%s.xmls%s.oldsBackup of file '%s' failed: %si�tmodetwttencodingsUTF-8RRRR%s
s  RRR'R&R)R((!R�RR&tostexiststshutiltcopy2t	ExceptionRterrortdirnameRIRR�tmkdirtioR�Rt
startDocumentRRRttignorableWhitespaceRt
charactersRyRRR4t
simpleElementR tendDocumenttclose(R%R�t_pathR&R�tdirpathR�R�RxRdR)R(((s:/usr/lib/python2.7/site-packages/firewall/core/io/ipset.pyR�sf	%






!






(*t__doc__t__all__txml.saxR�R�R�R�tfirewallRtfirewall.functionsRRRRRR	R
RRtfirewall.core.io.io_objectR
RRRtfirewall.core.ipsetRRtfirewall.core.icmpRRRRtfirewall.core.loggerRRtfirewall.errorsRRRsRRoR(((s:/usr/lib/python2.7/site-packages/firewall/core/io/ipset.pyt<module>s$@""�=	5

ZeroDay Forums Mini