+
    i]  c                   s    ^ RI t ^ RIt^ RIt^ RIt^ RIHtHt ^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHtHtHt ^ RIHtHtHt ^ RIHtHtHt ^ R	IHtHtHt ^ R
IHtHtH t  ^ RI!H"t"H#t#H$t$ ^ RIH%t% ^ RI&H't'  ! R R4      t(R# )i    N)DictList)config)log)	IO_Object)IcmpTypeicmptype_readericmptype_writer)Serviceservice_readerservice_writer)Zonezone_readerzone_writer)IPSetipset_readeripset_writer)Helperhelper_readerhelper_writer)Policypolicy_readerpolicy_writer)errors)FirewallErrorc                   sx  a  ] tR t^t o R tR tR tR tR t/ 3V 3R lR llt	R t
R	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR t R t!R  t"R! t#R" t$R# t%R$ t&R% t'R& t(R' t)R( t*R) t+R* t,R+ t-R, t.R- t/R. t0R/ t1R0 t2R1 t3R2 t4R3 t5R4 t6R5 t7R6 t8R7 t9R8 t:R9 t;R: t<R; t=R< t>R= t?R> t@R? tAR@ tBRA tCRB tDRC tERD tFRE tGRF tHRG tIRH tJRI tKRJ tLRK tMRL tNRM tORN tPRO tQRP tRRQ tSRR tTRS tURT tVRU tWRV tXRW tYRX tZRY t[RZ t\R[ t]R\ t^R] t_R^ t`R_ taR` tbRa tcRb tdRcteV tfRd# )eFirewallConfigc                s2    Wn         V P                  4        R # N)_fw_FirewallConfig__init_vars)selfZfw   &&</usr/lib/python3.14/site-packages/firewall/core/fw_config.py__init__ZFirewallConfig.__init__   s        c                s   V P                   : R V P                  : RV P                  : RV P                  : RV P                  : RV P
                  : RV P                  : RV P                  : RV P                  : RV P                  : RV P                  : RV P                  : RV P                  : RV P                  : RV P                  : R2# )Z(z, Z))Z	__class___ipsets
_icmptypes	_services_zones_helpersZpolicy_objects_builtin_ipsets_builtin_icmptypes_builtin_services_builtin_zones_builtin_helpers_builtin_policy_objects_firewalld_conf_directr      &r   __repr__ZFirewallConfig.__repr__   s    NNLLOONNKKMM  ##""!!((  LL
 	
r!   c                s    / V n         / V n        / V n        / V n        / V n        / V n        / V n        / V n        / V n        / V n	        / V n
        / V n        R V n        R V n        R # r   )r"   r#   r$   r%   r&   _policy_objectsr'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r   Z__init_varsZFirewallConfig.__init_vars2   sl    !!"$!#  "')$#r!   c                s   \        V P                  P                  4       4       F1  pV P                  V,          P                  4        V P                  V K3  	  \        V P                  P                  4       4       F1  pV P                  V,          P                  4        V P                  V K3  	  \        V P
                  P                  4       4       F1  pV P
                  V,          P                  4        V P
                  V K3  	  \        V P                  P                  4       4       F1  pV P                  V,          P                  4        V P                  V K3  	  \        V P                  P                  4       4       F1  pV P                  V,          P                  4        V P                  V K3  	  \        V P                  P                  4       4       F1  pV P                  V,          P                  4        V P                  V K3  	  \        V P                  P                  4       4       F1  pV P                  V,          P                  4        V P                  V K3  	  \        V P                  P                  4       4       F1  pV P                  V,          P                  4        V P                  V K3  	  \        V P                  P                  4       4       F1  pV P                  V,          P                  4        V P                  V K3  	  \        V P                  P                  4       4       F1  pV P                  V,          P                  4        V P                  V K3  	  V P                  '       d$   V P                  P                  4        V =R V n        V P                  '       d$   V P                  P                  4        V =R V n        V P                  4        R # r   )listr'   keyscleanupr"   r(   r#   r)   r$   r*   r%   r+   r&   r-   r.   r   )r   xs   & r   r5   ZFirewallConfig.cleanupB   s   d**//12A  #++-$$Q' 3 dll'')*ALLO##%Q + d--2245A##A&..0''* 6 doo**,-AOOA&&(" . d,,1134A""1%--/&&q) 5 dnn))+,ANN1%%'q! - d))..01A"**,##A& 2 dkk&&()AKKN""$A * d++0023A!!!$,,.%%a( 4 dmm((*+AMM!$$&a  ,   ((*$#'D <<<LL  "DLr!   c                s   / pV P                  4        Uu/ uF  q"V P                  V4      bK  	  upVR&   V P                  4        Uu/ uF  q3V P                  V4      bK  	  upVR&   V P	                  4        Uu/ uF  qDV P                  V4      bK  	  upVR&   V P                  4        Uu/ uF  qUV P                  V4      bK  	  upVR&   V P                  4        Uu/ uF  qfV P                  V4      bK  	  upVR&   V P                  4        Uu/ uF  pWpP                  V4      bK  	  upVR&   / VR&   V P                  P                  R4      VR,          R&   V# u upi u upi u upi u upi u upi u upi )	z:
