/usr/lib/python3.9/site-packages/firewall/__pycache__
NameSizeModeActions
client.cpython-39.opt-1.pyc1351840644editdlrm
client.cpython-39.pyc1351840644editdlrm
command.cpython-39.opt-1.pyc179030644editdlrm
command.cpython-39.pyc179030644editdlrm
dbus_utils.cpython-39.opt-1.pyc63550644editdlrm
dbus_utils.cpython-39.pyc63550644editdlrm
errors.cpython-39.opt-1.pyc38160644editdlrm
errors.cpython-39.pyc38160644editdlrm
functions.cpython-39.opt-1.pyc154450644editdlrm
functions.cpython-39.pyc154450644editdlrm
fw_types.cpython-39.opt-1.pyc30030644editdlrm
fw_types.cpython-39.pyc30030644editdlrm
__init__.cpython-39.opt-1.pyc1440644editdlrm
__init__.cpython-39.pyc1440644editdlrm
Edit: /usr/lib/python3.9/site-packages/firewall/__pycache__/command.cpython-39.pyc (17903B)
a F‡©jÁ^ã@sfdZdgZddlZddlmZddlmZddlmZddl m Z m Z m Z m Z mZGdd„deƒZdS) z„Zd?d@„Z dgdAfdBdC„Z!dgfdDdE„Z"dgfdFdG„Z#dHdI„Z$dJdK„Z%dLdM„Z&dNdO„Z'dPdQ„Z(dRdS„Z)dTdU„Z*dVdW„Z+dXdY„Z,dZd[„Z-dS)nrFcCs||_||_d|_d|_dS©NT)ÚquietÚverboseÚ'_FirewallCommand__use_exception_handlerÚfw)Úselfr r ©rú4/usr/lib/python3.9/site-packages/firewall/command.pyÚ__init__#szFirewallCommand.__init__cCs ||_dS©N)r)rrrrrÚset_fw)szFirewallCommand.set_fwcCs ||_dSr©r ©rÚflagrrrÚ set_quiet,szFirewallCommand.set_quietcCs|jSrr©rrrrÚ get_quiet/szFirewallCommand.get_quietcCs ||_dSr©r rrrrÚ set_verbose2szFirewallCommand.set_verbosecCs|jSrrrrrrÚ get_verbose5szFirewallCommand.get_verboseNcCs"|dur|jstj |d¡dS©NÚ )r ÚsysÚstdoutÚwrite©rÚmsgrrrÚ print_msg8szFirewallCommand.print_msgcCs"|dur|jstj |d¡dSr)r r!Ústderrr#r$rrrÚprint_error_msg<szFirewallCommand.print_error_msgcCs,d}d}tj ¡r|||}| |¡dS)Nzz)r!r'Úisattyr()rr%ZFAILZENDrrrÚ print_warning@s   zFirewallCommand.print_warningrcCs,|dkr| |¡n | |¡t |¡dS)Né)r*r&r!Úexit)rr%Z exit_coderrrÚprint_and_exitGs  zFirewallCommand.print_and_exitcCs| |d¡dS)Né©r-r$rrrÚfailRszFirewallCommand.failcCs"|dur|jrtj |d¡dSr)r r!r"r#r$rrrÚprint_if_verboseUsz FirewallCommand.print_if_verbosec  Cs˜|jdur|j ¡g} d} g} |D]¨} |durÂz || ƒ} Wn„tyÀ}zlt t|ƒ¡}t|ƒdkrv| d|¡n| d||¡|| vr˜|   |¡| d7} WYd}~q$WYd}~n d}~00|   | ¡q$| D�]d} g}|durì||7}t | t ƒ�st | t ƒ�s|  | ¡n|| 7}|du�r*||7}|  ¡z ||ŽWnðttf�y.}zÒt |tƒ�rx| | ¡¡| ¡}nt|ƒ}t |¡}|tjtjtjtjfv�r¨d}t|ƒdk�rÆ| d|¡n8|dk�rî| d|¡WYd}~dS| d||¡|| v�r|   |¡| d7} WYd}~n d}~00| ¡qÒ| �s”t|ƒ| k�sXd| v�r\dSt| ƒdk�rzt | d¡nt| ƒdk�r”t tj¡dS)Nrr+ú Warning: %sú Error: %s)rZ authorizeAllÚ ExceptionrÚget_codeÚstrÚlenr*r-ÚappendÚ isinstanceÚlistÚtupleÚdeactivate_exception_handlerrÚfail_if_not_authorizedÚ get_dbus_nameÚget_dbus_messagerÚALREADY_ENABLEDÚ NOT_ENABLEDÚZONE_ALREADY_SETÚ ALREADY_SETÚactivate_exception_handlerr!r,Z UNKNOWN_ERROR)rZcmd_typeÚoptionÚ action_methodÚ query_methodÚ parse_methodÚmessageÚ start_argsÚend_argsÚno_exitÚitemsÚ_errorsZ _error_codesÚitemr%ÚcodeÚ call_itemrrrZ__cmd_sequenceYst     "         ÿ    zFirewallCommand.__cmd_sequencec Cs|jd||||||d�dS)NÚadd©rL©Ú_FirewallCommand__cmd_sequence©rrErFrGrHrIrLrrrÚ add_sequence¤s ÿzFirewallCommand.add_sequencec Cs |jd||||||g|d�dS)NrR©rJrLrT©rÚxrErFrGrHrIrLrrrÚx_add_sequence©s þzFirewallCommand.x_add_sequencec Cs$|jd||||||g|g|d� dS)NrR)rJrKrLrT) rÚzonerErFrGrHrIÚtimeoutrLrrrÚzone_add_timeout_sequence¯s þz)FirewallCommand.zone_add_timeout_sequencec Cs|jd||||||d�dS)NÚremoverSrTrVrrrÚremove_sequence¶s ÿzFirewallCommand.remove_sequencec Cs |jd||||||g|d�dS)Nr_rXrTrYrrrÚx_remove_sequence»s þz!FirewallCommand.x_remove_sequencec Cs*g}|D]Ž}|durŒz ||ƒ}WnjtyŠ} zRt|ƒdkrX| d| ¡WYd} ~ qnt t| ƒ¡} | d| | ¡WYd} ~ n d} ~ 00| |¡q|D�]v}g} |dur¶| |7} t|t ƒsÖt|t ƒsÖ|  |¡n| |7} |  ¡z || Ž} Wnät �yv} zj|  |  ¡¡t |  ¡¡} t|ƒdk�rN| d|  ¡¡WYd} ~ qœn| d|  ¡| ¡WYd} ~ njd} ~ 0t�yÖ} zHt t| ƒ¡} t|ƒdk�r²| d| ¡n| d| | ¡WYd} ~ n d} ~ 00| ¡t|ƒdk�r | d||d| f¡qœ| | ¡qœ|�s&t d¡dS)Nr+r2r3z%s: %s)ÚnoÚyesr)r4r7r*rr5r6r-r8r9r:r;r<rr=r>r?rDr&Úprint_query_resultr!r,) rrErGrHrIrJrLrMrOr%rPrQÚresrrrZ__query_sequenceÂsT  &    ÿ& z FirewallCommand.__query_sequencecCs|j|||||d�dS)NrS©Ú _FirewallCommand__query_sequence)rrErGrHrIrLrrrÚquery_sequenceôs ÿzFirewallCommand.query_sequencecCs|j|||||g|d�dS)NrXrf)rrZrErGrHrIrLrrrÚx_query_sequenceùs ÿz FirewallCommand.x_query_sequencecCsBt|ƒs>t|ƒs>t|ƒs>| d¡r.t|ƒdks>ttjd|ƒ‚|S)Nzipset:éz8'%s' is no valid IPv4, IPv6 or MAC address, nor an ipset)rrrÚ startswithr7rrÚ INVALID_ADDR©rÚvaluerrrÚ parse_sourceÿsÿþ þÿzFirewallCommand.parse_sourceú/cCsjz| |¡\}}Wn"ty4ttjd|ƒ‚Yn0t|ƒsJttj|ƒ‚|dvrbttjd|ƒ‚||fS)NzTbad port (most likely missing protocol), correct syntax is portid[-portid]%sprotocol©ZtcpZudpZsctpZdccpú''%s' not in {'tcp'|'udp'|'sctp'|'dccp'})ÚsplitÚ ValueErrorrrÚ INVALID_PORTr ÚINVALID_PROTOCOL)rrnÚ separatorÚportÚprotorrrÚ parse_ports þ  ÿÿzFirewallCommand.parse_portc Cs¬d}d}d}d}d}d||d…vrê||d… dd¡d}|t|ƒd7}d||d…vrv||d… dd¡d} n ||d…} |t| ƒd7}|dkr | }q|dkr®| }q|dkr¼| }q|dkrÊ| }q|d krØ|rØqttjd |ƒ‚q|súttjd ƒ‚|�s ttjd ƒ‚|�s$|�s$ttjd ƒ‚t|ƒ�s:ttj|ƒ‚|dv�rTttjd|ƒ‚|�rpt|ƒ�spttj|ƒ‚|�r td|ƒ�s |�s”td|ƒ�s ttj |ƒ‚||||fS)Nrú=r+ú:rxryÚtoportÚtoaddrÚifzinvalid forward port arg '%s'z missing portzmissing protocolzmissing destinationrqrrÚipv4Úipv6) rsr7rrZINVALID_FORWARDr rurvr rl) rrnÚcompatrxZprotocolr}r~ÚiÚoptÚvalrrrÚparse_forward_portsZ  ÿ       ÿÿ  z"FirewallCommand.parse_forward_portcCsF| d¡}t|ƒdkr"|ddfSt|ƒdkr2|Sttjd|ƒ‚dS)Nr{r+rÚr.zinvalid ipset option '%s')rsr7rrZINVALID_OPTION)rrnÚargsrrrÚparse_ipset_optionHs    ÿz"FirewallCommand.parse_ipset_optioncCs.ddg}||vr*ttjd|d |¡fƒ‚|S)Nr€r�ú'invalid argument: %s (choose from '%s')ú', '©rrZ INVALID_IPVÚjoin©rrnZipvsrrrÚcheck_destination_ipvRs ÿÿz%FirewallCommand.check_destination_ipvcCsBz| dd¡\}}Wnty2ttjdƒ‚Yn0| |¡|fS)Nr|r+z(destination syntax is ipv:address[/mask])rsrtrrZINVALID_DESTINATIONr�)rrnZipvZ destinationrrrÚparse_service_destinationZs ÿ z)FirewallCommand.parse_service_destinationcCs.gd¢}||vr*ttjd|d |¡fƒ‚|S)N)r€r�ZebrŠr‹rŒrŽrrrÚ check_ipvbs ÿÿzFirewallCommand.check_ipvcCs.gd¢}||vr*ttjd|d |¡fƒ‚|S)N)r‡r€r�rŠr‹rŒrŽrrrÚcheck_helper_familyjs ÿÿz#FirewallCommand.check_helper_familycCsB| d¡sttjd|ƒ‚t| dd¡ƒdkr>ttjd|ƒ‚|S)NZ nf_conntrack_z('%s' does not start with 'nf_conntrack_'r‡r+zModule name '%s' too short)rkrrZINVALID_MODULEr7ÚreplacermrrrÚ check_modulers þÿzFirewallCommand.check_moduleTc CsÜ| ¡}| ¡}| ¡}| ¡} | ¡} | ¡} | ¡} | ¡} | ¡}|  ¡}|  ¡}|rv|  ¡}|  ¡}|  ¡}n,| ¡}tt| ¡|ƒƒ}| ¡}| ¡}dd„}g}|durÈ||krÈ| d¡|sÔ|sà|sà|rê|rê|rê| d¡|�r|dd |¡}| |¡|j�r0| d|¡| d|¡|�rH| d t|ƒ¡| d |¡|�st| d |�rld nd ¡|�r¤| dd |¡¡| dd |¡¡n(| dd |¡¡| dd |¡¡| dd t|ƒ¡¡| dd dd„|Dƒ¡¡| dd t| ƒ¡¡|�s8| d|�r0d nd ¡| d| �rHd nd ¡| d| �r`dndd dd„| Dƒ¡¡| dd dd„| Dƒ¡¡| d d | ¡¡| d!|�r¾dndd t||d"�¡¡dS)#NcSsdd}d}z| |¡}Wnty(Yn80|t|ƒ7}t|||||d… d¡… dd¡ƒ}|S)Nrz priority=ú ú"r‡)Úindexrtr7Úintr“)ZruleÚpriorityZ search_strrƒrrrÚrich_rule_sorted_key’s  *zDFirewallCommand.print_zone_policy_info..rich_rule_sorted_keyÚdefaultZactivez (%s)z, ú summary: ú description: z priority: z target: z icmp-block-inversion: %srcrbz ingress-zones: r•z egress-zones: z interfaces: z sources: z services: ú ports: cSs g|]}d|d|df‘qS©z%s/%srr+r©Ú.0rxrrrÚ ¹sÿz:FirewallCommand.print_zone_policy_info..ú protocols: z forward: %sz masquerade: %sz forward-ports: z r‡cSs$g|]\}}}}d||||f‘qS)z$port=%s:proto=%s:toport=%s:toaddr=%sr)r¡rxryr}r~rrrr¢Às þ ÿú source-ports: cSs g|]}d|d|df‘qSrŸrr rrrr¢Åsÿz icmp-blocks: z rich rules: )Úkey)Z getTargetZ getServicesÚgetPortsÚ getProtocolsZ getMasqueradeZgetForwardPortsÚgetSourcePortsZ getIcmpBlocksZ getRichRulesÚgetDescriptionÚgetShortZgetIngressZonesZgetEgressZonesZ getPriorityZgetIcmpBlockInversionÚsortedÚsetZ getInterfacesZ getSourcesZ getForwardr8r�r&r r6)rr\ÚsettingsÚ default_zoneÚextra_interfacesÚisPolicyÚtargetZservicesÚportsÚ protocolsZ masqueradeZ forward_portsÚ source_portsZ icmp_blocksZrulesÚ descriptionÚshort_descriptionZ ingress_zonesZ egress_zonesr™Zicmp_block_inversionZ interfacesZsourcesZforwardršZ attributesrrrÚprint_zone_policy_info|s�    ÿÿÿ   ÿÿ  ýÿ ÿÿÿz&FirewallCommand.print_zone_policy_infocCs|j||||dd�dS)NF©r®r¯r°©r·)rr\r­r®r¯rrrÚprint_zone_infoËszFirewallCommand.print_zone_infocCs|j||||dd�dS)NTr¸r¹)rZpolicyr­r®r¯rrrÚprint_policy_infoÎsz!FirewallCommand.print_policy_infoc Cs.| ¡}| ¡}| ¡}| ¡}| ¡}| ¡}| ¡} | ¡} | ¡} |  |¡|j rt|  d| ¡|  d|¡|  dd  dd„|Dƒ¡¡|  dd  |¡¡|  dd  d d„|Dƒ¡¡|  d d  |¡¡|  d d  d d„|  ¡Dƒ¡¡|  d d  t | ƒ¡¡|  dd  t | ƒ¡¡dS)Nrœr�ržr•cSs g|]}d|d|df‘qSrŸrr rrrr¢ßsÿz6FirewallCommand.print_service_info..r£r¤cSs g|]}d|d|df‘qSrŸrr rrrr¢ãsÿz modules: ú destination: cSsg|]\}}d||f‘qS)z%s:%sr©r¡ÚkÚvrrrr¢çsÿz includes: z helpers: )r¦r§r¨Z getModulesr©ÚgetDestinationsrªZ getIncludesZ getHelpersr&r r�rMr«) rZservicer­r²r³r´ÚmodulesrµÚ destinationsr¶ZincludesZhelpersrrrÚprint_service_infoÑs< ÿ  ÿÿ ÿÿz"FirewallCommand.print_service_infocCsp| ¡}| ¡}| ¡}t|ƒdkr,ddg}| |¡|jrX| d|¡| d|¡| dd |¡¡dS)Nrr€r�rœr�r¼r•)rÀr©rªr7r&r r�)rZicmptyper­rÂrµr¶rrrÚprint_icmptype_infoìs  z#FirewallCommand.print_icmptype_infocCsœ| ¡}| ¡}| ¡}| ¡}| ¡}| |¡|jrT| d|¡| d|¡| d|¡| dd dd„| ¡Dƒ¡¡| dd |¡¡dS) Nrœr�z type: z options: r•cSs$g|]\}}|rd||fn|‘qS)z%s=%srr½rrrr¢sÿz4FirewallCommand.print_ipset_info..z entries: ) ZgetTypeZ getOptionsZ getEntriesr©rªr&r r�rM)rZipsetr­Z ipset_typeÚoptionsÚentriesrµr¶rrrÚprint_ipset_infoøs ÿ z FirewallCommand.print_ipset_infocCs’| ¡}| ¡}| ¡}| ¡}| ¡}| |¡|jrT| d|¡| d|¡| d|¡| d|¡| dd dd„|Dƒ¡¡dS) Nrœr�z family: z module: ržr•cSs g|]}d|d|df‘qSrŸrr rrrr¢sÿz5FirewallCommand.print_helper_info..)r¦Z getModuleZ getFamilyr©rªr&r r�)rÚhelperr­r²ÚmoduleZfamilyrµr¶rrrÚprint_helper_infos ÿz!FirewallCommand.print_helper_infocCs |r| d¡n | dd¡dS)Nrcrbr+r/rmrrrrds z"FirewallCommand.print_query_resultcCs\|js‚| |¡t t|ƒ¡}|tjtjtjtj fvrH|  d|¡n|  d||¡dS)Nr2r3) rr=rr5r6rr@rArBrCr*r-)rÚexception_messagerPrrrÚexception_handlers  ÿz!FirewallCommand.exception_handlercCsd|vrd}| |tj¡dS)NZNotAuthorizedExceptionz`Authorization failed. Make sure polkit agent is running or run the application as superuser.)r-rZNOT_AUTHORIZED)rrËr%rrrr='sz&FirewallCommand.fail_if_not_authorizedcCs d|_dS)NF©rrrrrr<-sz,FirewallCommand.deactivate_exception_handlercCs d|_dSr rÍrrrrrD0sz*FirewallCommand.activate_exception_handlercCsng}tƒ}t|ƒ}|D]J}|s"qb| ¡}t|ƒdks|ddvrDq||vr| |¡| |¡q| ¡|S)Nr+r)ú#ú;)r¬ÚopenÚstripr7r8rRÚclose)rÚfilenamerÆZ entries_setÚfÚlinerrrÚget_ipset_entries_from_file3s  z+FirewallCommand.get_ipset_entries_from_file)FF)N)N)N)Nr)N)N)NNF)F)F)F)F)F)NF)F)F)rp)F).Ú__name__Ú __module__Ú __qualname__rrrrrrr&r(r*r-r0r1rUrWr[r^r`rargrhrirorzr†r‰r�r�r‘r’r”r·rºr»rÃrÄrÇrÊrdrÌr=r<rDrÖrrrrr"sj      þ Lÿ ÿ þ ÿ ÿ ÿ 3ÿ ÿ   2  O  )Ú__doc__Ú__all__r!ZfirewallrZfirewall.errorsrZdbus.exceptionsrZfirewall.functionsrrrr r ÚobjectrrrrrÚs