MINI MINI MANI MO

Path : /lib/python2.7/site-packages/firewall/core/io/
File Upload :
Current File : //lib/python2.7/site-packages/firewall/core/io/io_object.pyo

ó
dߨ[c@sadZddddddddgZd	d
ljZd	d
ljjZd	d
lZd	d
lZd	dlm	Z	d	dl
mZd	d
lmZd	dl
mZejdkZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdejjfd„ƒYZdejfd„ƒYZd„Zd„Zd„Zd„Zd
S(s5Generic io_object handler, io specific check methods.tPY2t	IO_ObjecttIO_Object_ContentHandlertIO_Object_XMLGeneratort
check_porttcheck_tcpudptcheck_protocolt
check_addressiÿÿÿÿN(t	functions(tb2u(terrors(t
FirewallErrort3cBsteZdZd
ZdZgZiZiZd„Zd„Z	d„Z
d„Zd„Zd„Z
d„Zd	„ZRS(s; Abstract IO_Object as base for icmptype, service and zone s()cCs1d|_d|_d|_t|_t|_dS(Nt(tfilenametpathtnametFalsetdefaulttbuiltin(tself((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyt__init__1s
				cCsGg}x4|jD])}|jtjt||dƒƒƒqWt|ƒS(Ni(tIMPORT_EXPORT_STRUCTUREtappendtcopytdeepcopytgetattrttuple(Rtrettx((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyt
export_config8s'cCsÓ|j|ƒx¿t|jƒD]®\}\}}t||tƒr®g}tƒ}x;||D]/}||kr\|j|ƒ|j|ƒq\q\W~t||t	j
|ƒƒqt||t	j
||ƒƒqWdS(N(tcheck_configt	enumerateRt
isinstancetlisttsetRtaddtsetattrRR(Rtconftitelementtdummyt_conft_setR((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyt
import_config>s
"	
cCs½t|ƒtdƒkrFttjd|tdƒt|ƒfƒ‚nt|ƒdkrmttjdƒ‚nxI|D]A}|jƒrt||jkrtttjd||fƒ‚qtqtWdS(NR
s'%s' not of type %s, but %sisname can't be emptys'%s' is not allowed in '%s'(ttypeRR
tINVALID_TYPEtlentINVALID_NAMEtisalnumtADDITIONAL_ALNUM_CHARS(RRtchar((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyt
check_nameNs	
cCs›t|ƒt|jƒkrIttjdt|ƒt|jƒfƒ‚nxKt|jƒD]:\}\}}|j|||ƒ|j|||ƒqYWdS(Ns structure size mismatch %d != %d(R/RRR
R.R t_check_config_structuret
_check_config(RR&R'R(tvalue((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyR[s""cCsdS(N((Rtdummy1tdummy2((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyR6esc	Cst|ƒt|ƒksFttjd|t|ƒt|ƒfƒ‚nt|tƒr¨t|ƒdkr€ttjd|ƒ‚nx||D]}|j||dƒq‡WnWt|tƒr(t|ƒt|ƒkrôttjd|t|ƒfƒ‚nxt	|ƒD] \}}|j|||ƒqWn×t|t
ƒrÿt|jƒƒd\}}x©|jƒD]˜\}}t|ƒt|ƒkr²ttjd|t|ƒt|ƒfƒ‚nt|ƒt|ƒkr`ttjd|t|ƒt|ƒfƒ‚q`q`WndS(Ns'%s' not of type %s, but %sislen('%s') != 1islen('%s') != %d(R-RR
R.R!R"R/R5RR tdicttitems(	RR&t	structureRR'R7tskeytsvaluetkey((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyR5is8	"	
		"	cCs,|jƒ}t}||jkrt}|j|dk	rxP|j|D]>}||krj|j|ƒqHttjd||fƒ‚qHWqn||j	krÜt}x4|j	|D]"}||kr³|j|ƒq³q³Wn|sûttjd|ƒ‚nx*|D]"}ttjd||fƒ‚qWdS(NsMissing attribute %s for %ssUnexpected element %ss%s: Unexpected attribute %s(
tgetNamesRtPARSER_REQUIRED_ELEMENT_ATTRStTruetNonetremoveRR
tPARSE_ERRORtPARSER_OPTIONAL_ELEMENT_ATTRS(RRtattrst_attrstfoundR((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pytparser_check_element_attrsŠs,	
	((t__name__t
__module__t__doc__RtDBUS_SIGNATURER2RARFRRR,R4RR6R5RJ(((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyR(s				
	
		!tUnexpectedElementErrorcBseZd„Zd„ZRS(cCs tt|ƒjƒ||_dS(N(tsuperRORR(RR((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyR¨scCsd|jS(NsUnexpected element '%s'(R(R((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyt__str__«s(RKRLRRQ(((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyRO§s	tMissingAttributeErrorcBseZd„Zd„ZRS(cCs)tt|ƒjƒ||_||_dS(N(RPRRRRt	attribute(RRRS((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyR¯s	cCsd|j|jfS(Ns$Element '%s': missing '%s' attribute(RRS(R((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyRQ³s(RKRLRRQ(((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyRR®s	tUnexpectedAttributeErrorcBseZd„Zd„ZRS(cCs)tt|ƒjƒ||_||_dS(N(RPRTRRRS(RRRS((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyR¸s	cCsd|j|jfS(Ns'Element '%s': unexpected attribute '%s'(RRS(R((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyRQ¼s(RKRLRRQ(((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyRT·s	cBs5eZd„Zd„Zd„Zd„Zd„ZRS(cCs||_d|_dS(NR
(titemt_element(RRU((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyRÁs	cCs
d|_dS(NR
(RV(R((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyt
startDocumentÅscCs
d|_dS(NR
(RV(RRRG((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pytstartElementÈscCs@|dkr|j|j_n|dkr<|j|j_ndS(Ntshorttdescription(RVRURYRZ(RR((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyt
endElementËscCs|j|jddƒ7_dS(Ns
t (RVtreplace(Rtcontent((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyt
charactersÑs(RKRLRRWRXR[R_(((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyRÀs
				cBs>eZd„Zd„Zd„Zd„Zd„Zd„ZRS(cCsotjjj|ƒ|j|_|j|_ig|_|jd|_	g|_
d|_t|_
t|_dS(Niÿÿÿÿsutf-8(tsaxthandlertContentHandlerRtwritet_writetflusht_flusht_ns_contextst_current_contextt_undeclared_ns_mapst	_encodingRt_pending_start_elementt_short_empty_elements(Rtout((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyRÕs			cCs9trd„|jƒDƒ}ntjj|||ƒdS(s saxutils.XMLGenerator.startElement() expects name and attrs to be
            unicode and bad things happen if any of them is (utf-8) encoded.
            We override the method here to sanitize this case.
            Can be removed once we drop Python2 support.
        cSs+i|]!\}}t|ƒt|ƒ“qS((R	(t.0RR7((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pys
<dictcomp>ís	N(RR;tsaxutilstXMLGeneratorRX(RRRG((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyRXæscCsÕtrv|jdt|ƒƒxF|jƒD]8\}}|jdt|ƒtjt|ƒƒfƒq*W|jdƒn[|jd|ƒx:|jƒD],\}}|jd|tj|ƒfƒq”W|jdƒdS(s* slightly modified startElement()
        u<u %s=%su/>t<s %s=%ss/>N(RRdR	R;Rot	quoteattr(RRRGR7((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyt
simpleElementðs$cCstjj|t|ƒƒdS(sú saxutils.XMLGenerator.endElement() expects name to be
            unicode and bad things happen if it's (utf-8) encoded.
            We override the method here to sanitize this case.
            Can be removed once we drop Python2 support.
        N(RoRpR[R	(RR((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyR[ÿscCstjj|t|ƒƒdS(sý saxutils.XMLGenerator.characters() expects content to be
            unicode and bad things happen if it's (utf-8) encoded.
            We override the method here to sanitize this case.
            Can be removed once we drop Python2 support.
        N(RoRpR_R	(RR^((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyR_scCstjj|t|ƒƒdS(s saxutils.XMLGenerator.ignorableWhitespace() expects content to be
            unicode and bad things happen if it's (utf-8) encoded.
            We override the method here to sanitize this case.
            Can be removed once we drop Python2 support.
        N(RoRptignorableWhitespaceR	(RR^((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyRts(RKRLRRXRsR[R_Rt(((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyRÔs		
			cCsÁtj|ƒ}|dkr4ttjd|ƒ‚n‰|dkrYttjd|ƒ‚nd|dkr~ttjd|ƒ‚n?t|ƒdkr½|d|dkr½ttjd|ƒ‚ndS(	Niþÿÿÿsport number in '%s' is too bigiÿÿÿÿs'%s' is invalid port rangesport range '%s' is ambiguousiii(RtgetPortRangeRR
tINVALID_PORTRCR/(tportt
port_range((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyRs			&	cCs)|dkr%ttjd|ƒ‚ndS(Nttcptudptsctptdccps)'%s' not from {'tcp'|'udp'|'sctp'|'dccp'}(RyRzR{R|(RR
tINVALID_PROTOCOL(tprotocol((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyR&s	cCs(tj|ƒs$ttj|ƒ‚ndS(N(Rt
checkProtocolRR
R}(R~((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyR,scCs5tj||ƒs1ttjd||fƒ‚ndS(Ns'%s' is not valid %s address(RRRR
tINVALID_ADDR(tipvtaddr((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyR0s	( RMt__all__txml.saxR`txml.sax.saxutilsRoRtsystfirewallRtfirewall.functionsR	R
tfirewall.errorsRtversionRtobjectRt	ExceptionRORRRTRaRbRRpRRRRR(((s>/usr/lib/python2.7/site-packages/firewall/core/io/io_object.pyt<module>s,			C			

OHA YOOOO