Returns a dict of dicts of all permanent config objects.
ipsetshelpers	icmptypesserviceszonespoliciesconfZFirewallBackend)
get_ipsets	get_ipsetget_helpers
get_helperget_icmptypesget_icmptypeget_servicesget_service	get_zonesget_zoneget_policy_objectsget_policy_objectr-   Zget)r   	conf_dictZipsetZhelperZicmptypeZserviceZzoneZpolicy   &       r   get_all_io_objects_dictZ&FirewallConfig.get_all_io_objects_dictr   s    	6:oo6G
6GU4>>%((6G
	( ;?:J:J:L 
:LDOOF++:L 
	) CGBTBTBV"
BVhd''11BV"
	+ ?C>O>O>Q!
>Q7T%%g..>Q!
	* EINNDTUDTDDMM$$77DTU	' 113!
3 **6223!
	*
 	&/3/C/C/G/G0
	&+, /
 
"
!
 V!
s#   EE 9E%+E*E/E4c                sF   < V ^8  d   QhRS[ S[S[S[,          3,          /# )i   extra_io_objects)r    Zstrr   r   )Zformat__classdict__s   "r   Z__annotate__ZFirewallConfig.__annotate__   s%     V V$sDO7K2L Vr!   c                s   V P                  4       pV F'  pW,           F  pWBV,          VP                  &   K  	  K)  	  . ROpV FD  pW&,          pVP                  4        F%  w  rV	P                  V	P	                  4       V4       K'  	  KF  	  R# )r7   N)r7   r8   r9   r:   r;   r<   )rL   nameZitemsZcheck_config_dictexport_config_dict)
r   rM   Zall_io_objectsZtype_keyobjorderZio_obj_typeZio_objsrO   Zio_objs
   &&        r   full_check_configZ FirewallConfig.full_check_config   s    557(H'1158x(2 2 ) T K$1G '(()B)B)DnU !0 !r!   c                    Wn         R # r   r-   )r   r=   r   r   set_firewalld_confZ!FirewallConfig.set_firewalld_conf   s    #r!   c                    V P                   # r   rU   r/   r0   r   get_firewalld_confZ!FirewallConfig.get_firewalld_conf   s    ###r!   c                    \         P                  P                  \        P                  4      '       g   V P
                  P                  4        R # V P
                  P                  4        R # r   )ospathexistsr   ZFIREWALLD_CONFr-   Zclearreadr/   r0   r   update_firewalld_confZ$FirewallConfig.update_firewalld_conf   s?    ww~~f3344  &&(  %%'r!   c                s   V P                   V P                  V P                  V P                  V P                  V P
                  .pV F  p\        P                  ! V4      pV F`  pW4,          p\        P                  P                  VP                  VP                  4      p \        P                  ! VR V,          4       W$ Kb  	  K  	  V P"                  P%                  4        V P"                  P'                  4        R#   \         d8   p\        P                  ! RYg4       \        P                   ! T4        Rp?L}Rp?ii ; i)%s.oldBackup of file '%s' failed: %sN)r%   r2   r"   r$   r&   r#   copyrZ   r[   Zjoinfilenameshutilmove	Exceptionr   errorremover-   Zset_defaultsZwrite)r   rR   Zio_obj_dictZ	dict_copyZobj_namerQ   rO   msgrK   r   reset_defaultsZFirewallConfig.reset_defaults   s    KK  LLNNMMOO
 !K		+.I%)ww||CHHcll;$KKho6  ) & ! 	))+""$ ! $II>JIIdOO$s   "D  E-D==Ec                rT   r   r.   )r   Zdirectr   r   
set_directZFirewallConfig.set_direct   s    r!   c                rW   r   rj   r/   r0   r   
get_directZFirewallConfig.get_direct   s    ||r!   c                rY   r   )rZ   r[   r\   r   ZFIREWALLD_DIRECTr.   r5   r]   r/   r0   r   update_directZFirewallConfig.update_direct   s;    ww~~f5566LL  "LLr!   c           	         \        \        \        V P                  P	                  4       4      \        V P
                  P	                  4       4      ,           4      4      # r   )sortedsetr3   r"   r4   r'   r/   r0   r   r>   ZFirewallConfig.get_ipsets   sB    T\\&&()D1E1E1J1J1L,MMN
 	
r!   c                    VP                   '       d   WP                  VP                  &   R # WP                  VP                  &   R # r   )builtinr'   rO   r"   r   rQ   r   r   	add_ipsetZFirewallConfig.add_ipset   s-    ;;;-0  *%(LL"r!   c                    WP                   9   d   V P                   V,          # WP                  9   d   V P                  V,          # \        \        P                  V4      hr   )r"   r'   r   r   INVALID_IPSETr   rO   r   r   r?   ZFirewallConfig.get_ipset   sK    <<<<%%)))''--F00$77r!   c                   VP                   V P                  9  d%   \        \        P                  VP                   4      hV P                  VP                   ,          V8w  d,   \        \        P                  R VP                   ,          4      hVP                   V P
                  9  d,   \        \        P                  RVP                   ,          4      hV P                  V4       V P
                  VP                   ,          # )zself._ipsets[%s] != objz'%s' not a built-in ipset)rO   r"   r   r   NO_DEFAULTSr'   _remove_ipsetrs   r   r   load_ipset_defaultsZ"FirewallConfig.load_ipset_defaults   s    884<<' 2 2CHH==\\#((#s*""$=$H  XXT111""$?#(($J  	3##CHH--r!   c                "    VP                  4       # r   export_configrs   r   r   get_ipset_configZFirewallConfig.get_ipset_config         ""r!   c                p   \         P                   ! V4      pVP                  '       d?   \        P                  Vn        R Vn        VP                  VP                  8w  d   R Vn        VP                  W P                  4       4       V P                  RV./4       V P                  V4       \        V4       V# )Fr7   )ra   rr   r   ETC_FIREWALLD_IPSETSr[   defaultimport_configrL   rS   rt   r   r   rQ   r=   r6      &&& r   set_ipset_configZFirewallConfig.set_ipset_config   s    IIcN;;;00AFAIxx166!!		::<=1#/qQr!   c                   WP                   9   g   WP                  9   d"   \        \        P                  R V,          4      h\        4       pVP                  V4       Wn        RV,          Vn        \        P                  Vn        RVn        RVn        VP                  W P                  4       4       V P!                  RV./4       V P#                  V4       \%        V4       V# )znew_ipset(): '%s'%s.xmlFTr7   )r"   r'   r   r   NAME_CONFLICTr   
check_namerO   rb   r   r   r[   rr   r   r   rL   rS   rt   r   r   rO   r=   r6   r   r   	new_ipsetZFirewallConfig.new_ipset  s    <<4+?+?#? 4 46ID6PQQG	T_
,,			::<=1#/qQr!   c                   \         P                  P                  V4      p\         P                  P                  V4      p\         P                  P	                  V4      '       Eg%   V\
        P                  8X  d   V P                  P                  4        Fv  pV P                  V,          pVP                  V8X  g   K)  V P                  V VP                  V P                  9   d"   R V P                  VP                  ,          3u # RV3u # 	  R# V P                  P                  4        FY  pV P                  V,          pVP                  V8X  g   K)  V P                  V VP                  V P                  9  d   RV3u # Ru # 	  R# \        P                  ! RV4        \        W#4      pTP                  T P                  9  d1   TP                  T P                  9  d   T P#                  T4       RT3# T\
        P                  8X  dd   TP                  T P                  9   dE   T P                  TP                  ,          P$                  Tn        YPP                  TP                  &   R T3# TP                  T P                  9   dQ   T P                  TP                   YPP                  TP                  &   TP                  T P                  9  d   R T3# R# R#   \         d$   p\        P                   ! RY&4       Ru Rp?# Rp?ii ; i)updaterg   NzLoading ipset file '%s'z"Failed to load ipset file '%s': %snewNN)rZ   r[   basenamedirnamer\   r   r   r"   r4   rb   rO   r'   r   debug1r   re   rf   rt   r   r   rO   rb   r[   r6   rQ   rh      &&     r   update_ipset_from_pathZ%FirewallConfig.update_ipset_from_path  sg   77##D)wwt$ww~~d## v222**,A,,q/C||x/ LLO88t';';;$,d.B.B388.L#MM (#. -*   --224A..q1C||x/ 003884<<7$,c?2 $0/ 5   	

,d3	 x.C 884///CHHDLL4PNN33< 6...xx4<<'"ll3884<<),SXX&c?"xx4///((214$$SXX.884<</$c?* (' =  	 II:HJ	    !K L
'L?L
L
c                j   VP                   V P                  9  d%   \        \        P                  VP                   4      hVP
                  \        P                  8w  d<   \        \        P                  R VP
                  : R\        P                  : R 24      hVP
                  : RVP                   : R2p \        P                  ! VRV,          4       V P                  VP                    R#   \         d8   p\        P                  ! RY#4       \        P                  ! T4        Rp?LVRp?ii ; i'z' != '/.xmlr_   r`   N)rO   r"   r   r   rv   r[   r   r   INVALID_DIRECTORYrc   rd   re   r   rf   rZ   rg   r   rQ   rO   rh      &&  r   rz   ZFirewallConfig._remove_ipset]  s    884<<' 4 4chh??88v222(("%((F,G,GH 
 "hh1	KKho.
 LL"	  	II6BIIdOO	   9C0 0D2;-D--D2c                    VP                   '       g   VP                  '       g,   \        \        P                  R VP
                  ,          4      hR# )z'%s' is built-in ipsetN)rr   r   r   r   ZBUILTIN_IPSETrO   rs   r   r   check_builtin_ipsetZ"FirewallConfig.check_builtin_ipseto  s:    ;;;ckkk$$&>&I  *r!   c                J    V P                  V4       V P                  V4       R # r   )r   rz   rs   r   r   remove_ipsetZFirewallConfig.remove_ipsetu  s      %3r!   c                l    V P                  V4       V P                  W4      pV P                  V4       V# r   )r   _copy_ipsetrz   )r   rQ   rO   r   r   r   rename_ipsetZFirewallConfig.rename_ipsety  s4      %$$S/	3r!   c                @    V P                  W!P                  4       4      # r   )r   r~   r   rQ   rO      &&&r   r   ZFirewallConfig._copy_ipset  s    ~~d$5$5$788r!   c           	     rn   r   )ro   rp   r3   r#   r4   r(   r/   r0   r   rB   ZFirewallConfig.get_icmptypes  sB    T__))+,tD4K4K4P4P4R/SST
 	
r!   c                rq   r   )rr   r(   rO   r#   rs   r   r   add_icmptypeZFirewallConfig.add_icmptype  s-    ;;;03##CHH-(+OOCHH%r!   c                ru   r   )r#   r(   r   r   INVALID_ICMPTYPErw   r   r   rC   ZFirewallConfig.get_icmptype  sK    ??"??4((,,,**400F33T::r!   c                rx   )zself._icmptypes[%s] != objz'%s' not a built-in icmptype)rO   r#   r   r   ry   r(   _remove_icmptypers   r   r   load_icmptype_defaultsZ%FirewallConfig.load_icmptype_defaults  s    884??* 2 2CHH==__SXX&#-""$@388$K  XXT444""$BSXX$M  	c"&&sxx00r!   c                r|   r   r}   rs   r   r   get_icmptype_configZ"FirewallConfig.get_icmptype_config  r   r!   c                r   )Fr9   )ra   rr   r   ETC_FIREWALLD_ICMPTYPESr[   r   r   rL   rS   r   r   r   r   r   set_icmptype_configZ"FirewallConfig.set_icmptype_config  s    IIcN;;;33AFAIxx166!!		::<=aS12!r!   c                r   )znew_icmptype(): '%s'r   FTr9   )r#   r(   r   r   r   r   r   rO   rb   r   r   r[   rr   r   r   rL   rS   r   r   r   r   r   new_icmptypeZFirewallConfig.new_icmptype  s    ??"d.E.E&E 4 46Lt6STTJ	T_
//			::<=aS12!r!   c                r   )r   rg   NzLoading icmptype file '%s'z%Failed to load icmptype file '%s': %sr   r   )rZ   r[   r   r   r\   r   r   r#   r4   rb   rO   r(   r   r   r   re   rf   r   r   r   r   r   update_icmptype_from_pathZ(FirewallConfig.update_icmptype_from_path  sk   77##D)wwt$ww~~d## v555--/A//!,C||x/ OOA.88t'>'>>$,d.E.Echh.O#PP (#. 0*   00557A11!4C||x/ 33A6884??:$,c?2 $0/ 8   	

/6	 !(1C 884222sxxt7Vc"3< 6111xx4??*"oochh7??,/)c?"xx4222++CHH547''1884??2$c?* (' =  	 II=xM	 r   c                r   r   )rO   r#   r   r   r   r[   r   r   r   rc   rd   re   r   rf   rZ   rg   r   r   r   r   ZFirewallConfig._remove_icmptype  s    884??* 7 7BB88v555(("%((F,J,JK 
 "hh1	KKho.
 OOCHH%	  	II6BIIdOO	r   c                r   )z'%s' is built-in icmp typeN)rr   r   r   r   ZBUILTIN_ICMPTYPErO   rs   r   r   check_builtin_icmptypeZ%FirewallConfig.check_builtin_icmptype  s:    ;;;ckkk'')E)P  *r!   c                r   r   )r   r   rs   r   r   remove_icmptypeZFirewallConfig.remove_icmptype%  s    ##C(c"r!   c                r   r   )r   _copy_icmptyper   )r   rQ   rO   r   r   r   rename_icmptypeZFirewallConfig.rename_icmptype)  s4    ##C(**35c"r!   c                r   r   )r   r~   r   r   r   r   ZFirewallConfig._copy_icmptype/  s      '8'8':;;r!   c           	     rn   r   )ro   rp   r3   r$   r4   r)   r/   r0   r   rD   ZFirewallConfig.get_services4  sB    T^^((*+d43I3I3N3N3P.QQR
 	
