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/direct.pyc
�
�c�`c@sddljZddlZddlZddlZddlmZddlmZddl	m
Z
mZmZddl
mZmZmZddlmZddlmZddlmZdd	lmZdd
lmZdefd��YZd
efd��YZdS(i����N(tconfig(tLastUpdatedOrderedDict(t	splitArgstjoinArgst
u2b_if_py2(t	IO_ObjecttIO_Object_ContentHandlertIO_Object_XMLGenerator(tlog(t	ipXtables(tebtables(terrors(t
FirewallErrortdirect_ContentHandlercBs#eZd�Zd�Zd�ZRS(cCstj||�t|_dS(N(Rt__init__tFalsetdirect(tselftitem((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pyR(scCs�tj|||�|jj||�|dkr\|jrPttjd��nt|_n�|dkr�|js�t	j
d�dS|d}|d}|d}|jjt|�t|�t|��n+|dkr�|js�t	j
d�dS|d}|dkr ttj
d|��n|d}|d}yt|d
�}Wn'tk
rqt	j
d|d
�dSXt|�t|�t|�|g|_nZ|dkr�|js�t	j
d�dS|d}t|�g|_nt	j
d|�dSdS(NRsMore than one direct tag.tchains$Parse Error: chain outside of directtipvttabletrules#Parse Error: rule outside of directtipv4tipv6tebs"'%s' not from {'ipv4'|'ipv6'|'eb'}tprioritys'Parse Error: %s is not a valid prioritytpassthroughs&Parse Error: command outside of directsUnknown XML element %s(RRR(RtstartElementRtparser_check_element_attrsRRRtPARSE_ERRORtTrueRterrort	add_chainRtINVALID_IPVtintt
ValueErrort_rulet_passthrough(RtnametattrsRRRR((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pyR,sT			



	

	


		

cCstj||�|dkr�|jrm|jjgt|j�D]}t|�^q>�|jj|j�n
t	j
d�d|_nz|dkr|jr�|jjgt|j�D]}t|�^q��|jj
|j�nt	j
dd�d|_ndS(NRs2Error: rule does not have any arguments, ignoring.Rs0Error: passthrough does not have any arguments, s	ignoring.(Rt
endElementt_elementR%tappendRRRtadd_ruleRR tNoneR&tadd_passthrough(RR'tx((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pyR)^s 	&
	&	(t__name__t
__module__RRR)(((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pyR
's		2tDirectcBs�eZdZdd(gfddddddgfgfdddgfgffZdZid)d6dd	d
gd
6dd	d
dgd6dgd
6ZiZd�Zd�Z	d�Z
d�Zd�Zd�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd �Zd!�Zd"�Zd#�Zd$�Zd%�Zd&�Z d'�Z!RS(*s Direct class tchainsttrulesitpassthroughss(a(sss)a(sssias)a(sas))RRRRRRRcCsDtt|�j�||_t�|_t�|_t�|_dS(N(tsuperR2RtfilenameRR3R5R6(RR8((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pyR�s
	cCsdS(N((RtconfR((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pyt
_check_config�scCsNg}g}xO|jD]D}x;|j|D],}|jtt|�t|g���q*WqW|j|�g}xe|jD]Z}xQ|j|D]B}|jt|d|d|d|dt|d�f��q�Wq{W|j|�g}xH|jD]=}x4|j|D]%}|jt|t|�f��q
Wq�W|j|�t|�S(Niii(R3R+ttupletlistR5R6(RtretR/tkeyRR((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pyt
export_config�s$.
%
'
cCs�|j�|j|�x�t|j�D]�\}\}}|dkrjx"||D]}|j|�qPWn|dkr�x"||D]}|j|�q�Wn|dkr'x"||D]}|j|�q�Wq'q'WdS(NR3R5R6(tcleanuptcheck_configt	enumeratetIMPORT_EXPORT_STRUCTURER!R,R.(RR9titelementtdummyR/((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pyt
import_config�s

"cCs+|jj�|jj�|jj�dS(N(R3tclearR5R6(R((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pyR@�s

cCsdGHx;|jD]0}d|d|ddj|j|�fGHqWdGHxe|jD]Z}d|d|d|dfGHx3|j|D]$\}}d	|d
j|�fGHq�WqRWdGHxD|jD]9}d|GHx'|j|D]}d
d
j|�GHq�Wq�WdS(NR3s  (%s, %s): %siit,R5s  (%s, %s, %s):is    (%d, ('%s'))s','R6s  %s:s
    ('%s')(R3tjoinR5R6(RR>Rtargs((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pytoutput�s 	cCs>dddg}||kr:ttjd||f��ndS(NRRRs'%s' not in '%s'(RRR"(RRtipvs((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pyt
_check_ipv�s	cCsf|j|�|dkr(tjj�ntjj�}||krbttjd||f��ndS(NRRs'%s' not in '%s'(sipv4sipv6(RNR	tBUILT_IN_CHAINStkeysR
RRt
INVALID_TABLE(RRRttables((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pyt_check_ipv_table�s
	cCs�|j||�||f}||jkr;g|j|<n||j|kre|j|j|�ntjd|||fd�dS(Ns(Chain '%s' for table '%s' with ipv '%s' salready in list, ignoring(RSR3R+Rtwarning(RRRRR>((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pyR!�s	cCs�|j||�||f}||jkr{||j|kr{|j|j|�t|j|�dkr�|j|=q�ntd|||f��dS(Nis4Chain '%s' with table '%s' with ipv '%s' not in list(RSR3tremovetlenR$(RRRRR>((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pytremove_chain�s"cCs<|j||�||f}||jko;||j|kS(N(RSR3(RRRRR>((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pytquery_chain�scCsP|j||�||f}||jkr6|j|Std||f��dS(Ns&No chains for table '%s' with ipv '%s'(RSR3R$(RRRR>((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pyt
get_chains�scCs|jS(N(R3(R((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pytget_all_chainsscCs�|j||�|||f}||jkrAt�|j|<n|t|�f}||j|krz||j||<n5tjddj|�||fd||fd�dS(Ns(Rule '%s' for table '%s' and chain '%s' s',swith ipv '%s' and priority %d salready in list, ignoring(RSR5RR;RRTRJ(RRRRRRKR>tvalue((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pyR,s'cCs�|j||�|||f}|t|�f}||jkr�||j|kr�|j||=t|j|�dkr�|j|=q�n0tddj|�||fd||f��dS(Nis(Rule '%s' for table '%s' and chain '%s' s',s)with ipv '%s' and priority %d not in list(RSR;R5RVR$RJ(RRRRRRKR>R[((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pytremove_rules"cCs�|j||�|||f}||jkr�x)|j|j�D]}|j||=qBWt|j|�dkr�|j|=q�ndS(Ni(RSR5RPRV(RRRRR>R[((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pytremove_rules"scCsQ|j||�|||f}|t|�f}||jkoP||j|kS(N(RSR;R5(RRRRRRKR>R[((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pyt
query_rule+scCs[|j||�|||f}||jkr9|j|Std||fd|��dS(Ns'No rules for table '%s' and chain '%s' s
with ipv '%s'(RSR5R$(RRRRR>((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pyt	get_rules1scCs|jS(N(R5(R((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pyt
get_all_rules:scCs~|j|�||jkr,g|j|<n||j|krV|j|j|�n$tjddj|�|fd�dS(NsPassthrough '%s' for ipv '%s's',salready in list, ignoring(RNR6R+RRTRJ(RRRK((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pyR.?s
	cCs�|j|�||jkrl||j|krl|j|j|�t|j|�dkr�|j|=q�n#tddj|�|fd��dS(NisPassthrough '%s' for ipv '%s's',snot in list(RNR6RURVR$RJ(RRRK((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pytremove_passthroughIs
"cCs-|j|�||jko,||j|kS(N(RNR6(RRRK((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pytquery_passthroughSs
cCs;|j|�||jkr'|j|Std|��dS(NsNo passthroughs for ipv '%s'(RNR6R$(RR((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pytget_passthroughsWs
cCs|jS(N(R6(R((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pytget_all_passthroughs^sc	Cs�|j�|jjd�s8ttjd|j��nt|�}tj�}|j	|�t
|jd��i}tjd�}|j
|�y|j|�Wn2tjk
r�}ttjd|j���nXWdQXdS(Ns.xmls'%s' is missing .xml suffixtrbsNot a valid file: %s(R@R8tendswithRRtINVALID_NAMER
tsaxtmake_parsertsetContentHandlertopentInputSourceR-t
setByteStreamtparsetSAXParseExceptiontINVALID_TYPEtgetException(Rthandlertparsertftsourcetmsg((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pytreadcs 
	

	c
Cs�tjj|j�reytj|jd|j�Wqetk
ra}td|j|f��qeXntjjtj	�s�tj
tj	d�ntj|jdddd�}t
|�}|j�|jdi�|jd	�xt|jD]i}|\}}xT|j|D]E}|jd
�|jdi|d6|d
6|d6�|jd	�qWq�Wx�|jD]�}|\}}}x�|j|D]�\}}	t|	�dkr�q�n|jd
�|jdi|d6|d
6|d6d|d6�|jtjjt|	���|jd�|jd	�q�WqbWx�|jD]�}x�|j|D]{}	t|	�dkrcqEn|jd
�|jdi|d6�|jtjjt|	���|jd�|jd	�qEWq1W|jd�|jd	�|j�|j�~dS(Ns%s.oldsBackup of '%s' failed: %si�tmodetwttencodingsUTF-8Rs
s  RRRiRs%dRR(tostpathtexistsR8tshutiltcopy2t	ExceptiontIOErrorRt
ETC_FIREWALLDtmkdirtioRkRt
startDocumentRtignorableWhitespaceR3t
simpleElementR5RVRhtsaxutilstescapeRR)R6tendDocumenttclose(
RRvRtRrR>RRRRRK((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pytwriteusZ 










(R4R4R4N("R0R1t__doc__RCtDBUS_SIGNATURER-tPARSER_REQUIRED_ELEMENT_ATTRStPARSER_OPTIONAL_ELEMENT_ATTRSRR:R?RGR@RLRNRSR!RWRXRYRZR,R\R]R^R_R`R.RaRbRcRdRwR�(((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pyR2usJ
																
							
	
				(txml.saxRhR{R�R~tfirewallRtfirewall.fw_typesRtfirewall.functionsRRRtfirewall.core.io.io_objectRRRtfirewall.core.loggerRt
firewall.coreR	R
Rtfirewall.errorsRR
R2(((s;/usr/lib/python2.7/site-packages/firewall/core/io/direct.pyt<module>sN

ZeroDay Forums Mini