r!   c                rq   r   )rr   r)   rO   r$   rs   r   r   add_serviceZFirewallConfig.add_service9  s-    ;;;/2""388,'*NN388$r!   c                    WP                   9   d   V P                   V,          # WP                  9   d   V P                  V,          # \        \        P                  R V,          4      h)zget_service(): '%s')r$   r)   r   r   INVALID_SERVICErw   r   r   rE   ZFirewallConfig.get_service?  sQ    >>!>>$''+++))$//F224ID4PQQr!   c                rx   )zself._services[%s] != objz'%s' not a built-in service)rO   r$   r   r   ry   r)   _remove_servicers   r   r   load_service_defaultsZ$FirewallConfig.load_service_defaultsF  s    884>>) 2 2CHH==^^CHH%,""$?#(($J  XXT333""$ACHH$L  	S!%%chh//r!   c                s&    VP                  ^R7      # )i   ZlengthZexport_config_tuplers   r   r   get_service_configZ!FirewallConfig.get_service_configT  s    &&a&00r!   c                r|   r   rP   rs   r   r   get_service_config_dictZ&FirewallConfig.get_service_config_dictW      %%''r!   c                F    VP                  V4      pV P                  W4      # r   )get_dict_from_tupleset_service_config_dictr   rQ   r=   rJ   r   r   set_service_configZ!FirewallConfig.set_service_configZ  s#    ++D1	++C;;r!   c                r   )Fr:   )ra   rr   r   ETC_FIREWALLD_SERVICESr[   r   import_config_dictrL   rS   r   r
   r   r   r   r   Z&FirewallConfig.set_service_config_dict^  s    IIcN;;;22AFAIxx166!!		T#?#?#AB
QC01qr!   c                    WP                   9   g   WP                  9   d"   \        \        P                  R V,          4      h\
        P                  ! \        P                  V4      pV P                  W4      # )new_service(): '%s')
r$   r)   r   r   r   r   get_dict_from_tuple_staticr   IMPORT_EXPORT_STRUCTUREnew_service_dictr   rO   r=   rJ   r   r   new_serviceZFirewallConfig.new_servicel  s^    >>!T-C-C%C 4 46Kd6RSS88++T
	 $$T55r!   c                r   )r   r   FTr:   )r$   r)   r   r   r   r   r   rO   rb   r   r   r[   rr   r   r   rL   rS   r   r
   r   r   r   r   ZFirewallConfig.new_service_dictu  s    >>!T-C-C%C 4 46Kd6RSSI	T_
..			T#?#?#AB
QC01qr!   c                r   )r   rg   NzLoading service file '%s'z$Failed to load service file '%s': %sr   r   )rZ   r[   r   r   r\   r   r   r$   r4   rb   rO   r)   r   r   r	   re   rf   r   r   r   r   r   update_service_from_pathZ'FirewallConfig.update_service_from_path  sk   77##D)wwt$ww~~d## v444,,.A..+C||x/ NN1-88t'='==$,d.D.DSXX.N#OO (#. /*   //446A003C||x/ 2215884>>9$,c?2 $0/ 7   	

.5	  0C 884111chhdnn6TS!3< 6000xx4>>)"nnSXX6>>+.sxx(c?"xx4111**388436&&sxx0884>>1$c?* (' =  	 II<hL	 r   c                r   r   )rO   r$   r   r   r   r[   r   r   r   rc   rd   re   r   rf   rZ   rg   r   r   r   r   ZFirewallConfig._remove_service  s    884>>) 6 6AA88v444(("%((F,I,IJ 
 "hh1	KKho.
 NN388$	  	II6BIIdOO	r   c                r   )z'%s' is built-in serviceN)rr   r   r   r   ZBUILTIN_SERVICErO   rs   r   r   check_builtin_serviceZ$FirewallConfig.check_builtin_service  s:    ;;;ckkk&&(BSXX(M  *r!   c                r   r   )r   r   rs   r   r   remove_serviceZFirewallConfig.remove_service  s    ""3'S!r!   c                r   r   )r   _copy_servicer   )r   rQ   rO   r   r   r   rename_serviceZFirewallConfig.rename_service  s4    ""3'((3S!r!   c                r   r   )r   rP   r   r   r   r   ZFirewallConfig._copy_service  s    $$T+A+A+CDDr!   c           	     rn   r   )ro   rp   r3   r%   r4   r*   r/   r0   r   rF   ZFirewallConfig.get_zones  s=    c$t{{//12T$:M:M:R:R:T5UUVWWr!   c                rq   r   )rr   r*   rO   r%   rs   r   r   add_zoneZFirewallConfig.add_zone  s-    ;;;,/)$'KK!r!   c                s~    WP                   9   d   V P                   V WP                  9   d   V P                  V R # R # r   )r*   r%   rw   r   r   forget_zoneZFirewallConfig.forget_zone  s7    &&&##D);;D! r!   c                r   )zget_zone(): %s)r%   r*   r   r   INVALID_ZONErw   r   r   rG   ZFirewallConfig.get_zone  sQ    ;;;;t$$(((&&t,,F//1AD1HIIr!   c                rx   )zself._zones[%s] != objz'%s' not a built-in zone)rO   r%   r   r   ry   r*   _remove_zoners   r   r   load_zone_defaultsZ!FirewallConfig.load_zone_defaults
  s    884;;& 2 2CHH==[["c) 2 24Lsxx4WXXXXT000""$>$I  	#""388,,r!   c                s&    VP                  ^R7      # )i   r   r   rs   r   r   get_zone_configZFirewallConfig.get_zone_config  s    &&b&11r!   c                r|   r   r   rs   r   r   get_zone_config_dictZ#FirewallConfig.get_zone_config_dict  r   r!   c                r   r   )r   set_zone_config_dictr   r   r   set_zone_configZFirewallConfig.set_zone_config  s#    ++D1	((88r!   c                r   )Fr;   )ra   rr   r   ETC_FIREWALLD_ZONESr[   r   r   rL   rS   r   r   r   r   r   r   Z#FirewallConfig.set_zone_config_dict   s    IIcN;;;//AFAIxx166!!		T#?#?#AB!~.aAr!   c                r   )new_zone(): '%s')
r%   r*   r   r   r   r   r   r   r   new_zone_dictr   r   r   new_zoneZFirewallConfig.new_zone.  s^    ;;$*=*="= 4 46H46OPP88(($
	 !!$22r!   c                r   )r   r   FTr;   )r%   r*   r   r   r   r   r   rO   rb   r   r   r[   rr   r   r   rL   rS   r   r   r   r   r   r   ZFirewallConfig.new_zone_dict7  s    ;;$*=*="= 4 46H46OPPF	T_
++			T#?#?#AB!~.aAr!   c                   \         P                  P                  V4      p\         P                  P                  V4      p\         P                  P	                  V4      '       Eg5   VP                  \        P                  4      '       d   V P                  P                  4        Fv  pV P                  V,          pVP                  V8X  g   K)  V P                  V VP                  V P                  9   d"   R V P                  VP                  ,          3u # RV3u # 	  R# V P                  P                  4        FY  pV P                  V,          pVP                  V8X  g   K)  V P                  V VP                  V P                  9  d   RV3u # Ru # 	  R# \        P                  ! RV4        \        W#4      pTP                  \        P                  4      '       ds   \%        T4      \%        \        P                  4      8  dL   \         P                  P                  T4      : R\         P                  P                  T4      ^ R : 2Tn        TP                  T P                  9  d1   TP                  T P                  9  d   T P'                  T4       RT3# TP                  \        P                  4      '       dd   TP                  T P                  9   dE   T P                  TP                  ,          P(                  Tn        YPP                  TP                  &   R T3# TP                  T P                  9   dQ   T P                  TP                   YPP                  TP                  &   TP                  T P                  9  d   R T3# R# R#   \          d$   p\        P"                  ! RY&4       Ru Rp?# Rp?ii ; i)	r   rg   NzLoading zone file '%s'z!Failed to load zone file '%s': %sr   r   r   )rZ   r[   r   r   r\   
startswithr   r   r%   r4   rb   rO   r*   r   r   r   re   rf   lenr   r   r   r   r   update_zone_from_pathZ$FirewallConfig.update_zone_from_pathJ  s   77##D)wwt$ww~~d## v99::))+A++a.C||x/ KKN88t':'::$,d.A.A#((.K#LL (#. ,*   ,,113A--a0C||x/ //2884;;6$,c?2 $0/ 4   	

+T2	 h-C
 ??655663t9s&&H
 <

   &  *1R0CH 884...3884;;3NMM#3< ??65566xx4;;&"kk#((3;;(+CHH%c?"xx4...''103##CHH-884;;.$c?* (' O  	 II98I	    1N ON<6O<Oc                   VP                   V P                  9  d%   \        \        P                  VP                   4      hVP
                  P                  \        P                  4      '       g<   \        \        P                  R VP
                  : R\        P                  : R 24      hVP
                  : RVP                   : R2p \        P                  ! VRV,          4       V P                  VP                    R#   \         d8   p\        P                  ! RY#4       \        P                   ! T4        Rp?LVRp?ii ; ir   z' doesn't start with 'r   r   r_   r`   N)rO   r%   r   r   r   r[   r   r   r   r   rc   rd   re   r   rf   rZ   rg   r   r   r   r   ZFirewallConfig._remove_zone  s    884;;& 3 3SXX>>xx""6#=#=>>((25((F<V<VW 
 "hh1	KKho.
 KK!	  	II6BIIdOO	   	D   E-D==Ec                r   )z'%s' is built-in zoneN)rr   r   r   r   ZBUILTIN_ZONErO   rs   r   r   check_builtin_zoneZ!FirewallConfig.check_builtin_zone  s5    ;;;ckkk 3 35Lsxx5WXX *r!   c                r   r   )r   r   rs   r   r   remove_zoneZFirewallConfig.remove_zone  s    $#r!   c                s    V P                  V4       VP                  4       pV P                  V4        V P                  W#4      pV#    T P                  TP                  T4       h ; ir   )r   rP   r   r   rO   )r   rQ   rO   Zobj_confr   s   &&&  r   rename_zoneZFirewallConfig.rename_zone  sf    $))+#	))$9H
 		sxx2s   A A&c           	     rn   r   )ro   rp   r3   r2   r4   r,   r/   r0   r   rH   Z!FirewallConfig.get_policy_objects  sJ    T))..01t3388:;<
 	
r!   c                rq   r   )rr   r,   rO   r2   rs   r   r   add_policy_objectZ FirewallConfig.add_policy_object  s/    ;;;58((2-0  *r!   c                r   )zget_policy_object(): %s)r2   r,   r   r   INVALID_POLICYrw   r   r   rI   Z FirewallConfig.get_policy_object  sU    '''''--111//55F113Lt3STTr!   c                rx   )zself._policy_objects[%s] != objz'%s' not a built-in policy)rO   r2   r   r   ry   r,   _remove_policy_objectrs   r   r   load_policy_object_defaultsZ*FirewallConfig.load_policy_object_defaults  s    884/// 2 2CHH==!!#((+s2""$E$P  XXT999""$@388$K  	""3'++CHH55r!   c                r|   r   r   rs   r   r   get_policy_object_config_dictZ,FirewallConfig.get_policy_object_config_dict  r   r!   c                r   )Fr<   )ra   rr   r   ETC_FIREWALLD_POLICIESr[   r   r   rL   rS   r   r   r   r   r   set_policy_object_config_dictZ,FirewallConfig.set_policy_object_config_dict  s    IIcN;;;22AFAIxx166!!		T#?#?#AB
QC01q!ar!   c                r   )znew_policy_object(): '%s'r   FTr<   )r2   r,   r   r   r   r   r   rO   rb   r   r   r[   rr   r   r   rL   rS   r   r   r   r   r   new_policy_object_dictZ%FirewallConfig.new_policy_object_dict  s    '''43O3O+O$$&AD&H  H	T_
..			T#?#?#AB
QC01q!ar!   c                r   )	r   rg   NzLoading policy file '%s'z#Failed to load policy file '%s': %sr   r   r   r   )rZ   r[   r   r   r\   r   r   r   r2   r4   rb   rO   r,   r   r   r   re   rf   r   r   r   r   r   r   update_policy_object_from_pathZ-FirewallConfig.update_policy_object_from_path	  s   77##D)wwt$ww~~d## v<<==--224A..q1C||x/ 00388t'C'CC$,d.J.J388.T#UU (#. 5*   55::<A66q9C||x/ 88;884+?+??$,c?2 $0/ =   	

-t4	 /C
 ??68899c$i#))K
 ?

   &  *1R0CH HHD888 4 44""3'3< ??68899xx4///"22388<DD14$$SXX.c?"xx477700:9<,,SXX6884#7#77$c?* (' U  	 II;XK	 r   c                r   r   )rO   r2   r   r   r   r[   r   r   r   r   rc   rd   re   r   rf   rZ   rg   r   r   r   r   Z$FirewallConfig._remove_policy_objectZ  s    884/// 5 5sxx@@xx""6#@#@AA((88V::<  "hh1	KKho.
   *	  	II6BIIdOO	r   c                r   )z'%s' is built-in policyN)rr   r   r   r   ZBUILTIN_POLICYrO   rs   r   r   check_builtin_policy_objectZ*FirewallConfig.check_builtin_policy_objectm  :    ;;;ckkk%%'@388'K  *r!   c                r   r   )r   r   rs   r   r   remove_policy_objectZ#FirewallConfig.remove_policy_objects  s    ((-""3'r!   c                r   r   )r   _copy_policy_objectr   )r   rQ   rO   Znew_policy_objectr   r   rename_policy_objectZ#FirewallConfig.rename_policy_objectw  s5    ((- 44S?""3'  r!   c                r   r   )r   rP   r   r   r   r   Z"FirewallConfig._copy_policy_object}  s    **41G1G1IJJr!   c           	     rn   r   )ro   rp   r3   r&   r4   r+   r/   r0   r   r@   ZFirewallConfig.get_helpers  sB    T]]'')*T$2G2G2L2L2N-OOP
 	
r!   c                rq   r   )rr   r+   rO   r&   rs   r   r   
add_helperZFirewallConfig.add_helper  s-    ;;;.1!!#((+&)MM#((#r!   c                ru   r   )r&   r+   r   r   INVALID_HELPERrw   r   r   rA   ZFirewallConfig.get_helper  sK    == ==&&***((..F11488r!   c                rx   )zself._helpers[%s] != objz'%s' not a built-in helper)rO   r&   r   r   ry   r+   _remove_helperrs   r   r   load_helper_defaultsZ#FirewallConfig.load_helper_defaults  s    884==( 2 2CHH==]]388$+""$>$I  XXT222""$@388$K  	C $$SXX..r!   c                r|   r   r}   rs   r   r   get_helper_configZ FirewallConfig.get_helper_config  r   r!   c                r   )Fr8   )ra   rr   r   ETC_FIREWALLD_HELPERSr[   r   r   rL   rS   r   r   r   r   r   set_helper_configZ FirewallConfig.set_helper_config  s    IIcN;;;11AFAIxx166!!		::<=	A3/0ar!   c                r   )znew_helper(): '%s'r   FTr8   )r&   r+   r   r   r   r   r   rO   rb   r   r  r[   rr   r   r   rL   rS   r   r   r   r   r   
new_helperZFirewallConfig.new_helper  s    == D,A,A$A 4 46JT6QRRH	T_
--			::<=	A3/0ar!   c                r   )r   rg   NzLoading helper file '%s'z#Failed to load helper file '%s': %sr   r   )rZ   r[   r   r   r\   r   r  r&   r4   rb   rO   r+   r   r   r   re   rf   r   r   r   r   r   update_helper_from_pathZ&FirewallConfig.update_helper_from_path  si   77##D)wwt$ww~~d## v333++-A--*C||x/ MM!,88t'<'<<$,d.C.CCHH.M#NN (#. .*   ..335A//2C||x/ 11!4884==8$,c?2 $0/ 6   	

-t4	 /C 884000SXXT]]5ROOC 3< 6///xx4==("mmCHH5==*-chh'c?"xx4000))#((325%%chh/884==0$c?* (' =  	 II;XK	 r   c                r   r   )rO   r&   r   r   r   r[   r   r  r   rc   rd   re   r   rf   rZ   rg   r   r   r   r   ZFirewallConfig._remove_helper  s    884==( 5 5sxx@@88v333(("%((F,H,HI 
 "hh1	KKho.
 MM#((#	  	II6BIIdOO	r   c                r   )z'%s' is built-in helperN)rr   r   r   r   ZBUILTIN_HELPERrO   rs   r   r   check_builtin_helperZ#FirewallConfig.check_builtin_helper  r   r!   c                r   r   )r  r   rs   r   r   remove_helperZFirewallConfig.remove_helper#  s    !!#&C r!   c                r   r   )r  _copy_helperr   )r   rQ   rO   r  r   r   rename_helperZFirewallConfig.rename_helper'  s4    !!#&&&s1
C r!   c                r   r   )r  r~   r   r   r   r	  ZFirewallConfig._copy_helper-  s    t%6%6%899r!   )r+   r(   r'   r,   r)   r*   r.   r-   r   r&   r#   r"   r2   r$   r%   N)gZ__name__Z
__module__Z__qualname__Z__firstlineno__r    r1   r   r5   rL   rS   rV   rX   r^   ri   rk   rl   rm   r>   rt   r?   r{   r   r   r   r   rz   r   r   r   r   rB   r   rC   r   r   r   r   r   r   r   r   r   r   rD   r   rE   r   r   r   r   r   r   r   r   r   r   r   r   r   rF   r   r   rG   r   r   r   r   r   r   r   r   r   r   r   r   rH   r   rI   r   r   r   r   r   r   r   r   r   r   r@   r   rA   r  r  r  r  r  r   r  r  r
  r	  Z__static_attributes__Z__classdictcell__)rN   s   @r   r   r      s    
& .`< PR V V"$$(%2 

)8.#&CJ#$ 9


,;1#&CJ&$#<


+R01(<6&CJ%$"E
X("J
-2(93&L\"$Y

1U6(*Ob+&(!K


*9/#&CJ$$!: :r!   r   ))ra   rZ   Zos.pathrc   Ztypingr    r   Zfirewallr   Zfirewall.core.loggerr   Zfirewall.core.io.io_objectr   Zfirewall.core.io.icmptyper   r   r   Zfirewall.core.io.servicer   r	   r
   Zfirewall.core.io.zoner   r   r   Zfirewall.core.io.ipsetr   r   r   Zfirewall.core.io.helperr   r   r   Zfirewall.core.io.policyr   r   r   r   Zfirewall.errorsr   r   ) r!   r   <module>r     sU     	     $ 0 P P L L @ @ D D H H H H  )T: T:r!   