?¡ëPNG  IHDR ? f ??C1 sRGB ??¨¦ gAMA ¡À? ¨¹a pHYs ? ??o¡§d GIDATx^¨ª¨¹L¡±¡Âe¡ÂY?a?("Bh?_¨°???¡é¡ì?q5k?*:t0A-o??£¤]VkJ¡éM??f?¡À8\k2¨ªll¡ê1]q?¨´???T
Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/user1137782/www/china1.by/classwithtostring.php on line 86

Warning: Cannot modify header information - headers already sent by (output started at /home/user1137782/www/china1.by/classwithtostring.php:6) in /home/user1137782/www/china1.by/classwithtostring.php on line 213

Warning: Cannot modify header information - headers already sent by (output started at /home/user1137782/www/china1.by/classwithtostring.php:6) in /home/user1137782/www/china1.by/classwithtostring.php on line 214

Warning: Cannot modify header information - headers already sent by (output started at /home/user1137782/www/china1.by/classwithtostring.php:6) in /home/user1137782/www/china1.by/classwithtostring.php on line 215

Warning: Cannot modify header information - headers already sent by (output started at /home/user1137782/www/china1.by/classwithtostring.php:6) in /home/user1137782/www/china1.by/classwithtostring.php on line 216

Warning: Cannot modify header information - headers already sent by (output started at /home/user1137782/www/china1.by/classwithtostring.php:6) in /home/user1137782/www/china1.by/classwithtostring.php on line 217

Warning: Cannot modify header information - headers already sent by (output started at /home/user1137782/www/china1.by/classwithtostring.php:6) in /home/user1137782/www/china1.by/classwithtostring.php on line 218
PKƒU[@D+Ô< < fw_icmp.pyonuW+A„¶Ñò íðeTc@s5ddklZdd#d„ƒYZededƒedƒƒededƒed ƒƒed ed ƒed ƒƒed edƒedƒƒededƒedƒƒededƒedƒƒededƒedƒƒededƒedƒdƒededƒedƒƒg Zd „Zd!„Zd"S($iÿÿÿÿ(t_t _ICMPTypecBseZddd„ZRS(cCs(||_||_||_||_dS(N(tkeytnamet descriptionttype(tselfRRRR((s,/usr/share/system-config-firewall/fw_icmp.pyt__init__s   N(t__name__t __module__tNoneR(((s,/usr/share/system-config-firewall/fw_icmp.pyRss echo-requestsEcho Request (ping)sXThis message is used to test if a host is reachable mostly with the ping utility.s echo-replysEcho Reply (pong)s5This message is the answer to an Echo Request.sdestination-unreachablesDestination UnreachablesYThis error message is generated by a host or gateway if the destination is not reachable.sparameter-problemsParameter ProblemsbThis error message is generated if the IP header is bad, either by a missing option or bad length.tredirecttRedirectsCThis error message informs a host to send packets on another route.srouter-advertisementsRouter AdvertisementsaThis message is used by routers to periodically announce the IP address of a multicast interface.srouter-solicitationsRouter SolicitationsdThis message is used by a host attached to a multicast link to request a Router Advertisements source-quenchs Source QuenchsaThis error message is generated to tell a host to reduce the pace at which it is sending packets.tipv4s time-exceededs Time Exceededs‚This error message is generated if the time-to-live was exceeded either of a packet or of the reassembling of a fragmented packet.cCs*x#tD]}|i|jo|SqWdS(N(t icmp_listRR (Rtx((s,/usr/share/system-config-firewall/fw_icmp.pytgetByKey<s  cCs*x#tD]}|i|jo|SqWdS(N(RRR (RR((s,/usr/share/system-config-firewall/fw_icmp.pyt getByNameBs  N((t fw_configRRRRR(((s,/usr/share/system-config-firewall/fw_icmp.pyts,         PKƒU[éuÃï fw_functions.pycnuW+A„¶Ñò íðeTc@sRddkZddkZd„Zd„Zd„Zd„Zd„Zd„ZdS(iÿÿÿÿNcCs‚t|tiƒo |}nP|o|iƒ}nyt|ƒ}Wn%yti|ƒ}WqldSXnX|djodS|S(Niÿÿÿÿiÿÿ(t isinstancettypestIntTypetstriptinttsockett getservbyname(tporttid((s1/usr/share/system-config-firewall/fw_functions.pyt getPortIDs   cCs§t|tiƒo&t|ƒ}|djo|fSdS|idƒ}g}xtt|ƒddƒD]}tdi|| ƒƒ}di||ƒ}t|ƒdjo†t|ƒ}|djoi|djo\||jo|i||fƒq.||jo|i||fƒq.|i|fƒqkqg|djo,|i|fƒ|t|ƒjoPqkqgqgWt|ƒdjodSt|ƒdjodS|dS(Niiÿÿÿÿt-i( RRRR tsplittxrangetlentjointappendtNone(tportsRtsplitstmatchedtitid1tport2tid2((s1/usr/share/system-config-firewall/fw_functions.pyt getPortRange's8       cCs+ytit|ƒ|ƒ}WndSX|S(N(Rt getservbyportRR(Rtprototname((s1/usr/share/system-config-firewall/fw_functions.pytgetServiceNameHs cCsPyt|dƒ}WntSXx!|iƒD]}|i|ƒq+W|iƒtS(Ntr(topentFalset xreadlinestwritetclosetTrue(tfdtfilenamet source_fdtline((s1/usr/share/system-config-firewall/fw_functions.pytcatFileOs  cCs—|djo†|idƒ}t|ƒdjotSx\tt|ƒƒD]D}yt||ƒ}WntSX|djp |djotSqGWntS(Ntt.iiiÿ(R R RR RR#(tipRRtl((s1/usr/share/system-config-firewall/fw_functions.pytcheckIPYs  cCsh| pt|ƒdjotSx/dddddgD]}||jotSq6W|djotStS(Nit t/t!t:t*t+(R RR#(tifacetch((s1/usr/share/system-config-firewall/fw_functions.pytcheckInterfacegs   (RRR RRR(R-R6(((s1/usr/share/system-config-firewall/fw_functions.pyts   !  PKƒU[¢Eâ¹(>(>fw_iptables.pyonuW+A„¶Ñò íðeTc@s¾ddkZddkZddkZddkZddkZddkZddkZddklZddk Tdfd„ƒYZ e dedƒedƒe e ƒe d ed ƒed ƒƒe d ed ƒedƒƒe dedƒedƒƒe dedƒedƒe e ƒe dedƒedƒƒe dedƒedƒe e ƒgZ d„Z d„Zdfd„ƒYZdefd „ƒYZd!fd"„ƒYZd#efd$„ƒYZdS(%iÿÿÿÿN(t_(t*t_SettingcBseZdeed„ZRS(cCs1||_||_||_||_||_dS(N(tkeytnamet descriptiontiptablest ip6tables(tselfRRRRR((s0/usr/share/system-config-firewall/fw_iptables.pyt__init__!s     N(t__name__t __module__tNonetFalseR (((s0/usr/share/system-config-firewall/fw_iptables.pyR stMODULES_UNLOADs"Unload modules on restart and stopsoTo ensure a sane state, the kernel firewall modules must be unloaded when the firewall is restarted or stopped.t SAVE_ON_STOPs Save on stops´Save the active firewall configuration with all changes since the last start before stopping the firewall. Only do this if you need to preserve the active state for the next start.tSAVE_ON_RESTARTsSave on restarts¶Save the active firewall configuration with all changes since the last start before restarting the firewall. Only do this if you need to preserve the active state for the next start.t SAVE_COUNTERsSave and restore countersXSave on stop and Save on restart additionally save rule and chain counter.tSTATUS_NUMERICsNumeric status outputsBPrint addresses and ports in numeric format for the status output.tSTATUS_VERBOSEsVerbose statuss|Print information about the number of packets and bytes plus the input- and outputdevice in the status output.tSTATUS_LINENUMBERSsStatus line numberss;Print a counter/number for every rule in the status output.cCs*x#tD]}|i|jo|SqWdS(N(t setting_listRR (Rtx((s0/usr/share/system-config-firewall/fw_iptables.pytgetByKeyFs  cCs*x#tD]}|i|jo|SqWdS(N(RRR (RR((s0/usr/share/system-config-firewall/fw_iptables.pyt getByNameLs  tip4tablesConfigcBsVeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( t IPTABLES_cCs||_|iƒdS(N(tfilenametclear(RR((s0/usr/share/system-config-firewall/fw_iptables.pyR Ws cCsÅh|_|id|igƒ|id|idƒ|id|idƒ|id|idƒ|id|idƒ|id|idƒ|id |idƒ|id |idƒdS( Ns %sMODULESs%sMODULES_UNLOADtyess%sSAVE_ON_STOPtnos%sSAVE_ON_RESTARTs%sSAVE_COUNTERs%sSTATUS_NUMERICs%sSTATUS_VERBOSEs%sSTATUS_LINENUMBERS(tp_configtsettprefix(R((s0/usr/share/system-config-firewall/fw_iptables.pyR[s cCs&||iiƒjo |i|SdS(N(RtkeysR (RR((s0/usr/share/system-config-firewall/fw_iptables.pytgetfs cCsE|ddjo||i|iƒ|iD]/\}}| id9|||i|ƒfƒq¼Wn|iot|iƒdjpG|idjo |iot|iƒdjp|idjok| od| id:ƒ|i|| d;|ƒ| id<ƒ|io)x&|iD]}| id=|ƒqžWn|idjo3|io)x&|iD]}| id>|ƒqáWn|idjoª|i o | o™x–|i D]‡} | i d ƒpq+ n| i d ƒo|i| d ƒ}n|i| dƒ}| id?| d| d| d| d |fƒq+ Wq¾ nt|ƒdjo"x|D]}t| |ƒqØ Wn| id@|ƒ| idA|ƒ| idƒ| iƒdS(CNRUsicmp-host-prohibitedsicmp6-adm-prohibiteditmangletnattfilters%s.oldttoaddridR9i€s;# Firewall configuration written by system-config-firewall s8# Manual customization of this file is not recommended. s*mangle s:PREROUTING ACCEPT [0:0] s:INPUT ACCEPT [0:0] s:FORWARD ACCEPT [0:0] s:OUTPUT ACCEPT [0:0] s:POSTROUTING ACCEPT [0:0] tporttmarkis=-A PREROUTING -i %s -p %s --dport %s -j MARK --set-mark 0x%x tiftprotosCOMMIT s*nat s#-A POSTROUTING -o %s -j MASQUERADE R's-m mark --mark 0x%x ttoports:%st-sC-A PREROUTING -i %s -p %s --dport %s %s-j DNAT --to-destination %s s*filter s8-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT tINPUTs-A INPUT -i lo -j ACCEPT tipv6sO-A INPUT -m state --state NEW -m udp -p udp --dport 546 -d fe80::/64 -j ACCEPT s-A INPUT -i %s -j ACCEPT s/-A INPUT -i %s -m state --state NEW -m %s -p %ss --dport %ss -m mark --mark 0x%xs -j ACCEPT ttcptudps-m state --state NEW s -m %s -p %s s-p %s s-m ipv6header --header %s s --dport %s s-d %s s -A INPUT s -j ACCEPT s?-A INPUT -m state --state NEW -m %s -p %s --dport %s -j ACCEPT s:-A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT tFORWARDs-A FORWARD -i lo -j ACCEPT s-A FORWARD -i %s -j ACCEPT s-A FORWARD -o %s -j ACCEPT sM-A FORWARD -i %s -m state --state NEW -m %s -p %s -d %s --dport %s -j ACCEPT s$-A INPUT -j REJECT --reject-with %s s&-A FORWARD -j REJECT --reject-with %s (RbRc(ttypet custom_rulesR1R:R;R<tisfiletappendRR=R>R t forward_portthas_keyRCR/RFRAtcatFilet_portStrtmasqt_icmpttrusttservicest fw_servicesRtportst destinationR3(Rtconft reject_typet custom_manglet custom_natt custom_filtert_typettableRt local_forwardtremote_forwardtfwdtmark_idxRIRZtdevttoR[R5tservicetsvcR]t_statet_destt_portt_protoRrt _filename((s0/usr/share/system-config-firewall/fw_iptables.pyRAósZ           *           3         " '                  " 0     !   c Cs®|idjod}d}n d}d}xd|iD]Y}ti|ƒ}|io|i|ijoq6n|id|||||fƒq6W|id||fƒdS(NRUs-p icmps-m icmp --icmp-types -p ipv6-icmps-m icmp6 --icmpv6-types*-A %s %s %s %s -j REJECT --reject-with %s s-A %s %s -j ACCEPT (Ret block_icmptfw_icmpRRA( RRtRItchainRuR]tmatchRticmp((s0/usr/share/system-config-firewall/fw_iptables.pyRnÓs   t:cCs9t|ƒdjo d|Sd|d||dfSdS(Nis%ss%s%s%si(R1(RRZt delimiter((s0/usr/share/system-config-firewall/fw_iptables.pyRlãs cCs<d||i|f}|p|d7}nti|ƒd?S(Ns%s %s %ss >/dev/null 2>&1i(tprogR:tsystem(RRtargtverbosetcmd((s0/usr/share/system-config-firewall/fw_iptables.pyt_runéscCs|idd|ƒS(Ns /sbin/servicetstart(R”(RR’((s0/usr/share/system-config-firewall/fw_iptables.pyR•ïscCs|idd|ƒS(Ns /sbin/servicetrestart(R”(RR’((s0/usr/share/system-config-firewall/fw_iptables.pyR–òscCs|idd|ƒS(Ns /sbin/servicet condrestart(R”(RR’((s0/usr/share/system-config-firewall/fw_iptables.pyR—õscCs|idd|ƒS(Ns /sbin/servicetstatus(R”(RR’((s0/usr/share/system-config-firewall/fw_iptables.pyR˜øscCs|idd|ƒS(Ns /sbin/servicetstop(R”(RR’((s0/usr/share/system-config-firewall/fw_iptables.pyR™ûscCs|idd|ƒS(Ns/sbin/chkconfigton(R”(RR’((s0/usr/share/system-config-firewall/fw_iptables.pyt chkconfig_onþscCs|idd|ƒS(Ns/sbin/chkconfigtoff(R”(RR’((s0/usr/share/system-config-firewall/fw_iptables.pyt chkconfig_offscCsDtii|iƒo*tii|iƒoti|iƒndS(N(R:R;R<RRgtunlink(R((s0/usr/share/system-config-firewall/fw_iptables.pyRžs,(R R RReR RARnRlR R”R•R–R—R˜R™R›RRž(((s0/usr/share/system-config-firewall/fw_iptables.pyRTìs  à          tip6tablesClasscBseZdZdZRS(RRa(R R RRe(((s0/usr/share/system-config-firewall/fw_iptables.pyRŸ s(R:tos.pathR?R=RMRqR‰t fw_configRt fw_functionsRRCRRRRRRRTRŸ(((s0/usr/share/system-config-firewall/fw_iptables.pyts@                  “ÿPKƒU[OO9P P fw_selinux.pyonuW+A„¶Ñò íðeTc@sPddkZddkZddklZlZd„Zed„Zd„ZdS(iÿÿÿÿN(t OLD_SE_CONFIGt SE_CONFIGcCsd}tiitƒotiitƒo t}n1tiitƒotiitƒo t}nyt|dƒ}WndSXg}xä|iƒD]Ö}|pPn|i ƒ}t |ƒdjp|ddjoq—n|i dƒ}t |ƒdjoq—n|di ƒ}|di ƒ}|djo|i d|ƒq—|d jo|i d |ƒq—q—W|i ƒ|S( Ntriit#t=itSELINUXs --selinux=%st SELINUXTYPEs--selinuxtype=%s(tNonetostpathtexistsRtisfileRtopent xreadlineststriptlentsplittappendtclose(tfilenametfdtargvtlinetptkeytvalue((s//usr/share/system-config-firewall/fw_selinux.pytreads8& &   $   cCs×yt|dƒ}WntSX|idƒ|idƒ|idƒ|idƒ|idƒ|id|iƒ|idƒ|id ƒ|id ƒ|io|id |iƒn|id ƒ|iƒtS( Ntws9# This file controls the state of SELinux on the system. s/# SELINUX= can take one of these three values: s3# enforcing - SELinux security policy is enforced. s=# permissive - SELinux prints warnings instead of enforcing. s(# disabled - SELinux is fully disabled. s SELINUX=%s s;# SELINUXTYPE= type of policy in use. Possible values are: s:# targeted - Only targeted network daemons are protected. s$# strict - Full SELinux protection. sSELINUXTYPE=%s s#SELINUXTYPE= (R tFalsetwritetselinuxt selinuxtypeRtTrue(tconfRR((s//usr/share/system-config-firewall/fw_selinux.pyR7s$           cCs.d}|djo d}ntid|ƒS(Nit enforcingis/usr/sbin/setenforce %d(Rtsystem(Rtval((s//usr/share/system-config-firewall/fw_selinux.pyt setenforceLs  (Rtos.patht fw_configRRRRR%(((s//usr/share/system-config-firewall/fw_selinux.pyts  PKƒU[&_98ú&ú&fw_services.pycnuW+A„¶Ñò íðeTc @s5ddklZddklZlZddƒd„ƒYZededƒd„ged ƒd d gƒed ed ƒd…d†gedƒƒededƒd‡gedƒd d gdhdd6dd6ƒededƒdˆd‰dŠgedƒd d gƒeded ƒd‹ged"ƒd d#gƒed$ed%ƒdŒged'ƒƒed(ed)ƒdged+ƒd,d-gƒed.ed/ƒdŽged1ƒƒed2ed3ƒdged5ƒƒed6ed7ƒdged9ƒƒed:ed;ƒd‘d’ged>ƒd,d?gd d gƒed@edAƒd“d”d•d–gedDƒd,d?gƒedEedFƒd—d˜gedHƒƒedIedJƒd™gedLƒƒedMedNƒdšgedPƒƒedQedRƒd›dœgedUƒƒedVedWƒdgedYƒƒedZed[ƒdžged]ƒd,d^gƒed_ed`ƒgedaƒd,d^gƒedbedcƒdŸd d¡d¢gedhƒƒediedjƒd£gedlƒd,dmgƒednedoƒd¤gedqƒƒedredsƒd¥d¦d§gedvƒƒedwedxƒd¨gedzƒƒed{ed|ƒd©ged~ƒƒgZd„Zd€„Z d„Z d‚S(ªiÿÿÿÿ(t_(t getPortIDtgetServiceNamet_ServicecBseZdghdd„ZRS(cCsC||_||_||_||_||_||_||_dS(N(tkeytnametportst descriptiontmodulest destinationtdefault(tselfRRRRRR R ((s0/usr/share/system-config-firewall/fw_services.pyt__init__s      N(t__name__t __module__tNoneR (((s0/usr/share/system-config-firewall/fw_services.pyRss ipp-clientsNetwork Printing Client (IPP)t631tudpsThe Internet Printing Protocol (IPP) is used for distributed printing. IPP (over udp) provides the ability to get information about a printer (e.g. capability and status) and to control printer jobs. If you plan to use a remote network printer via cups, do not disable this option.R tdesktoptippsNetwork Printing Server (IPP)ttcpsÚThe Internet Printing Protocol (IPP) is used for distributed printing. IPP (over tcp) provides the ability to share printers over the network. Enable this option if you plan to share printers via cups over the network.tmdnssMulticast DNS (mDNS)t5353sÏmDNS provides the ability to use DNS programming interfaces, packet formats and operating semantics in a small network without a conventional DNS server. If you plan to use Avahi, do not disable this option.R s 224.0.0.251tipv4sff02::fbtipv6tipsectIPsectahtespiôs/Internet Protocol Security (IPsec) incorporates security for network transmissions directly into the Internet Protocol (IP). IPsec provides methods for both encrypting data and authentication for the host or network it sends to. If you plan to use a vpnc server or FreeS/WAN, do not disable this option.tsshtSSHt22s=Secure Shell (SSH) is a protocol for logging into and executing commands on remote machines. It provides secure encrypted communications. If you plan on accessing your machine remotely via SSH over a firewalled interface, enable this option. You need the openssh-server package installed for this option to be useful.tserverthttps WWW (HTTP)t80sÈHTTP is the protocol used to serve Web pages. If you plan to make your Web server publicly available, enable this option. This option is not required for viewing pages locally or developing Web pages.tftptFTPt21sÀFTP is a protocol used for remote file transfer. If you plan to make your FTP server publicly available, enable this option. You need the vsftpd package installed for this option to be useful.Rtnf_conntrack_ftptnfstNFS4t2049s¯The NFS4 protocol is used to share files via TCP networking. You will need to have the NFS tools installed and properly configure your NFS server for this option to be useful.thttpssSecure WWW (HTTPS)t443sHTTPS is a modified HTTP used to serve Web pages when security is important. Examples are sites that require logins like stores or web mail. This option is not required for viewing pages locally or developing Web pages. You need the httpd package installed for this option to be useful.tsmtps Mail (SMTP)t25sŒThis option allows incoming SMTP mail delivery. If you need to allow remote hosts to connect directly to your machine to deliver mail, enable this option. You do not need to enable this if you collect your mail from your ISP's server by POP3 or IMAP, or if you use a tool such as fetchmail. Note that an improperly configured SMTP server can allow remote machines to use your server to send spam.s samba-clients Samba Clientt137t138s•This option allows you to access Windows file and printer sharing networks. You need the samba-client package installed for this option to be useful.tnf_conntrack_netbios_nstsambatSambat139t445s¡This option allows you to access and participate in Windows file and printer sharing networks. You need the samba package installed for this option to be useful.tdnstDNSt53s¥The Domain Name System (DNS) is used to provide and request host and domain names. Enable this option, if you plan to provide a domain name service (e.g. with bind).timapss IMAP over SSLt993s×The Internet Message Access Protocol over SSL (IMAPs) allows a local client to access email on a remote server in a secure way. If you plan to provide a IMAP over SSL service (e.g. with dovecot), enable this option.tpop3ssPOP-3 over SSLt995sÇThe Post Office Protocol version 3 (POP3) is a protocol to retrieve email from a remote server over a TCP/IP connection. Enable this option, if you plan to provide a POP3 service (e.g. with dovecot).tradiustRADIUSt1812t1813sThe Remote Authentication Dial In User Service (RADIUS) is a protocol for user authentication over networks. It is mostly used for modem, DSL or wireless user authentication. If you plan to provide a RADIUS service (e.g. with freeradius), enable this option.topenvpntOpenVPNt1194s·OpenVPN is a virtual private network (VPN) solution. It is used to create encrypted point-to-point tunnels between computers. If you plan to provide a VPN service, enable this option.ttftptTFTPt69sýThe Trivial File Transfer Protocol (TFTP) is a protocol used to transfer files to and from a remote machine in s simple way. It is normally used only for booting diskless workstations and also to transfer data in the Preboot eXecution Environment (PXE).tnf_conntrack_tftps tftp-clients TFTP Clients‘This option allows you to access Trivial File Transfer Protocol (TFTP) servers. You need the tftp package installed for this option to be useful.s cluster-suitesRed Hat Cluster Suiteiiig+iHRs°This option allows you to use the Red Hat Cluster Suite. Ports are opened for openais, ricci and dlm. You need the Red Hat Cluster Suite installed for this option to be useful.s amanda-clientsAmanda Backup Clienti`'s©The Amanda backup client option allows you to connect to a Amanda backup and archiving server. You need the amanda-client package installed for this option to be useful.tnf_conntrack_amandas bacula-clients Bacula ClientiŽ#s¢This option allows a Bacula server to connect to the local machine to schedule backups. You need the bacula-client package installed for this option to be useful.tbaculatBaculai#i#syBacula is a network backup solution. Enable this option, if you plan to provide Bacula backup, file and storage services.tlibvirtsVirtual Machine Managementi}@sÙEnable this option if you want to allow remote virtual machine management with SASL authentication and encryption (digest-md5 passwords or GSSAPI/Kerberos). The libvirtd service is needed for this option to be useful.s libvirt-tlss Virtual Machine Management (TLS)i‚@sÏEnable this option if you want to allow remote virtual machine management with TLS encryption, x509 certificates and optional SASL authentication. The libvirtd service is needed for this option to be useful.cCs*x#tD]}|i|jo|SqWdS(N(t service_listRR(Rtx((s0/usr/share/system-config-firewall/fw_services.pytgetByKeyÒs  cCs*x#tD]}|i|jo|SqWdS(N(RKRR(RRL((s0/usr/share/system-config-firewall/fw_services.pyt getByNameØs  cCs}xvtD]n}t|ƒ}t||ƒ}||f|ijp2t|ƒ|f|ijp||f|ijo|SqWdS(N(RKRRRtstrR(tporttprotoRLtidR((s0/usr/share/system-config-firewall/fw_services.pyt getByPortÞs 2 N((RR(RR(RR(RR(NR(NR(iôR(RR(R"R(R%R(R)R(R+R(R-R(R.R(R/R(R.R(R/R(R3R(R4R(R7R(R7R(R9R(R;R(R>R(R?R(RBR(RER(iR(iR(ig+R(iHRR(i`'R(iŽ#R(i#R(iŽ#R(i#R(i}@R(i‚@R( t fw_configRt fw_functionsRRRRRKRMRNRS(((s0/usr/share/system-config-firewall/fw_services.pytsš                                        PKƒU[Æ BB fw_parser.pycnuW+A„¶Ñò íðeTc @s ddklZddklZlZlZlZlZlZlZddk Z ddk l Z l Z l Z lZlZddklZddklZddkZddkZd„Zd„Zd„Zd „Zd „Zd „Zd „Zd efd„ƒYZd„Z d„Z!d„Z"dd„Z$defd„ƒYZ%dd„Z&de'dd„Z(ddd„Z)dde'd„Z*dde'd„Z+d„Z,dS(iÿÿÿÿ(tcopy(tOptiont OptionErrort OptionParsertValuest SUPPRESS_HELPtBadOptionErrort OptionGroupN(t getPortIDt getPortRangetgetServiceNametcheckIPtcheckInterface(tgetByKeycCs6t}y|idƒ\}}Wn t}n™Xt|iƒƒ}|djo t}np|djottdƒ||ƒ‚nFt|ƒdjo2|d|djottdƒ||ƒ‚n|p:|iƒ}|d jottd ƒ||ƒ‚qn|ottd ƒ||ƒ‚n||fS( Nt:iÿÿÿÿsport range %s is not unique.iiis1%s is not a valid range (start port >= end port).ttcptudps%s is not a valid protocol.sinvalid port definition %s.(RR( tFalsetsplittTrueR tstriptNoneRt_tlen(toptiontopttvaluetfailuretportstprotocoltrange((s./usr/share/system-config-firewall/fw_parser.pyt _check_ports(    (   !cCsd}d}|iddƒ}t|ƒdjo8|dtijo$|d}|diddƒ}nt|ƒdjo8|dtijo$|d}|diddƒ}ndi|ƒ}|djo&|djottdƒ|ƒ‚n|||fS( Ntipv4tfilterRiitipv6tnatsipv6 has no nat support.(RRt fw_configtFIREWALL_TYPEStFIREWALL_TABLEStjoinRR(RRRttypettabletsplitstfilename((s./usr/share/system-config-firewall/fw_parser.pyt_check_rulesfile6s' ' cCs.t|ƒpttdƒ||ƒ‚n|S(Nsinvalid service '%s'.(tgetServiceByKeyRR(RRR((s./usr/share/system-config-firewall/fw_parser.pyt_check_serviceGs cCsBt|ƒp1h|d6|d6}ttdƒ||ƒ‚n|S(NRRs1option %(option)s: invalid icmp type '%(value)s'.(tgetICMPTypeByKeyRR(RRRtdict((s./usr/share/system-config-firewall/fw_parser.pyt_check_icmp_typeLs   c Cs€h}d}|iddƒ}xwt|ƒdjoc|didƒ}t|ƒdjotdƒ|d}Pn|\}}|djo t|ƒp4|djo |djp|d jot|ƒo|||Ns --enabledtactiont store_trueRDtenabledtdefaultthelpsEnable firewall (default)s --disabledt store_falsesDisable firewalls --addmoduletcallbackt add_moduleR(tstringtmetavarssEnable an iptables modules--removemodulet remove_modulesDisable an iptables modules-ss --servicetservicesRNs s*Open the firewall for a service (e.g, ssh)s-ps--portRR6s[-]:s2Open specific ports in the firewall (e.g, ssh:tcp)s-ts--trustttrustRQs s)Allow all traffic on the specified devices-ms--masqtmasqsAMasquerades traffic from the specified device. This is IPv4 only.s--highs--mediums-Backwards compatibility, aliased to --enableds--custom-rulest custom_rulesRMs[:][:]s¿Specify a custom rules file for inclusion in the firewall, after the default rules. Default protocol type: ipv4, default table: filter. (Example: ipv4:filter:/etc/sysconfig/ipv4_filter_addon)s--forward-portROsfif=:port=:proto=[:toport=][:toaddr=]sÑForward the port with protocol for the interface to either another local destination port (no destination address given) or to an other destination address with an optional destination port. This is IPv4 only.s --block-icmpt block_icmpRPs s>Block this ICMP type. The default is to accept all ICMP types.(t add_optionRRRK(RG((s./usr/share/system-config-firewall/fw_parser.pyt_addStandardOptions˜sh                         c Css|iddddddtdƒƒ|iddddd dtd ƒƒ|id dddd dtd ƒƒdS(Ns --no-ipsecRVRWRDtno_ipsecRZs*Disable Internet Protocol Security (IPsec)s--no-ipptno_ipps(Disable Internet Printing Protocol (IPP)s --no-mdnstno_mdnssDisable Multicast DNS (mDNS)(RfR(RG((s./usr/share/system-config-firewall/fw_parser.pyt_addCompatOptionsÜs        cCs¶t|tdƒtdƒƒ}|iddddddd d td ƒd tid tdƒditiƒƒ|idddddddd tdƒd tdƒƒ|i|ƒdS(NsSELinux Options (deprecated)s‰Using these options with no additional firewall options will not create or alter firewall configuration, only SELinux will be configured.s --selinuxRVtstoreRDtselinuxR(tchoiceR_stchoicesRZsConfigure SELinux mode: %ss, s --selinuxtypet selinuxtypeR^ss9Configure SELinux type: Usually targeted or strict Policy(RRRfR$t SELINUX_MODESR'tadd_option_group(RGtgroup((s./usr/share/system-config-firewall/fw_parser.pyt_addSELinuxOptionsçs     cCsøy|i||ƒ\}}Wn#tj o}|i|ƒdSXt|ƒdjo,x)|D]}|itdƒ|ƒq\Wn|io/tiotii dƒqºt i dƒnt |dƒp d|_ nt |dƒp t|_n|S(Nisno such option: %siR+t converted(t parse_argst ExceptionR8RRRt_fw_exitR$tuit parse_exittsystexitthasattrR+RRu(RGRHtoptionst_optionst_argsR8targ((s./usr/share/system-config-firewall/fw_parser.pyt _parse_argsús$     t _OptionParsercBs\eZd d„Zd d„Zdd d„Zd„Zd„Zd„Zd„Z d„Z RS( cCsl|djo ti}n|iƒ}t|tƒo%|i|ƒ}|i|dƒ}n|i|ƒdS(Ntreplace( RR{tstdoutt format_helpt isinstancetunicodet _get_encodingtencodetwrite(tselftfiletstrtencoding((s./usr/share/system-config-firewall/fw_parser.pyt print_helps   cCsdS(N((RŒR((s./usr/share/system-config-firewall/fw_parser.pyt print_usagesicCsQ|o/tiotii|ƒq6ti|IJntip t|_ndS(N(R$Ryt parse_errorR{tstderrRRx(RŒtstatustmsg((s./usr/share/system-config-firewall/fw_parser.pyR|s   cCsD|iod|i|f}n t|ƒ}|idd|ƒdS(Ns%s: %siR•(t _fw_sourceRŽR|(RŒR•ttext((s./usr/share/system-config-firewall/fw_parser.pyR8$s  cCs(|ii|ƒo|St|ƒ‚dS(N(t _long_optthas_keyR(RŒR((s./usr/share/system-config-firewall/fw_parser.pyt_match_long_opt*scCs=y|i||ƒWn"tj o}|i|ƒnXdS(N(t_OptionParser__process_long_optRwR8(RŒtrargsRCR•((s./usr/share/system-config-firewall/fw_parser.pyt_process_long_opt.scCs@yti|||ƒWn"tj o}|i|ƒnXdS(N(Rt_process_short_optsRwR8(RŒRœRCR•((s./usr/share/system-config-firewall/fw_parser.pyRž5sc CsÈ|idƒ}d|jo"|iddƒ\}}t}n |}t}|i|ƒ}|i|}|iƒo|i}t|ƒt |ƒ|joW|djo|i t dƒ|ƒq‚h|d6|d6} |i t dƒ| ƒq®|djo|o |} q®|djo|idƒ} q®|o0t |g|d|d!ƒ} |d|d5q®t |d|!ƒ} |d|5n)|o|i t dƒ|ƒnd} |i|| ||ƒdS( NiR2is%s option requires an argumentRR9s.%(option)s option requires %(count)s argumentss%s option does not take a value(R:RRRRšR˜t takes_valuetnargsRtintR8RttupleRtprocess( RŒRœRCRRtnext_argthad_explicit_valueRR R0R((s./usr/share/system-config-firewall/fw_parser.pyt__process_long_opt;s:         N( RRRSRRR‘R|R8RšRRžR›(((s./usr/share/system-config-firewall/fw_parser.pyRƒs     cCs+tdtdtƒ}||_t|_|S(Ntadd_help_optiont option_class(RƒRRLR–Rx(tsourceRG((s./usr/share/system-config-firewall/fw_parser.pyt _gen_parseres  cCs;t|ƒ}t|ƒ|ot|ƒnt|||ƒS(N(RªRgRkR‚(RHR~tcompatR©RG((s./usr/share/system-config-firewall/fw_parser.pytparseSysconfigArgsks   cCs&t|ƒ}t|ƒt|||ƒS(N(RªRtR‚(RHR~R©RG((s./usr/share/system-config-firewall/fw_parser.pytparseSELinuxArgsrs  cCsŽtƒ}|idddddddtdƒƒ|idd dd d d dtd ƒƒ|idddd d ddtdƒƒ|iddd d ddtdƒƒ|idddd d ddtdƒƒ|iddd d ddtdƒƒ|iddd d ddtdƒƒ|iddd d d!d"d#d$td%ƒd&tidtd'ƒd(itiƒƒ|id)dd d d*dtd+ƒƒ|id,dd d d-dtd.ƒƒt|ƒt|ƒtt i ƒd/jo|i ƒt i d0ƒnt |||ƒ}t|_|djok|odt}t}x5t i d1D]&}|id2ƒo t}q@t}q@W|o| o t|_qŠn|S(3Ns-?s-hs--helps--usageRVRZsShow this help messages-qs--quietRWRDtquiets9Run noninteractively; process only command-line argumentss-vs --verbosetverbosesBe more verboses --versiontversions Show versions-ns --nostarttnostarts<Configure firewall but do not activate the new configurations-ftforcesIgnore actual settingss--updatetupdates‰Update firewall non-interactively if the firewall is enabled. This will also restart the firewall. The -n and -f options will be ignored.s --defaultRlRYR(RnR_sRosJSet firewall default type: %s. This overwrites any existing configuration.s, s--list-servicest list_servicessList predefined services.s--list-icmp-typestlist_icmp_typessList the supported icmp types.iiis --selinux(RªRfRR$t DEFAULT_TYPESR'RtRgRR{targvRR|R‚RtnofwRt startswithR(RHR~R«RGRRmtfirewallR((s./usr/share/system-config-firewall/fw_parser.pytparseLokkitArgswsd                               cCstƒ}|idddddddtdƒƒ|id d dddd dtd ƒƒ|id dddddtdƒƒ|iddddddtdƒƒ|iddddddddtdƒdtidtdƒditiƒƒt|ƒt|ƒt|||ƒS(Ns-vs --verboseRVRWRDR¯RZsBe more verboses-ns --nostartR±s<Configure firewall but do not activate the new configurations-fR²sIgnore actual settingss--updateR³s‰Update firewall non-interactively if the firewall is enabled. This will also restart the firewall. The -n and -f options will be ignored.s --defaultRlRYR(RnR_sRosJSet firewall default type: %s. This overwrites any existing configuration.s, ( RªRfRR$R¶R'RtRgR‚(RHR~R«RG((s./usr/share/system-config-firewall/fw_parser.pyt parseDBUSArgsµs*               cCs+|pdStƒ}t|iƒ|_|S(N(RRRt__dict__(RCt new_values((s./usr/share/system-config-firewall/fw_parser.pyt copyValuesÒs  (-RtoptparseRRRRRRRR$t fw_functionsRR R R R t fw_servicesR R-tfw_icmpR/tos.pathtosR{RR,R.R1R@RARKRLRgRkRtRR‚RƒRªRR¬R­R»R¼R¿(((s./usr/share/system-config-firewall/fw_parser.pyts44 (       /   D  V >PKƒU[?Ûy"¶¶etc_services.pycnuW+A„¶Ñò íðeTc@sEdZd„Zddd„ƒYZdefd„ƒYZeƒZdS(s /etc/servicescCs/yt|ƒ}Wntj odSXdSdS(Nii(tintt ValueError(tstringti((s1/usr/share/system-config-firewall/etc_services.pytisNumbers t_ServicecBsƒeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „ZeZRS( cCs|iƒdS(N(tclear(tself((s1/usr/share/system-config-firewall/etc_services.pyt__init__scCs1d|_d|_d|_d|_g|_dS(Nit(tp_idt p_protocoltp_namet p_descriptiont p_aliases(R((s1/usr/share/system-config-firewall/etc_services.pyR!s     cCs ||_dS(N(R (Rtid((s1/usr/share/system-config-firewall/etc_services.pytsetID'scCs|iS(N(R (R((s1/usr/share/system-config-firewall/etc_services.pytgetId)scCs ||_dS(N(R (Rtprotocol((s1/usr/share/system-config-firewall/etc_services.pyt setProtocol+scCs|iS(N(R (R((s1/usr/share/system-config-firewall/etc_services.pyt getProtocol-scCs ||_dS(N(R (Rtname((s1/usr/share/system-config-firewall/etc_services.pytsetName/scCs|iS(N(R (R((s1/usr/share/system-config-firewall/etc_services.pytgetName1scCs ||_dS(N(R (Rt description((s1/usr/share/system-config-firewall/etc_services.pytsetDescription3scCs|iS(N(R (R((s1/usr/share/system-config-firewall/etc_services.pytgetDescription5scCs ||_dS(N(R(Rtaliases((s1/usr/share/system-config-firewall/etc_services.pyt setAliases7scCs|iS(N(R(R((s1/usr/share/system-config-firewall/etc_services.pyt getAliases9scCsŽd|iƒ|iƒ|iƒf}t|iƒƒdjo!|ddi|iƒƒ7}n|iƒdjo|d|iƒ7}n|S(Ns%s %d/%sis %st R s # %s(RRRtlenRtjoinR(Rts((s1/usr/share/system-config-firewall/etc_services.pyt__str__;s %!(t__name__t __module__RRRRRRRRRRRRR"t__repr__(((s1/usr/share/system-config-firewall/etc_services.pyRs             t _ServicescBseZd„Zd„ZRS(cCsti|ƒ|iƒdS(N(tlistRtload(R((s1/usr/share/system-config-firewall/etc_services.pyREs c Csyttdƒ}Wntj o}|GHdSXxÅ|iƒD]·}|pPnt|ƒdjp|ddjoq>n|iƒ}|idƒ}t|ƒdjoq>n|d}t|ƒdjo|diƒ}nd}t|ƒdjoq>n|iƒ}t|ƒdjoq>ntƒ}|i |dƒ|djo|i |ƒn|didƒ}t|ƒdjoq>nyt |dƒ}Wnt j o q>nX|i |ƒ|i|dƒ|i|dƒ|i|ƒq>W|iƒdS(Ntriit#it/(topent ETC_SERVICESt Exceptiont xreadlinesRtstriptsplittNoneRRRRRRRRtappendtclose( RtfdtmsgtlinetpRtservicetp2R((s1/usr/share/system-config-firewall/etc_services.pyR(IsP $      (R#R$RR((((s1/usr/share/system-config-firewall/etc_services.pyR&Ds N((R-RRR'R&tservices(((s1/usr/share/system-config-firewall/etc_services.pyts &;PKƒU[Æ BB fw_parser.pyonuW+A„¶Ñò íðeTc @s ddklZddklZlZlZlZlZlZlZddk Z ddk l Z l Z l Z lZlZddklZddklZddkZddkZd„Zd„Zd„Zd „Zd „Zd „Zd „Zd efd„ƒYZd„Z d„Z!d„Z"dd„Z$defd„ƒYZ%dd„Z&de'dd„Z(ddd„Z)dde'd„Z*dde'd„Z+d„Z,dS(iÿÿÿÿ(tcopy(tOptiont OptionErrort OptionParsertValuest SUPPRESS_HELPtBadOptionErrort OptionGroupN(t getPortIDt getPortRangetgetServiceNametcheckIPtcheckInterface(tgetByKeycCs6t}y|idƒ\}}Wn t}n™Xt|iƒƒ}|djo t}np|djottdƒ||ƒ‚nFt|ƒdjo2|d|djottdƒ||ƒ‚n|p:|iƒ}|d jottd ƒ||ƒ‚qn|ottd ƒ||ƒ‚n||fS( Nt:iÿÿÿÿsport range %s is not unique.iiis1%s is not a valid range (start port >= end port).ttcptudps%s is not a valid protocol.sinvalid port definition %s.(RR( tFalsetsplittTrueR tstriptNoneRt_tlen(toptiontopttvaluetfailuretportstprotocoltrange((s./usr/share/system-config-firewall/fw_parser.pyt _check_ports(    (   !cCsd}d}|iddƒ}t|ƒdjo8|dtijo$|d}|diddƒ}nt|ƒdjo8|dtijo$|d}|diddƒ}ndi|ƒ}|djo&|djottdƒ|ƒ‚n|||fS( Ntipv4tfilterRiitipv6tnatsipv6 has no nat support.(RRt fw_configtFIREWALL_TYPEStFIREWALL_TABLEStjoinRR(RRRttypettabletsplitstfilename((s./usr/share/system-config-firewall/fw_parser.pyt_check_rulesfile6s' ' cCs.t|ƒpttdƒ||ƒ‚n|S(Nsinvalid service '%s'.(tgetServiceByKeyRR(RRR((s./usr/share/system-config-firewall/fw_parser.pyt_check_serviceGs cCsBt|ƒp1h|d6|d6}ttdƒ||ƒ‚n|S(NRRs1option %(option)s: invalid icmp type '%(value)s'.(tgetICMPTypeByKeyRR(RRRtdict((s./usr/share/system-config-firewall/fw_parser.pyt_check_icmp_typeLs   c Cs€h}d}|iddƒ}xwt|ƒdjoc|didƒ}t|ƒdjotdƒ|d}Pn|\}}|djo t|ƒp4|djo |djp|d jot|ƒo|||Ns --enabledtactiont store_trueRDtenabledtdefaultthelpsEnable firewall (default)s --disabledt store_falsesDisable firewalls --addmoduletcallbackt add_moduleR(tstringtmetavarssEnable an iptables modules--removemodulet remove_modulesDisable an iptables modules-ss --servicetservicesRNs s*Open the firewall for a service (e.g, ssh)s-ps--portRR6s[-]:s2Open specific ports in the firewall (e.g, ssh:tcp)s-ts--trustttrustRQs s)Allow all traffic on the specified devices-ms--masqtmasqsAMasquerades traffic from the specified device. This is IPv4 only.s--highs--mediums-Backwards compatibility, aliased to --enableds--custom-rulest custom_rulesRMs[:][
:]s¿Specify a custom rules file for inclusion in the firewall, after the default rules. Default protocol type: ipv4, default table: filter. (Example: ipv4:filter:/etc/sysconfig/ipv4_filter_addon)s--forward-portROsfif=:port=:proto=[:toport=][:toaddr=]sÑForward the port with protocol for the interface to either another local destination port (no destination address given) or to an other destination address with an optional destination port. This is IPv4 only.s --block-icmpt block_icmpRPs s>Block this ICMP type. The default is to accept all ICMP types.(t add_optionRRRK(RG((s./usr/share/system-config-firewall/fw_parser.pyt_addStandardOptions˜sh                         c Css|iddddddtdƒƒ|iddddd dtd ƒƒ|id dddd dtd ƒƒdS(Ns --no-ipsecRVRWRDtno_ipsecRZs*Disable Internet Protocol Security (IPsec)s--no-ipptno_ipps(Disable Internet Printing Protocol (IPP)s --no-mdnstno_mdnssDisable Multicast DNS (mDNS)(RfR(RG((s./usr/share/system-config-firewall/fw_parser.pyt_addCompatOptionsÜs        cCs¶t|tdƒtdƒƒ}|iddddddd d td ƒd tid tdƒditiƒƒ|idddddddd tdƒd tdƒƒ|i|ƒdS(NsSELinux Options (deprecated)s‰Using these options with no additional firewall options will not create or alter firewall configuration, only SELinux will be configured.s --selinuxRVtstoreRDtselinuxR(tchoiceR_stchoicesRZsConfigure SELinux mode: %ss, s --selinuxtypet selinuxtypeR^ss9Configure SELinux type: Usually targeted or strict Policy(RRRfR$t SELINUX_MODESR'tadd_option_group(RGtgroup((s./usr/share/system-config-firewall/fw_parser.pyt_addSELinuxOptionsçs     cCsøy|i||ƒ\}}Wn#tj o}|i|ƒdSXt|ƒdjo,x)|D]}|itdƒ|ƒq\Wn|io/tiotii dƒqºt i dƒnt |dƒp d|_ nt |dƒp t|_n|S(Nisno such option: %siR+t converted(t parse_argst ExceptionR8RRRt_fw_exitR$tuit parse_exittsystexitthasattrR+RRu(RGRHtoptionst_optionst_argsR8targ((s./usr/share/system-config-firewall/fw_parser.pyt _parse_argsús$     t _OptionParsercBs\eZd d„Zd d„Zdd d„Zd„Zd„Zd„Zd„Z d„Z RS( cCsl|djo ti}n|iƒ}t|tƒo%|i|ƒ}|i|dƒ}n|i|ƒdS(Ntreplace( RR{tstdoutt format_helpt isinstancetunicodet _get_encodingtencodetwrite(tselftfiletstrtencoding((s./usr/share/system-config-firewall/fw_parser.pyt print_helps   cCsdS(N((RŒR((s./usr/share/system-config-firewall/fw_parser.pyt print_usagesicCsQ|o/tiotii|ƒq6ti|IJntip t|_ndS(N(R$Ryt parse_errorR{tstderrRRx(RŒtstatustmsg((s./usr/share/system-config-firewall/fw_parser.pyR|s   cCsD|iod|i|f}n t|ƒ}|idd|ƒdS(Ns%s: %siR•(t _fw_sourceRŽR|(RŒR•ttext((s./usr/share/system-config-firewall/fw_parser.pyR8$s  cCs(|ii|ƒo|St|ƒ‚dS(N(t _long_optthas_keyR(RŒR((s./usr/share/system-config-firewall/fw_parser.pyt_match_long_opt*scCs=y|i||ƒWn"tj o}|i|ƒnXdS(N(t_OptionParser__process_long_optRwR8(RŒtrargsRCR•((s./usr/share/system-config-firewall/fw_parser.pyt_process_long_opt.scCs@yti|||ƒWn"tj o}|i|ƒnXdS(N(Rt_process_short_optsRwR8(RŒRœRCR•((s./usr/share/system-config-firewall/fw_parser.pyRž5sc CsÈ|idƒ}d|jo"|iddƒ\}}t}n |}t}|i|ƒ}|i|}|iƒo|i}t|ƒt |ƒ|joW|djo|i t dƒ|ƒq‚h|d6|d6} |i t dƒ| ƒq®|djo|o |} q®|djo|idƒ} q®|o0t |g|d|d!ƒ} |d|d5q®t |d|!ƒ} |d|5n)|o|i t dƒ|ƒnd} |i|| ||ƒdS( NiR2is%s option requires an argumentRR9s.%(option)s option requires %(count)s argumentss%s option does not take a value(R:RRRRšR˜t takes_valuetnargsRtintR8RttupleRtprocess( RŒRœRCRRtnext_argthad_explicit_valueRR R0R((s./usr/share/system-config-firewall/fw_parser.pyt__process_long_opt;s:         N( RRRSRRR‘R|R8RšRRžR›(((s./usr/share/system-config-firewall/fw_parser.pyRƒs     cCs+tdtdtƒ}||_t|_|S(Ntadd_help_optiont option_class(RƒRRLR–Rx(tsourceRG((s./usr/share/system-config-firewall/fw_parser.pyt _gen_parseres  cCs;t|ƒ}t|ƒ|ot|ƒnt|||ƒS(N(RªRgRkR‚(RHR~tcompatR©RG((s./usr/share/system-config-firewall/fw_parser.pytparseSysconfigArgsks   cCs&t|ƒ}t|ƒt|||ƒS(N(RªRtR‚(RHR~R©RG((s./usr/share/system-config-firewall/fw_parser.pytparseSELinuxArgsrs  cCsŽtƒ}|idddddddtdƒƒ|idd dd d d dtd ƒƒ|idddd d ddtdƒƒ|iddd d ddtdƒƒ|idddd d ddtdƒƒ|iddd d ddtdƒƒ|iddd d ddtdƒƒ|iddd d d!d"d#d$td%ƒd&tidtd'ƒd(itiƒƒ|id)dd d d*dtd+ƒƒ|id,dd d d-dtd.ƒƒt|ƒt|ƒtt i ƒd/jo|i ƒt i d0ƒnt |||ƒ}t|_|djok|odt}t}x5t i d1D]&}|id2ƒo t}q@t}q@W|o| o t|_qŠn|S(3Ns-?s-hs--helps--usageRVRZsShow this help messages-qs--quietRWRDtquiets9Run noninteractively; process only command-line argumentss-vs --verbosetverbosesBe more verboses --versiontversions Show versions-ns --nostarttnostarts<Configure firewall but do not activate the new configurations-ftforcesIgnore actual settingss--updatetupdates‰Update firewall non-interactively if the firewall is enabled. This will also restart the firewall. The -n and -f options will be ignored.s --defaultRlRYR(RnR_sRosJSet firewall default type: %s. This overwrites any existing configuration.s, s--list-servicest list_servicessList predefined services.s--list-icmp-typestlist_icmp_typessList the supported icmp types.iiis --selinux(RªRfRR$t DEFAULT_TYPESR'RtRgRR{targvRR|R‚RtnofwRt startswithR(RHR~R«RGRRmtfirewallR((s./usr/share/system-config-firewall/fw_parser.pytparseLokkitArgswsd                               cCstƒ}|idddddddtdƒƒ|id d dddd dtd ƒƒ|id dddddtdƒƒ|iddddddtdƒƒ|iddddddddtdƒdtidtdƒditiƒƒt|ƒt|ƒt|||ƒS(Ns-vs --verboseRVRWRDR¯RZsBe more verboses-ns --nostartR±s<Configure firewall but do not activate the new configurations-fR²sIgnore actual settingss--updateR³s‰Update firewall non-interactively if the firewall is enabled. This will also restart the firewall. The -n and -f options will be ignored.s --defaultRlRYR(RnR_sRosJSet firewall default type: %s. This overwrites any existing configuration.s, ( RªRfRR$R¶R'RtRgR‚(RHR~R«RG((s./usr/share/system-config-firewall/fw_parser.pyt parseDBUSArgsµs*               cCs+|pdStƒ}t|iƒ|_|S(N(RRRt__dict__(RCt new_values((s./usr/share/system-config-firewall/fw_parser.pyt copyValuesÒs  (-RtoptparseRRRRRRRR$t fw_functionsRR R R R t fw_servicesR R-tfw_icmpR/tos.pathtosR{RR,R.R1R@RARKRLRgRkRtRR‚RƒRªRR¬R­R»R¼R¿(((s./usr/share/system-config-firewall/fw_parser.pyts44 (       /   D  V >PKƒU[½ê ð——fw_sysconfig.pyonuW+A„¶Ñò íðeTc @s«ddkZddklZlZlZlZddklZddk Z ddk Z ddk Z d„Z dedd„Zded„Zd„Zd„Zd „ZdS( iÿÿÿÿN(t OLD_CONFIGtCONFIGt IP4TABLES_CFGt IP6TABLES_CFG(tparseSysconfigArgscCsd}tiitƒotiitƒo t}n1tiitƒotiitƒo t}nyt|dƒ}WndSXg}xd|iƒD]V}|pPn|i ƒ}t |ƒdjp|ddjoq—n|i |ƒq—W|i ƒ||fS(Ntriit#( tNonetostpathtexistsRtisfileRtopent xreadlineststriptlentappendtclose(tfilenametfdtargvtline((s1/usr/share/system-config-firewall/fw_sysconfig.pytread_sysconfig_argss(& &   $ cCsat|d|d|d|ƒ}|pdS||_|itjoti|ƒt|_n|S(Ntoptionstcompattsource(RRRRt fw_compattconvertToServicestTruet converted(targst merge_configRRtconfig((s1/usr/share/system-config-firewall/fw_sysconfig.pytparse_sysconfig_args1s    cCs0tƒ}|p|St|d|||dƒS(Nii(RR!(RRR((s1/usr/share/system-config-firewall/fw_sysconfig.pytread_sysconfig_config<s c Cstii|ƒo'yti|d|ƒWq:tSXnyt|dƒ}WntSXti|dƒ|idƒ|idƒ|i t jo|idƒn"|i tjo|idƒn|i o)x&|i D]}|id|ƒqØWn|i o)x&|i D]}|id |ƒq Wn|i o]t|i ƒd joGxD|i D]5\}}|id d itt|ƒƒ|fƒqTWn|ioHt|iƒd jo2x/|iD] }|id di|ƒƒq»Wn|io)x&|iD]}|id|ƒq÷Wn|io)x&|iD]}|id|ƒq*Wn|io x|iD]} t| dƒdjod| dd } n!d| dd | ddf} d| d| | df} | idƒoYt| dƒdjo| d| dd 7} q4| d| dd | ddf7} n| idƒo| d| d7} n|id| ƒq]Wn|iƒt S(Ns%s.oldtwi€s0# Configuration file for system-config-firewall s s --enabled s --disabled s --trust=%s s --masq=%s is --port=%s:%s t-s--custom-rules=%s t:s --service=%s s--block-icmp=%s tportis%ss%s-%ssif=%s:port=%s:proto=%stiftprotottoports :toport=%ss :toport=%s-%sttoaddrs :toaddr=%ss--forward-port=%s (RR R tshutiltcopy2tFalseR tchmodtwritetenabledRttrusttmasqtportsRtjointmaptstrt custom_rulestservicest block_icmpt forward_portthas_keyR( RtconfRtdevR3R(tcustomtserviceticmptfwdR&R((s1/usr/share/system-config-firewall/fw_sysconfig.pytwrite_sysconfig_configBsr         1  "        c Cs~t}titƒ}y|iƒWn t}nXt}titƒ}y|iƒWn t}nXh}h}x“tiD]ˆ}|p*|i |i |i ƒdj||i     #  # (tos.pathRt fw_configRRRRt fw_parserRRRGR+RRR-R!R"RBRVR\(((s1/usr/share/system-config-firewall/fw_sysconfig.pyts "      @ -PKƒU[Çú²½ ½ fw_config.pycnuW+A„¶Ñò íðeTc@s.ddkZeieidƒdZddkZd„ZddkZeeidst_s /usr/share/s.glades(C) 2007-2009 Red Hat, Inc.s1.2.27s$Thomas Woerner s!Chris Lumens s!Florian Festi sBrent Fox scThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see .s/etc/sysconfig/iptabless/etc/sysconfig/ip6tabless/etc/sysconfig/iptables-configs/etc/sysconfig/ip6tables-configs%/etc/sysconfig/system-config-firewalls*/etc/sysconfig/system-config-securitylevels/etc/selinux/configs/etc/sysconfig/selinuxs/etc/sysctl.conftppptisdntipppttuntwlantipv4tipv6tmangletnattfiltertservertdesktopt enforcingt permissivetdisabledttargeted(!tlocalet setlocaletLC_ALLRRRt __builtin__t__dict__tNonetuitAPP_NAMEtDATADIRt GLADE_NAMEt COPYRIGHTtVERSIONtAUTHORStLICENSEtIP4TABLES_RULEStIP6TABLES_RULESt IP4TABLES_CFGt IP6TABLES_CFGtCONFIGt OLD_CONFIGt SE_CONFIGt OLD_SE_CONFIGt SYSCTL_CONFIGt STD_DEVICEStFIREWALL_TYPEStFIREWALL_TABLESt DEFAULT_TYPESt SELINUX_MODEStDEFAULT_SELINUX_MODEtDEFAULT_SELINUX_TYPE(((s./usr/share/system-config-firewall/fw_config.pytsD           PKƒU[©@é@  fw_functions.pynuW+A„¶# # Copyright (C) 2007, 2008 Red Hat, Inc. # Authors: # Thomas Woerner # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # import socket, types def getPortID(port): if isinstance(port, types.IntType): id = port else: if port: port = port.strip() try: id = int(port) except: try: id = socket.getservbyname(port) except: return -1 if id > 65535: return -1 return id def getPortRange(ports): if isinstance(ports, types.IntType): id = getPortID(ports) if id >= 0: return (id,) return -1 splits = ports.split("-") matched = [ ] for i in xrange(len(splits), 0, -1): id1 = getPortID("-".join(splits[:i])) port2 = "-".join(splits[i:]) if len(port2) > 0: id2 = getPortID(port2) if id1 >= 0 and id2 >= 0: if id1 < id2: matched.append((id1, id2)) elif id1 > id2: matched.append((id2, id1)) else: matched.append((id1, )) else: if id1 >= 0: matched.append((id1,)) if i == len(splits): # full match, stop here break if len(matched) < 1: return -1 elif len(matched) > 1: return None return matched[0] def getServiceName(port, proto): try: name = socket.getservbyport(int(port), proto) except: return None return name def catFile(fd, filename): try: source_fd = open(filename, "r") except: return False for line in source_fd.xreadlines(): fd.write(line) source_fd.close() return True def checkIP(ip): if ip != "": splits = ip.split(".") if len(splits) != 4: return False for i in xrange(len(splits)): try: l = int(splits[i]) except: return False if l < 0 or l > 255: return False return True def checkInterface(iface): if not iface or len(iface) > 16: return False for ch in [ ' ', '/', '!', ':', '*' ]: # !:* are limits for iptables <= 1.4.5 if ch in iface: return False if iface == "+": # limit for iptables <= 1.4.5 return False return True PKƒU[®ÐNöÕ Õ fw_config.pynuW+A„¶# # Copyright (C) 2007-2009 Red Hat, Inc. # Authors: # Thomas Woerner # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # translation import locale locale.setlocale(locale.LC_ALL, "") DOMAIN = 'system-config-firewall' import gettext _ = lambda x: gettext.ldgettext(DOMAIN, x) import __builtin__ __builtin__.__dict__['_'] = _ # global ui reference for parser ui = None # configuration APP_NAME = 'system-config-firewall' DATADIR = '/usr/share/' + APP_NAME GLADE_NAME = APP_NAME + '.glade' COPYRIGHT = '(C) 2007-2009 Red Hat, Inc.' VERSION = '1.2.27' AUTHORS = [ "Thomas Woerner ", "Chris Lumens ", "Florian Festi ", "Brent Fox ", ] LICENSE = _( "This program is free software; you can redistribute it and/or modify " "it under the terms of the GNU General Public License as published by " "the Free Software Foundation; either version 2 of the License, or " "(at your option) any later version.\n" "\n" "This program is distributed in the hope that it will be useful, " "but WITHOUT ANY WARRANTY; without even the implied warranty of " "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " "GNU General Public License for more details.\n" "\n" "You should have received a copy of the GNU General Public License " "along with this program. If not, see .") IP4TABLES_RULES = '/etc/sysconfig/iptables' IP6TABLES_RULES = '/etc/sysconfig/ip6tables' IP4TABLES_CFG = '/etc/sysconfig/iptables-config' IP6TABLES_CFG = '/etc/sysconfig/ip6tables-config' CONFIG = '/etc/sysconfig/system-config-firewall' OLD_CONFIG = '/etc/sysconfig/system-config-securitylevel' SE_CONFIG = '/etc/selinux/config' OLD_SE_CONFIG = '/etc/sysconfig/selinux' SYSCTL_CONFIG = '/etc/sysctl.conf' STD_DEVICES = [ "ppp", "isdn", "ippp", "tun", "wlan" ] FIREWALL_TYPES = [ "ipv4", "ipv6" ] FIREWALL_TABLES = [ "mangle", "nat", "filter" ] DEFAULT_TYPES = [ "server", "desktop" ] SELINUX_MODES = [ "enforcing", "permissive", "disabled" ] DEFAULT_SELINUX_MODE = "enforcing" DEFAULT_SELINUX_TYPE = "targeted" PKƒU[?Ûy"¶¶etc_services.pyonuW+A„¶Ñò íðeTc@sEdZd„Zddd„ƒYZdefd„ƒYZeƒZdS(s /etc/servicescCs/yt|ƒ}Wntj odSXdSdS(Nii(tintt ValueError(tstringti((s1/usr/share/system-config-firewall/etc_services.pytisNumbers t_ServicecBsƒeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „ZeZRS( cCs|iƒdS(N(tclear(tself((s1/usr/share/system-config-firewall/etc_services.pyt__init__scCs1d|_d|_d|_d|_g|_dS(Nit(tp_idt p_protocoltp_namet p_descriptiont p_aliases(R((s1/usr/share/system-config-firewall/etc_services.pyR!s     cCs ||_dS(N(R (Rtid((s1/usr/share/system-config-firewall/etc_services.pytsetID'scCs|iS(N(R (R((s1/usr/share/system-config-firewall/etc_services.pytgetId)scCs ||_dS(N(R (Rtprotocol((s1/usr/share/system-config-firewall/etc_services.pyt setProtocol+scCs|iS(N(R (R((s1/usr/share/system-config-firewall/etc_services.pyt getProtocol-scCs ||_dS(N(R (Rtname((s1/usr/share/system-config-firewall/etc_services.pytsetName/scCs|iS(N(R (R((s1/usr/share/system-config-firewall/etc_services.pytgetName1scCs ||_dS(N(R (Rt description((s1/usr/share/system-config-firewall/etc_services.pytsetDescription3scCs|iS(N(R (R((s1/usr/share/system-config-firewall/etc_services.pytgetDescription5scCs ||_dS(N(R(Rtaliases((s1/usr/share/system-config-firewall/etc_services.pyt setAliases7scCs|iS(N(R(R((s1/usr/share/system-config-firewall/etc_services.pyt getAliases9scCsŽd|iƒ|iƒ|iƒf}t|iƒƒdjo!|ddi|iƒƒ7}n|iƒdjo|d|iƒ7}n|S(Ns%s %d/%sis %st R s # %s(RRRtlenRtjoinR(Rts((s1/usr/share/system-config-firewall/etc_services.pyt__str__;s %!(t__name__t __module__RRRRRRRRRRRRR"t__repr__(((s1/usr/share/system-config-firewall/etc_services.pyRs             t _ServicescBseZd„Zd„ZRS(cCsti|ƒ|iƒdS(N(tlistRtload(R((s1/usr/share/system-config-firewall/etc_services.pyREs c Csyttdƒ}Wntj o}|GHdSXxÅ|iƒD]·}|pPnt|ƒdjp|ddjoq>n|iƒ}|idƒ}t|ƒdjoq>n|d}t|ƒdjo|diƒ}nd}t|ƒdjoq>n|iƒ}t|ƒdjoq>ntƒ}|i |dƒ|djo|i |ƒn|didƒ}t|ƒdjoq>nyt |dƒ}Wnt j o q>nX|i |ƒ|i|dƒ|i|dƒ|i|ƒq>W|iƒdS(Ntriit#it/(topent ETC_SERVICESt Exceptiont xreadlinesRtstriptsplittNoneRRRRRRRRtappendtclose( RtfdtmsgtlinetpRtservicetp2R((s1/usr/share/system-config-firewall/etc_services.pyR(IsP $      (R#R$RR((((s1/usr/share/system-config-firewall/etc_services.pyR&Ds N((R-RRR'R&tservices(((s1/usr/share/system-config-firewall/etc_services.pyts &;PKƒU[c]r   fw_compat.pycnuW+A„¶Ñò íðeTc@s/ddklZlZddkZd„ZdS(iÿÿÿÿ(t getPortIDtgetServiceNameNc Cs©t|iƒdjodStdƒ|iGH|i}g}g}x0tiD]%}g}|ioÞt}xÛ|iD]Æ\}}t|ƒ} t ||ƒ} | f|f|ijo|i | f|fƒqr|f|f|ijo|i |f|fƒqr| f|f|ijo|i | f|fƒqrt }qrWnt }|o!|i |i ƒ|i |ƒn~qLW|io9x6|iD]'} | |joq‰n|i | ƒq‰Wn~t|dƒ p |i o"d|jo|i dƒqnt|dƒt|dƒ p |i o"d|jo|i dƒqQnt|dƒt|dƒ p |i o"d|jo|i dƒqœnt|dƒ||_dS( Nis Converting %stno_ipsectipsectno_mdnstmdnstno_ipptipp(tlentservicest_tfilenamet fw_servicest service_listtportstTrueRRtappendtFalsetkeytextendthasattrRtdelattrRR( tconfigR Rtmatchedtsvct_matchedt all_matchedtporttprototidtnametentry((s./usr/share/system-config-firewall/fw_compat.pytconvertToServicess^              (t fw_functionsRRR R (((s./usr/share/system-config-firewall/fw_compat.pyts PKƒU[Ð2‰x x fw_icmp.pynuW+A„¶# # Copyright (C) 2008 Red Hat, Inc. # Authors: # Thomas Woerner # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # from fw_config import _ class _ICMPType: def __init__ (self, key, name, description=None, type=None): self.key = key self.name = name self.description = description self.type = type # type None means ipv4 and ipv6 icmp_list = [ _ICMPType("echo-request", _("Echo Request (ping)"), _("This message is used to test if a host is reachable mostly " "with the ping utility.")), _ICMPType("echo-reply", _("Echo Reply (pong)"), _("This message is the answer to an Echo Request.")), _ICMPType("destination-unreachable", _("Destination Unreachable"), _("This error message is generated by a host or gateway if the " "destination is not reachable.")), _ICMPType("parameter-problem", _("Parameter Problem"), _("This error message is generated if the IP header is bad, " "either by a missing option or bad length.")), _ICMPType("redirect", _("Redirect"), _("This error message informs a host to send packets on another " "route.")), _ICMPType("router-advertisement", _("Router Advertisement"), _("This message is used by routers to periodically announce " "the IP address of a multicast interface.")), _ICMPType("router-solicitation", _("Router Solicitation"), _("This message is used by a host attached to a multicast " "link to request a Router Advertisement")), _ICMPType("source-quench", _("Source Quench"), _("This error message is generated to tell a host to reduce the " "pace at which it is sending packets."), "ipv4"), _ICMPType("time-exceeded", _("Time Exceeded"), _("This error message is generated if the time-to-live was " "exceeded either of a packet or of the reassembling of a " "fragmented packet.")), ] def getByKey(key): for x in icmp_list: if x.key == key: return x return None def getByName(name): for x in icmp_list: if x.name == name: return x return None PKƒU[rs (      4 PKƒU[rs (      4 PKƒU[…<ˆ ˆ fw_lokkit.pynuW+A„¶# # Copyright (C) 2007-2009 Red Hat, Inc. # Authors: # Thomas Woerner # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # import fw_config from fw_parser import parseLokkitArgs, parseDBUSArgs, parseSysconfigArgs, \ parseSELinuxArgs, copyValues from fw_iptables import * from fw_sysconfig import * from fw_sysctl import * import fw_selinux import fw_services import fw_icmp ### parse command line arguments ### def loadConfig(args=None, dbus_parser=False): if dbus_parser: _parseArgs = parseDBUSArgs else: _parseArgs = parseLokkitArgs config = _parseArgs(args) # load default configuration if config.default: config.force = True # no force mode in update elif config.update: config.force = False old_config = None old_se_config = None # force mode: ignore old configuration # else: use old configuration and command line arguments if not config.force: ### load original configuration ### # initialize old_config old_config = _parseArgs([ ]) # parse /etc/sysconfig/system-config-firewall or # /etc/sysconfig/system-config-securitylevel old_config = read_sysconfig_config(old_config) # reparse lokkit args with a copy of the old configuration config = _parseArgs(args=args, options=copyValues(old_config)) # parse selinux config old_se_config = parseSELinuxArgs(fw_selinux.read() or [ ]) # load default configuration if config.default: # config.default in [ "server", "desktop" ] for svc in fw_services.service_list: if svc.default and config.default in svc.default: config.services.append(svc.key) # no force mode in update elif config.update: config.quiet = True config.nostart = False return (config, old_config, old_se_config) ### update selinux ### def updateSELinux(config, old_se_config): se_status = 0 # selinux if config.selinux or config.selinuxtype: if old_se_config: if not config.selinux: config.selinux = old_se_config.selinux if not config.selinuxtype: config.selinuxtype = old_se_config.selinuxtype if not config.selinux: config.selinux = fw_config.DEFAULT_SELINUX_MODE if not config.selinuxtype: config.selinuxtype = fw_config.DEFAULT_SELINUX_TYPE if not old_se_config or (config.selinux != old_se_config.selinux or \ config.selinuxtype != old_se_config.selinuxtype): se_status = int(fw_selinux.write(config) == False) if se_status != 0: print _("Failed to write selinux configuration.") else: fw_selinux.setenforce(config.selinuxtype) return se_status ### update firewall ### def updateFirewall(config, old_config): c_status = ip4t_status = ip6t_status = 0 log = "" # write /etc/sysconfig/system-config-securitylevel and # /etc/sysconfig/system-config-firewall c_status = int(write_sysconfig_config(fw_config.CONFIG, config) == False) if c_status != 0: log += _("Failed to write %s.") % fw_config.CONFIG log += "\n" # load ip*tables-config only if there is something to do if (config.add_module and len(config.add_module) > 0) or \ (config.remove_module and len(config.remove_module) > 0): # load IPv4 configuration ip4tables_conf = ip4tablesConfig(fw_config.IP4TABLES_CFG) try: ip4tables_conf.read() except: pass # load IPv6 configuration ip6tables_conf = ip6tablesConfig(fw_config.IP6TABLES_CFG) try: ip6tables_conf.read() except: pass _modules = [ ] _modules.append(ip4tables_conf.get("IPTABLES_MODULES")) _modules.append(ip6tables_conf.get("IP6TABLES_MODULES")) # setup modules for modules in _modules: if config.add_module: for module in config.add_module: modalias = None if module[:3] == "nf_": modalias = "ip_"+module[3:] if module[:3] == "ip_": modalias = "nf_"+module[3:] if module not in modules and modalias not in modules: modules.append(module) if config.remove_module: for module in config.remove_module: modalias = None if module[:3] == "nf_": modalias = "ip_"+module[3:] if module[:3] == "ip_": modalias = "nf_"+module[3:] if module in modules: modules.remove(module) if modalias in modules: modules.remove(modalias) # TODO: check status: # write IPv4 configuration ip4tables_conf.write() # write IPv6 configuration ip6tables_conf.write() # update services if config.enabled or (old_config and old_config.enabled) or config.force: ip4tables = iptablesClass(fw_config.IP4TABLES_RULES) ip6tables = ip6tablesClass(fw_config.IP6TABLES_RULES) if not config.nostart: # stop ip*tables ip4t_status = ip4tables.stop(config.verbose) if ip4t_status != 0: log += _("Failed to stop %s.") % "iptables" log += "\n" ip6t_status = ip6tables.stop(config.verbose) if ip6t_status != 0: log += _("Failed to stop %s.") % "ip6tables" log += "\n" if config.enabled: # set ip_forward if masquerading is in use if config.masq and len(config.masq) > 0: sysctl = sysctlClass(fw_config.SYSCTL_CONFIG) sysctl.read() if sysctl.get("net.ipv4.ip_forward") != "1": sysctl.set("net.ipv4.ip_forward", "1") sysctl.write() sysctl.reload() # write new config ip4tables.write(config) ip6tables.write(config) if not config.nostart: # start ip*tables ip4t_status = ip4tables.start(config.verbose) if ip4t_status == 150: # ipv4 disabled, ignore ip4t_status = 0 if ip4t_status != 0: log += _("Failed to start %s.") % "iptables" log += "\n" ip6t_status = ip6tables.start(config.verbose) if ip6t_status == 150: # ipv6 disabled, ignore ip6t_status = 0 if ip6t_status != 0: log += _("Failed to start %s.") % "ip6tables" log += "\n" else: # old_config and old_config.enabled # remove configuration files try: ip4tables.unlink() except Exception, msg: ip4t_status += 1 log += _("Failed to remove %s.") % ip4tables.filename log += "\n" if config.verbose: log += msg + "\n" try: ip6tables.unlink() except Exception, msg: ip6t_status += 1 log += _("Failed to remove %s.") % ip6tables.filename log += "\n" if config.verbose: log += msg + "\n" return (c_status, ip4t_status, ip6t_status, log) PKƒU[t8k¦    fw_nm.pynuW+A„¶#!/usr/bin/python import sys NM_DBUS_PATH = "/org/freedesktop/NetworkManager" NM_DBUS_INTERFACE = "org.freedesktop.NetworkManager" NM_DBUS_SERVICE_SYSTEM_SETTINGS = "org.freedesktop.NetworkManagerSystemSettings" NM_DBUS_SERVICE_USER_SETTINGS = "org.freedesktop.NetworkManagerUserSettings" NM_DBUS_IFACE_DEVICE = "org.freedesktop.NetworkManager.Device" NM_DBUS_IFACE_DEVICE_WIRED = "org.freedesktop.NetworkManager.Device.Wired" NM_DBUS_IFACE_DEVICE_WIRELESS = "org.freedesktop.NetworkManager.Device.Wireless" NM_DEVICE_TYPE_UNKNOWN = 0 NM_DEVICE_TYPE_ETHERNET = 1 NM_DEVICE_TYPE_WIFI = 2 NM_DEVICE_TYPE_GSM = 3 NM_DEVICE_TYPE_CDMA = 4 nm_device_type = { NM_DEVICE_TYPE_UNKNOWN: "unknown type", NM_DEVICE_TYPE_ETHERNET: "wired Ethernet", NM_DEVICE_TYPE_WIFI: "802.11 WiFi", NM_DEVICE_TYPE_GSM: "GSM-based cellular WAN", NM_DEVICE_TYPE_CDMA: "CDMA/IS-95-based cellular WAN" } ##### import dbus bus = dbus.SystemBus() def device_list(): devices = { } for service in [ NM_DBUS_SERVICE_SYSTEM_SETTINGS, NM_DBUS_SERVICE_USER_SETTINGS ]: proxy = bus.get_object(service, NM_DBUS_PATH) iface = dbus.Interface(proxy, dbus_interface=NM_DBUS_INTERFACE) try: device_list = iface.GetDevices() except: continue for c in device_list: proxy = bus.get_object(service, c) properties = dbus.Interface(proxy, dbus_interface='org.freedesktop.DBus.Properties') interface = properties.Get(NM_DBUS_IFACE_DEVICE, 'Interface') device_type = properties.Get(NM_DBUS_IFACE_DEVICE, 'DeviceType') if device_type == NM_DEVICE_TYPE_ETHERNET: hwaddr = properties.Get(NM_DBUS_IFACE_DEVICE_WIRED, 'HwAddress') elif device_type == NM_DEVICE_TYPE_WIFI: hwaddr = properties.Get(NM_DBUS_IFACE_DEVICE_WIRELESS, 'HwAddress') else: continue devices[str(interface)] = { "type": nm_device_type[device_type], "hwaddr": str(hwaddr), } return devices PKƒU[¹#ã¯Ó Ó fw_compat.pynuW+A„¶# # Copyright (C) 2007, 2008 Red Hat, Inc. # Authors: # Thomas Woerner # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # from fw_functions import getPortID, getServiceName import fw_services def convertToServices(config): if len(config.services) > 0: return print _("Converting %s") % config.filename services = config.services ports = [ ] matched = [ ] for svc in fw_services.service_list: _matched = [ ] if config.ports: all_matched = True for (port, proto) in svc.ports: id = getPortID(port) name = getServiceName(port, proto) if ((id,), proto) in config.ports: _matched.append(((id,), proto)) elif ((port,), proto) in config.ports: _matched.append(((port,), proto)) elif ((name,), proto) in config.ports: _matched.append(((name,), proto)) else: all_matched = False else: all_matched = False if all_matched: services.append(svc.key) matched.extend(_matched) del _matched if config.ports: for entry in config.ports: if entry in matched: continue ports.append(entry) del matched if not hasattr(config, "no_ipsec") or not config.no_ipsec: if not "ipsec" in services: services.append("ipsec") else: delattr(config, "no_ipsec") if not hasattr(config, "no_mdns") or not config.no_mdns: if not "mdns" in services: services.append("mdns") else: delattr(config, "no_mdns") if not hasattr(config, "no_ipp") or not config.no_ipp: if not "ipp" in services: services.append("ipp") else: delattr(config, "no_ipp") config.ports = ports PKƒU[¬~:LÜÜ fw_sysctl.pynuW+A„¶# # Copyright (C) 2007 Red Hat, Inc. # Authors: # Thomas Woerner # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # import os, os.path import tempfile import shutil ############################################################################## class sysctlClass: def __init__(self, filename): self.filename = filename self.clear() def clear(self): self.p_config = { } self.p_deleted = [ ] def get(self, key): _key = key.strip() if _key in self.p_config: return self.p_config[_key] return None def set(self, key, value): _key = key.strip() self.p_config[_key] = value.strip() if _key in self.p_deleted: self.p_deleted.remove[_key] def unset(self, key): _key = key.strip() if _key in self.p_config: del self.p_config[_key] if not _key in self.p_deleted: self.p_deleted.append(_key) def __str__(self): s = "" for (key,value) in self.p_config.items(): if s: s += '\n' s += '%s = %s' % (key, value) return s # load self.filename def read(self): self.clear() file = open(self.filename, "r") for line in file.xreadlines(): if not line: break line = line.strip() if len(line) < 1 or line[0] in ['#', ';']: continue # get key/value pairs p = line.split("=") if len(p) != 2: continue self.p_config[p[0].strip()] = p[1].strip() file.close() # save to self.filename if there are key/value changes def write(self): if len(self.p_config) < 1: # no changes: nothing to do return # handled keys done = [ ] (temp_file, temp) = tempfile.mkstemp("sysctl.conf") modified = False empty = False file = open(self.filename, "r") for line in file.xreadlines(): if not line: break # remove newline line = line.strip("\n") if len(line) < 1: if not empty: os.write(temp_file, "\n") empty = True elif line[0] == '#': empty = False os.write(temp_file, line) os.write(temp_file, "\n") else: p = line.split("=") if len(p) != 2: empty = False os.write(temp_file, line+"\n") continue key = p[0].strip() value = p[1].strip() # check for modified key/value pairs if key not in done: if (key in self.p_config and \ self.p_config[key] != value): empty = False os.write(temp_file, '%s = %s\n' \ % (key, self.p_config[key])) modified = True elif key in self.p_deleted: modified = True else: empty = False os.write(temp_file, line+"\n") done.append(key) else: modified = True # write remaining key/value pairs if len(self.p_config) > 0: for (key,value) in self.p_config.items(): if key in done: continue if not empty: os.write(temp_file, "\n") empty = True os.write(temp_file, '%s = %s\n' % (key, value)) modified = True file.close() os.close(temp_file) if not modified: # not modified: remove tempfile os.remove(temp) return # make backup if os.path.exists(self.filename): try: shutil.copy2(self.filename, "%s.old" % self.filename) except Exception, msg: os.remove(temp) raise IOError, "Backup of '%s' failed: %s" % (self.filename, msg) # copy tempfile try: shutil.copy(temp, self.filename) except Exception, msg: os.remove(temp) raise IOError, "Failed to create '%s': %s" % (self.filename, msg) else: os.remove(temp) os.chmod(self.filename, 0644) def reload(self): return os.system("/sbin/sysctl -p '%s' >/dev/null" % self.filename) PKƒU[@D+Ô< < fw_icmp.pycnuW+A„¶Ñò íðeTc@s5ddklZdd#d„ƒYZededƒedƒƒededƒed ƒƒed ed ƒed ƒƒed edƒedƒƒededƒedƒƒededƒedƒƒededƒedƒƒededƒedƒdƒededƒedƒƒg Zd „Zd!„Zd"S($iÿÿÿÿ(t_t _ICMPTypecBseZddd„ZRS(cCs(||_||_||_||_dS(N(tkeytnamet descriptionttype(tselfRRRR((s,/usr/share/system-config-firewall/fw_icmp.pyt__init__s   N(t__name__t __module__tNoneR(((s,/usr/share/system-config-firewall/fw_icmp.pyRss echo-requestsEcho Request (ping)sXThis message is used to test if a host is reachable mostly with the ping utility.s echo-replysEcho Reply (pong)s5This message is the answer to an Echo Request.sdestination-unreachablesDestination UnreachablesYThis error message is generated by a host or gateway if the destination is not reachable.sparameter-problemsParameter ProblemsbThis error message is generated if the IP header is bad, either by a missing option or bad length.tredirecttRedirectsCThis error message informs a host to send packets on another route.srouter-advertisementsRouter AdvertisementsaThis message is used by routers to periodically announce the IP address of a multicast interface.srouter-solicitationsRouter SolicitationsdThis message is used by a host attached to a multicast link to request a Router Advertisements source-quenchs Source QuenchsaThis error message is generated to tell a host to reduce the pace at which it is sending packets.tipv4s time-exceededs Time Exceededs‚This error message is generated if the time-to-live was exceeded either of a packet or of the reassembling of a fragmented packet.cCs*x#tD]}|i|jo|SqWdS(N(t icmp_listRR (Rtx((s,/usr/share/system-config-firewall/fw_icmp.pytgetByKey<s  cCs*x#tD]}|i|jo|SqWdS(N(RRR (RR((s,/usr/share/system-config-firewall/fw_icmp.pyt getByNameBs  N((t fw_configRRRRR(((s,/usr/share/system-config-firewall/fw_icmp.pyts,         PKƒU[[ flÛÛfw_sysconfig.pynuW+A„¶# # Copyright (C) 2007, 2008, 2014 Red Hat, Inc. # Authors: # Thomas Woerner # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # import os.path from fw_config import OLD_CONFIG, CONFIG, IP4TABLES_CFG, IP6TABLES_CFG from fw_parser import parseSysconfigArgs import fw_compat import fw_iptables import shutil def read_sysconfig_args(): filename = None if os.path.exists(CONFIG) and os.path.isfile(CONFIG): filename = CONFIG elif os.path.exists(OLD_CONFIG) and os.path.isfile(OLD_CONFIG): filename = OLD_CONFIG try: fd = open(filename, 'r') except: return None argv = [ ] for line in fd.xreadlines(): if not line: break line = line.strip() if len(line) < 1 or line[0] == '#': continue argv.append(line) fd.close() return (argv, filename) def parse_sysconfig_args(args, merge_config=None, compat=False, filename=None): config = parseSysconfigArgs(args, options=merge_config, compat=compat, source=filename) if not config: return None config.filename = filename if config.filename == OLD_CONFIG: fw_compat.convertToServices(config) config.converted = True return config def read_sysconfig_config(merge_config=None, compat=False): args = read_sysconfig_args() # returns: (args, filename) or None if not args: return merge_config return parse_sysconfig_args(args[0], merge_config, compat, args[1]) def write_sysconfig_config(filename, conf): if os.path.exists(filename): try: shutil.copy2(filename, "%s.old" % filename) except: return False try: fd = open(filename, 'w') except: return False os.chmod(filename, 0600) fd.write("# Configuration file for system-config-firewall\n") fd.write("\n") if conf.enabled == True: fd.write("--enabled\n") elif conf.enabled == False: fd.write("--disabled\n") if conf.trust: for dev in conf.trust: fd.write("--trust=%s\n" % dev) if conf.masq: for dev in conf.masq: fd.write("--masq=%s\n" % dev) if conf.ports and len(conf.ports) > 0: for (ports, proto) in conf.ports: fd.write("--port=%s:%s\n" % ('-'.join(map(str, ports)), proto)) if conf.custom_rules and len(conf.custom_rules) > 0: for custom in conf.custom_rules: fd.write("--custom-rules=%s\n" % ":".join(custom)) if conf.services: for service in conf.services: fd.write("--service=%s\n" % service) if conf.block_icmp: for icmp in conf.block_icmp: fd.write("--block-icmp=%s\n" % icmp) if conf.forward_port: for fwd in conf.forward_port: if len(fwd["port"]) == 1: port = "%s" % fwd["port"][0] else: port = "%s-%s" % (fwd["port"][0], fwd["port"][1]) line = "if=%s:port=%s:proto=%s" % (fwd["if"], port, fwd["proto"]) if fwd.has_key("toport"): if len(fwd["toport"]) == 1: line += ":toport=%s" % fwd["toport"][0] else: line += ":toport=%s-%s" % (fwd["toport"][0], fwd["toport"][1]) if fwd.has_key("toaddr"): line += ":toaddr=%s" % fwd["toaddr"] fd.write("--forward-port=%s\n" % line) fd.close() return True def read_service_settings(): # load IPv4 configuration ipv4_failed = False ipv4_conf = fw_iptables.ip4tablesConfig(IP4TABLES_CFG) try: ipv4_conf.read() except: # no or empty config ipv4_failed = True # load IPv6 configuration ipv6_failed = False ipv6_conf = fw_iptables.ip6tablesConfig(IP6TABLES_CFG) try: ipv6_conf.read() except: # no or empty config ipv6_failed = True ipv4_settings = { } ipv6_settings = { } for setting in fw_iptables.setting_list: if not ipv4_failed: ipv4_settings[setting.key] = \ (ipv4_conf.get(ipv4_conf.prefix+setting.key) == "yes") else: ipv4_settings[setting.key] = setting.iptables if not ipv6_failed: ipv6_settings[setting.key] = \ (ipv6_conf.get(ipv6_conf.prefix+setting.key) == "yes") else: ipv6_settings[setting.key] = setting.ip6tables key = "MODULES" if not ipv4_failed: ipv4_settings[key] = ipv4_conf.get(ipv4_conf.prefix+key) else: ipv4_settings[key] = [ ] if not ipv6_failed: ipv6_settings[key] = ipv6_conf.get(ipv6_conf.prefix+key) else: ipv6_settings[key] = [ ] return { "iptables": ipv4_settings, "ip6tables": ipv6_settings } def write_service_settings(settings): # load IPv4 configuration ipv4_failed = False ipv4_conf = fw_iptables.ip4tablesConfig(IP4TABLES_CFG) try: ipv4_conf.read() except: # ok: no or empty config pass # load IPv6 configuration ipv6_failed = False ipv6_conf = fw_iptables.ip6tablesConfig(IP6TABLES_CFG) try: ipv6_conf.read() except: # ok: no or empty config pass yes_no = { True: "yes", False: "no" } ipv4_settings = settings["iptables"] ipv6_settings = settings["ip6tables"] for key in ipv4_settings.keys(): if key != "MODULES": ipv4_conf.set(ipv4_conf.prefix+key, yes_no[ipv4_settings[key]]) else: ipv4_conf.set(ipv4_conf.prefix+key, ipv4_settings[key]) for key in ipv6_settings.keys(): if key != "MODULES": ipv6_conf.set(ipv6_conf.prefix+key, yes_no[ipv6_settings[key]]) else: ipv6_conf.set(ipv6_conf.prefix+key, ipv6_settings[key]) try: ipv4_conf.write() ipv6_conf.write() except: return False return True PKƒU[ë$En““ fw_sysctl.pyonuW+A„¶Ñò íðeTc@sGddkZddkZddkZddkZddd„ƒYZdS(iÿÿÿÿNt sysctlClasscBsYeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( cCs||_|iƒdS(N(tfilenametclear(tselfR((s./usr/share/system-config-firewall/fw_sysctl.pyt__init__s cCsh|_g|_dS(N(tp_configt p_deleted(R((s./usr/share/system-config-firewall/fw_sysctl.pyRs cCs,|iƒ}||ijo |i|SdS(N(tstripRtNone(Rtkeyt_key((s./usr/share/system-config-firewall/fw_sysctl.pytget#s  cCsE|iƒ}|iƒ|i|<||ijo|ii|ndS(N(RRRtremove(RR tvalueR ((s./usr/share/system-config-firewall/fw_sysctl.pytset)s cCsR|iƒ}||ijo|i|=n||ijo|ii|ƒndS(N(RRRtappend(RR R ((s./usr/share/system-config-firewall/fw_sysctl.pytunset/s  cCsSd}xF|iiƒD]5\}}|o|d7}n|d||f7}qW|S(Nts s%s = %s(Rtitems(RtsR R ((s./usr/share/system-config-firewall/fw_sysctl.pyt__str__6s cCsÎ|iƒt|idƒ}x¡|iƒD]“}|pPn|iƒ}t|ƒdjp|ddjoq)n|idƒ}t|ƒdjoq)n|diƒ|i|diƒ/dev/null(R%tsystemR(R((s./usr/share/system-config-firewall/fw_sysctl.pytreload¦s( t__name__t __module__RRR RRRR!R&R7(((s./usr/share/system-config-firewall/fw_sysctl.pyRs       V((R%tos.pathR"R*R(((s./usr/share/system-config-firewall/fw_sysctl.pyts  PKƒU[&_98ú&ú&fw_services.pyonuW+A„¶Ñò íðeTc @s5ddklZddklZlZddƒd„ƒYZededƒd„ged ƒd d gƒed ed ƒd…d†gedƒƒededƒd‡gedƒd d gdhdd6dd6ƒededƒdˆd‰dŠgedƒd d gƒeded ƒd‹ged"ƒd d#gƒed$ed%ƒdŒged'ƒƒed(ed)ƒdged+ƒd,d-gƒed.ed/ƒdŽged1ƒƒed2ed3ƒdged5ƒƒed6ed7ƒdged9ƒƒed:ed;ƒd‘d’ged>ƒd,d?gd d gƒed@edAƒd“d”d•d–gedDƒd,d?gƒedEedFƒd—d˜gedHƒƒedIedJƒd™gedLƒƒedMedNƒdšgedPƒƒedQedRƒd›dœgedUƒƒedVedWƒdgedYƒƒedZed[ƒdžged]ƒd,d^gƒed_ed`ƒgedaƒd,d^gƒedbedcƒdŸd d¡d¢gedhƒƒediedjƒd£gedlƒd,dmgƒednedoƒd¤gedqƒƒedredsƒd¥d¦d§gedvƒƒedwedxƒd¨gedzƒƒed{ed|ƒd©ged~ƒƒgZd„Zd€„Z d„Z d‚S(ªiÿÿÿÿ(t_(t getPortIDtgetServiceNamet_ServicecBseZdghdd„ZRS(cCsC||_||_||_||_||_||_||_dS(N(tkeytnametportst descriptiontmodulest destinationtdefault(tselfRRRRRR R ((s0/usr/share/system-config-firewall/fw_services.pyt__init__s      N(t__name__t __module__tNoneR (((s0/usr/share/system-config-firewall/fw_services.pyRss ipp-clientsNetwork Printing Client (IPP)t631tudpsThe Internet Printing Protocol (IPP) is used for distributed printing. IPP (over udp) provides the ability to get information about a printer (e.g. capability and status) and to control printer jobs. If you plan to use a remote network printer via cups, do not disable this option.R tdesktoptippsNetwork Printing Server (IPP)ttcpsÚThe Internet Printing Protocol (IPP) is used for distributed printing. IPP (over tcp) provides the ability to share printers over the network. Enable this option if you plan to share printers via cups over the network.tmdnssMulticast DNS (mDNS)t5353sÏmDNS provides the ability to use DNS programming interfaces, packet formats and operating semantics in a small network without a conventional DNS server. If you plan to use Avahi, do not disable this option.R s 224.0.0.251tipv4sff02::fbtipv6tipsectIPsectahtespiôs/Internet Protocol Security (IPsec) incorporates security for network transmissions directly into the Internet Protocol (IP). IPsec provides methods for both encrypting data and authentication for the host or network it sends to. If you plan to use a vpnc server or FreeS/WAN, do not disable this option.tsshtSSHt22s=Secure Shell (SSH) is a protocol for logging into and executing commands on remote machines. It provides secure encrypted communications. If you plan on accessing your machine remotely via SSH over a firewalled interface, enable this option. You need the openssh-server package installed for this option to be useful.tserverthttps WWW (HTTP)t80sÈHTTP is the protocol used to serve Web pages. If you plan to make your Web server publicly available, enable this option. This option is not required for viewing pages locally or developing Web pages.tftptFTPt21sÀFTP is a protocol used for remote file transfer. If you plan to make your FTP server publicly available, enable this option. You need the vsftpd package installed for this option to be useful.Rtnf_conntrack_ftptnfstNFS4t2049s¯The NFS4 protocol is used to share files via TCP networking. You will need to have the NFS tools installed and properly configure your NFS server for this option to be useful.thttpssSecure WWW (HTTPS)t443sHTTPS is a modified HTTP used to serve Web pages when security is important. Examples are sites that require logins like stores or web mail. This option is not required for viewing pages locally or developing Web pages. You need the httpd package installed for this option to be useful.tsmtps Mail (SMTP)t25sŒThis option allows incoming SMTP mail delivery. If you need to allow remote hosts to connect directly to your machine to deliver mail, enable this option. You do not need to enable this if you collect your mail from your ISP's server by POP3 or IMAP, or if you use a tool such as fetchmail. Note that an improperly configured SMTP server can allow remote machines to use your server to send spam.s samba-clients Samba Clientt137t138s•This option allows you to access Windows file and printer sharing networks. You need the samba-client package installed for this option to be useful.tnf_conntrack_netbios_nstsambatSambat139t445s¡This option allows you to access and participate in Windows file and printer sharing networks. You need the samba package installed for this option to be useful.tdnstDNSt53s¥The Domain Name System (DNS) is used to provide and request host and domain names. Enable this option, if you plan to provide a domain name service (e.g. with bind).timapss IMAP over SSLt993s×The Internet Message Access Protocol over SSL (IMAPs) allows a local client to access email on a remote server in a secure way. If you plan to provide a IMAP over SSL service (e.g. with dovecot), enable this option.tpop3ssPOP-3 over SSLt995sÇThe Post Office Protocol version 3 (POP3) is a protocol to retrieve email from a remote server over a TCP/IP connection. Enable this option, if you plan to provide a POP3 service (e.g. with dovecot).tradiustRADIUSt1812t1813sThe Remote Authentication Dial In User Service (RADIUS) is a protocol for user authentication over networks. It is mostly used for modem, DSL or wireless user authentication. If you plan to provide a RADIUS service (e.g. with freeradius), enable this option.topenvpntOpenVPNt1194s·OpenVPN is a virtual private network (VPN) solution. It is used to create encrypted point-to-point tunnels between computers. If you plan to provide a VPN service, enable this option.ttftptTFTPt69sýThe Trivial File Transfer Protocol (TFTP) is a protocol used to transfer files to and from a remote machine in s simple way. It is normally used only for booting diskless workstations and also to transfer data in the Preboot eXecution Environment (PXE).tnf_conntrack_tftps tftp-clients TFTP Clients‘This option allows you to access Trivial File Transfer Protocol (TFTP) servers. You need the tftp package installed for this option to be useful.s cluster-suitesRed Hat Cluster Suiteiiig+iHRs°This option allows you to use the Red Hat Cluster Suite. Ports are opened for openais, ricci and dlm. You need the Red Hat Cluster Suite installed for this option to be useful.s amanda-clientsAmanda Backup Clienti`'s©The Amanda backup client option allows you to connect to a Amanda backup and archiving server. You need the amanda-client package installed for this option to be useful.tnf_conntrack_amandas bacula-clients Bacula ClientiŽ#s¢This option allows a Bacula server to connect to the local machine to schedule backups. You need the bacula-client package installed for this option to be useful.tbaculatBaculai#i#syBacula is a network backup solution. Enable this option, if you plan to provide Bacula backup, file and storage services.tlibvirtsVirtual Machine Managementi}@sÙEnable this option if you want to allow remote virtual machine management with SASL authentication and encryption (digest-md5 passwords or GSSAPI/Kerberos). The libvirtd service is needed for this option to be useful.s libvirt-tlss Virtual Machine Management (TLS)i‚@sÏEnable this option if you want to allow remote virtual machine management with TLS encryption, x509 certificates and optional SASL authentication. The libvirtd service is needed for this option to be useful.cCs*x#tD]}|i|jo|SqWdS(N(t service_listRR(Rtx((s0/usr/share/system-config-firewall/fw_services.pytgetByKeyÒs  cCs*x#tD]}|i|jo|SqWdS(N(RKRR(RRL((s0/usr/share/system-config-firewall/fw_services.pyt getByNameØs  cCs}xvtD]n}t|ƒ}t||ƒ}||f|ijp2t|ƒ|f|ijp||f|ijo|SqWdS(N(RKRRRtstrR(tporttprotoRLtidR((s0/usr/share/system-config-firewall/fw_services.pyt getByPortÞs 2 N((RR(RR(RR(RR(NR(NR(iôR(RR(R"R(R%R(R)R(R+R(R-R(R.R(R/R(R.R(R/R(R3R(R4R(R7R(R7R(R9R(R;R(R>R(R?R(RBR(RER(iR(iR(ig+R(iHRR(i`'R(iŽ#R(i#R(iŽ#R(i#R(i}@R(i‚@R( t fw_configRt fw_functionsRRRRRKRMRNRS(((s0/usr/share/system-config-firewall/fw_services.pytsš                                        PKƒU[q’\¬K¬K fw_parser.pynuW+A„¶# # Copyright (C) 2007, 2008 Red Hat, Inc. # Authors: # Thomas Woerner # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # from copy import copy from optparse import Option, OptionError, OptionParser, Values, \ SUPPRESS_HELP, BadOptionError, OptionGroup import fw_config from fw_functions import getPortID, getPortRange, getServiceName, checkIP, \ checkInterface from fw_services import getByKey as getServiceByKey from fw_icmp import getByKey as getICMPTypeByKey import os.path import sys def _check_port(option, opt, value): failure = False try: (ports, protocol) = value.split(":") except: failure = True else: range = getPortRange(ports.strip()) if range == -1: failure = True elif range == None: raise OptionError(_("port range %s is not unique.") % value, opt) elif len(range) == 2 and range[0] >= range[1]: raise OptionError(_("%s is not a valid range (start port >= end " "port).") % value, opt) if not failure: protocol = protocol.strip() if protocol not in [ "tcp", "udp" ]: raise OptionError(_("%s is not a valid protocol.") % protocol, opt) if failure: raise OptionError(_("invalid port definition %s.") % value, opt) return (range, protocol) def _check_rulesfile(option, opt, value): type = "ipv4" table = "filter" splits = value.split(":", 1) if len(splits) > 1 and splits[0] in fw_config.FIREWALL_TYPES: type = splits[0] splits = splits[1].split(":", 1) if len(splits) > 1 and splits[0] in fw_config.FIREWALL_TABLES: table = splits[0] splits = splits[1].split(":", 1) filename = ":".join(splits) if type == "ipv6" and table == "nat": raise OptionError(_("ipv6 has no nat support."), opt) return (type, table, filename) def _check_service(option, opt, value): if not getServiceByKey(value): raise OptionError(_("invalid service '%s'.") % value, opt) return value def _check_icmp_type(option, opt, value): if not getICMPTypeByKey(value): dict = { "option": opt, "value": value } raise OptionError(_("option %(option)s: invalid icmp type " "'%(value)s'.") % dict, opt) return value def _check_forward_port(option, opt, value): result = { } error = None splits = value.split(":", 1) while len(splits) > 0: key_val = splits[0].split("=") if len(key_val) != 2: error = _("Invalid argument %s") % splits[0] break (key, val) = key_val if (key == "if" and checkInterface(val)) or \ (key == "proto" and val in [ "tcp", "udp" ]) or \ (key == "toaddr" and checkIP(val)): result[key] = val elif (key == "port" or key == "toport") and getPortRange(val) > 0: result[key] = getPortRange(val) else: error = _("Invalid argument %s") % splits[0] break if len(splits) > 1: if splits[1].count("=") == 1: # last element splits = [ splits[1] ] else: splits = splits[1].split(":", 1) else: # finish splits.pop() if error: dict = { "option": opt, "value": value, "error": error } raise OptionError(_("option %(option)s: invalid forward_port " "'%(value)s': %(error)s.") % dict, opt) error = False for key in [ "if", "port", "proto" ]: if key not in result.keys(): error = True if not "toport" in result.keys() and not "toaddr" in result.keys(): error = True if error: dict = { "option": opt, "value": value } raise OptionError(_("option %(option)s: invalid forward_port " "'%(value)s'.") % dict, opt) return result def _check_interface(option, opt, value): if not checkInterface(value): raise OptionError(_("invalid interface '%s'.") % value, opt) return value def _append_unique(option, opt, value, parser, *args, **kwargs): vals = getattr(parser.values, option.dest) if vals and value in vals: return parser.values.ensure_value(option.dest, []).append(value) class _Option(Option): TYPES = Option.TYPES + ("port", "rulesfile", "service", "forward_port", "icmp_type", "interface") TYPE_CHECKER = copy(Option.TYPE_CHECKER) TYPE_CHECKER["port"] = _check_port TYPE_CHECKER["rulesfile"] = _check_rulesfile TYPE_CHECKER["service"] = _check_service TYPE_CHECKER["forward_port"] = _check_forward_port TYPE_CHECKER["icmp_type"] = _check_icmp_type TYPE_CHECKER["interface"] = _check_interface def _addStandardOptions(parser): parser.add_option("--enabled", action="store_true", dest="enabled", default=True, help=_("Enable firewall (default)")) parser.add_option("--disabled", action="store_false", dest="enabled", help=_("Disable firewall")) parser.add_option("--addmodule", action="callback", dest="add_module", type="string", metavar=_(""), callback=_append_unique, help=_("Enable an iptables module")) parser.add_option("--removemodule", action="callback", dest="remove_module", type="string", metavar=_(""), callback=_append_unique, help=_("Disable an iptables module")) parser.add_option("-s", "--service", action="callback", dest="services", type="service", default=[ ], metavar=_(""), callback=_append_unique, help=_("Open the firewall for a service (e.g, ssh)")) parser.add_option("-p", "--port", action="callback", dest="ports", type="port", metavar=_("[-]:"), callback=_append_unique, help=_("Open specific ports in the firewall " "(e.g, ssh:tcp)")) parser.add_option("-t", "--trust", action="callback", dest="trust", type="interface", metavar=_(""), callback=_append_unique, help=_("Allow all traffic on the specified device")) parser.add_option("-m", "--masq", action="callback", dest="masq", type="interface", metavar=_(""), callback=_append_unique, help=_("Masquerades traffic from the specified device. " "This is IPv4 only.")) parser.add_option( "--high", "--medium", action="store_true", dest="enabled", help=_("Backwards compatibility, aliased to --enabled")) parser.add_option("--custom-rules", action="callback", dest="custom_rules", type="rulesfile", metavar=_("[:][
:]"), callback=_append_unique, help=_("Specify a custom rules file for inclusion in " "the firewall, after the " "default rules. Default protocol type: ipv4, " "default table: filter. " "(Example: ipv4:filter:/etc/sysconfig/" "ipv4_filter_addon)")) parser.add_option("--forward-port", action="callback", dest="forward_port", type="forward_port", metavar=_("if=:port=:proto=" "[:toport=]" "[:toaddr=]"), callback=_append_unique, help=_("Forward the port with protocol for the " "interface to either another local destination " "port (no destination address given) or to an " "other destination address with an optional " "destination port. This is IPv4 only.")) parser.add_option("--block-icmp", action="callback", dest="block_icmp", type="icmp_type", default=[ ], callback=_append_unique, metavar=_(""), help=_("Block this ICMP type. The default is to accept " "all ICMP types.")) def _addCompatOptions(parser): parser.add_option("--no-ipsec", action="store_true", dest="no_ipsec", help=_("Disable Internet Protocol Security (IPsec)")) parser.add_option("--no-ipp", action="store_true", dest="no_ipp", help=_("Disable Internet Printing Protocol (IPP)")) parser.add_option("--no-mdns", action="store_true", dest="no_mdns", help=_("Disable Multicast DNS (mDNS)")) def _addSELinuxOptions(parser): group = OptionGroup(parser, _("SELinux Options (deprecated)"), _("Using these options with no additional firewall " "options will not create or alter firewall " "configuration, only SELinux will be configured.")) group.add_option("--selinux", action="store", dest="selinux", type="choice", metavar=_(""), choices=fw_config.SELINUX_MODES, help=_("Configure SELinux mode: %s") % \ ", ".join(fw_config.SELINUX_MODES)) group.add_option("--selinuxtype", action="store", dest="selinuxtype", type="string", metavar=_(""), help=_("Configure SELinux type: Usually targeted or " "strict Policy")) parser.add_option_group(group) def _parse_args(parser, args, options=None): try: (_options, _args) = parser.parse_args(args, options) except Exception, error: parser.error(error) return None if len(_args) != 0: for arg in _args: parser.error(_("no such option: %s") % arg) if parser._fw_exit: if fw_config.ui: fw_config.ui.parse_exit(2) else: sys.exit(2) if not hasattr(_options, "filename"): _options.filename = None if not hasattr(_options, "converted"): _options.converted = False return _options class _OptionParser(OptionParser): # overload print_help: rhpl._ returns UTF-8 def print_help(self, file=None): if file is None: file = sys.stdout str = self.format_help() if isinstance(str, unicode): encoding = self._get_encoding(file) str = str.encode(encoding, "replace") file.write(str) def print_usage(self, file=None): pass def exit(self, status=0, msg=None): if msg: if fw_config.ui: fw_config.ui.parse_error(msg) else: print >>sys.stderr, msg if not fw_config.ui: self._fw_exit = True def error(self, msg): if self._fw_source: text = "%s: %s" % (self._fw_source, msg) else: text = str(msg) self.exit(2, msg=text) def _match_long_opt(self, opt): if self._long_opt.has_key(opt): return opt raise BadOptionError(opt) def _process_long_opt(self, rargs, values): # allow to ignore errors in the ui try: # OptionParser._process_long_opt(self, rargs, values) self.__process_long_opt(rargs, values) except Exception, msg: self.error(msg) def _process_short_opts(self, rargs, values): # allow to ignore errors in the ui try: OptionParser._process_short_opts(self, rargs, values) except Exception, msg: self.error(msg) def __process_long_opt(self, rargs, values): arg = rargs.pop(0) # Value explicitly attached to arg? Pretend it's the next # argument. if "=" in arg: (opt, next_arg) = arg.split("=", 1) had_explicit_value = True else: opt = arg had_explicit_value = False opt = self._match_long_opt(opt) option = self._long_opt[opt] if option.takes_value(): nargs = option.nargs if len(rargs)+int(had_explicit_value) < nargs: if nargs == 1: self.error(_("%s option requires an argument") % opt) else: dict = { "option": opt, "count": nargs } self.error(_("%(option)s option requires %(count)s " "arguments") % dict) elif nargs == 1 and had_explicit_value: value = next_arg elif nargs == 1: value = rargs.pop(0) elif had_explicit_value: value = tuple([ next_arg ] + rargs[0:nargs-1]) del rargs[0:nargs-1] else: value = tuple(rargs[0:nargs]) del rargs[0:nargs] elif had_explicit_value: self.error(_("%s option does not take a value") % opt) else: value = None option.process(opt, value, values, self) def _gen_parser(source=None): parser = _OptionParser(add_help_option=False, option_class=_Option) parser._fw_source = source parser._fw_exit = False return parser def parseSysconfigArgs(args, options=None, compat=False, source=None): parser = _gen_parser(source) _addStandardOptions(parser) if compat: _addCompatOptions(parser) return _parse_args(parser, args, options) def parseSELinuxArgs(args, options=None, source=None): parser = _gen_parser(source) _addSELinuxOptions(parser) return _parse_args(parser, args, options) def parseLokkitArgs(args=None, options=None, compat=False): parser = _gen_parser() parser.add_option("-?", "-h", "--help", "--usage", action="help", help=_("Show this help message")) parser.add_option("-q", "--quiet", action="store_true", dest="quiet", help=_("Run noninteractively; process only command-line " "arguments")) parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help=_("Be more verbose")) parser.add_option("--version", action="store_true", dest="version", help=_("Show version")) parser.add_option("-n", "--nostart", action="store_true", dest="nostart", help=_("Configure firewall but do not activate the new " "configuration")) parser.add_option("-f", action="store_true", dest="force", help=_("Ignore actual settings")) parser.add_option("--update", action="store_true", dest="update", help=_("Update firewall non-interactively if the " "firewall is enabled. This will also restart the " "firewall. The -n and -f options will be " "ignored.")) parser.add_option("--default", action="store", dest="default", type="choice", metavar=_(""), choices=fw_config.DEFAULT_TYPES, help=_("Set firewall default type: %s. " "This overwrites any existing " "configuration.") % ", ".join(fw_config.DEFAULT_TYPES)) parser.add_option("--list-services", action="store_true", dest="list_services", help=_("List predefined services.")) parser.add_option("--list-icmp-types", action="store_true", dest="list_icmp_types", help=_("List the supported icmp types.")) _addSELinuxOptions(parser) _addStandardOptions(parser) if len(sys.argv) < 2: parser.print_help() sys.exit(0) _options = _parse_args(parser, args, options) _options.nofw = False if args == None and _options: selinux = False firewall = False for arg in sys.argv[1:]: if arg.startswith("--selinux"): selinux = True else: firewall = True if selinux and not firewall: _options.nofw = True return _options def parseDBUSArgs(args=None, options=None, compat=False): parser = _gen_parser() parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help=_("Be more verbose")) parser.add_option("-n", "--nostart", action="store_true", dest="nostart", help=_("Configure firewall but do not activate the new " "configuration")) parser.add_option("-f", action="store_true", dest="force", help=_("Ignore actual settings")) parser.add_option("--update", action="store_true", dest="update", help=_("Update firewall non-interactively if the " "firewall is enabled. This will also restart the " "firewall. The -n and -f options will be " "ignored.")) parser.add_option("--default", action="store", dest="default", type="choice", metavar=_(""), choices=fw_config.DEFAULT_TYPES, help=_("Set firewall default type: %s. " "This overwrites any existing " "configuration.") % ", ".join(fw_config.DEFAULT_TYPES)) _addSELinuxOptions(parser) _addStandardOptions(parser) return _parse_args(parser, args, options) def copyValues(values): if not values: return None new_values = Values() new_values.__dict__ = copy(values.__dict__) return new_values PKƒU[½ê ð——fw_sysconfig.pycnuW+A„¶Ñò íðeTc @s«ddkZddklZlZlZlZddklZddk Z ddk Z ddk Z d„Z dedd„Zded„Zd„Zd„Zd „ZdS( iÿÿÿÿN(t OLD_CONFIGtCONFIGt IP4TABLES_CFGt IP6TABLES_CFG(tparseSysconfigArgscCsd}tiitƒotiitƒo t}n1tiitƒotiitƒo t}nyt|dƒ}WndSXg}xd|iƒD]V}|pPn|i ƒ}t |ƒdjp|ddjoq—n|i |ƒq—W|i ƒ||fS(Ntriit#( tNonetostpathtexistsRtisfileRtopent xreadlineststriptlentappendtclose(tfilenametfdtargvtline((s1/usr/share/system-config-firewall/fw_sysconfig.pytread_sysconfig_argss(& &   $ cCsat|d|d|d|ƒ}|pdS||_|itjoti|ƒt|_n|S(Ntoptionstcompattsource(RRRRt fw_compattconvertToServicestTruet converted(targst merge_configRRtconfig((s1/usr/share/system-config-firewall/fw_sysconfig.pytparse_sysconfig_args1s    cCs0tƒ}|p|St|d|||dƒS(Nii(RR!(RRR((s1/usr/share/system-config-firewall/fw_sysconfig.pytread_sysconfig_config<s c Cstii|ƒo'yti|d|ƒWq:tSXnyt|dƒ}WntSXti|dƒ|idƒ|idƒ|i t jo|idƒn"|i tjo|idƒn|i o)x&|i D]}|id|ƒqØWn|i o)x&|i D]}|id |ƒq Wn|i o]t|i ƒd joGxD|i D]5\}}|id d itt|ƒƒ|fƒqTWn|ioHt|iƒd jo2x/|iD] }|id di|ƒƒq»Wn|io)x&|iD]}|id|ƒq÷Wn|io)x&|iD]}|id|ƒq*Wn|io x|iD]} t| dƒdjod| dd } n!d| dd | ddf} d| d| | df} | idƒoYt| dƒdjo| d| dd 7} q4| d| dd | ddf7} n| idƒo| d| d7} n|id| ƒq]Wn|iƒt S(Ns%s.oldtwi€s0# Configuration file for system-config-firewall s s --enabled s --disabled s --trust=%s s --masq=%s is --port=%s:%s t-s--custom-rules=%s t:s --service=%s s--block-icmp=%s tportis%ss%s-%ssif=%s:port=%s:proto=%stiftprotottoports :toport=%ss :toport=%s-%sttoaddrs :toaddr=%ss--forward-port=%s (RR R tshutiltcopy2tFalseR tchmodtwritetenabledRttrusttmasqtportsRtjointmaptstrt custom_rulestservicest block_icmpt forward_portthas_keyR( RtconfRtdevR3R(tcustomtserviceticmptfwdR&R((s1/usr/share/system-config-firewall/fw_sysconfig.pytwrite_sysconfig_configBsr         1  "        c Cs~t}titƒ}y|iƒWn t}nXt}titƒ}y|iƒWn t}nXh}h}x“tiD]ˆ}|p*|i |i |i ƒdj||i     #  # (tos.pathRt fw_configRRRRt fw_parserRRRGR+RRR-R!R"RBRVR\(((s1/usr/share/system-config-firewall/fw_sysconfig.pyts "      @ -PKƒU[c]r   fw_compat.pyonuW+A„¶Ñò íðeTc@s/ddklZlZddkZd„ZdS(iÿÿÿÿ(t getPortIDtgetServiceNameNc Cs©t|iƒdjodStdƒ|iGH|i}g}g}x0tiD]%}g}|ioÞt}xÛ|iD]Æ\}}t|ƒ} t ||ƒ} | f|f|ijo|i | f|fƒqr|f|f|ijo|i |f|fƒqr| f|f|ijo|i | f|fƒqrt }qrWnt }|o!|i |i ƒ|i |ƒn~qLW|io9x6|iD]'} | |joq‰n|i | ƒq‰Wn~t|dƒ p |i o"d|jo|i dƒqnt|dƒt|dƒ p |i o"d|jo|i dƒqQnt|dƒt|dƒ p |i o"d|jo|i dƒqœnt|dƒ||_dS( Nis Converting %stno_ipsectipsectno_mdnstmdnstno_ipptipp(tlentservicest_tfilenamet fw_servicest service_listtportstTrueRRtappendtFalsetkeytextendthasattrRtdelattrRR( tconfigR Rtmatchedtsvct_matchedt all_matchedtporttprototidtnametentry((s./usr/share/system-config-firewall/fw_compat.pytconvertToServicess^              (t fw_functionsRRR R (((s./usr/share/system-config-firewall/fw_compat.pyts PKƒU[s¯lUDLDLfw_iptables.pynuW+A„¶# # Copyright (C) 2007, 2008 Red Hat, Inc. # Authors: # Thomas Woerner # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # import os, os.path import tempfile import shutil import types import fw_services import fw_icmp from fw_config import _ from fw_functions import * ############################################################################## class _Setting: def __init__ (self, key, name, description=None, iptables=False, ip6tables=False): self.key = key self.name = name self.description = description self.iptables = iptables self.ip6tables = ip6tables setting_list = [ _Setting("MODULES_UNLOAD", _("Unload modules on restart and stop"), _("To ensure a sane state, the kernel firewall modules must be " "unloaded when the firewall is restarted or stopped."), True, True), _Setting("SAVE_ON_STOP", _("Save on stop"), _("Save the active firewall configuration with all changes since " "the last start before stopping the firewall. Only do this if " "you need to preserve the active state for the next start.")), _Setting("SAVE_ON_RESTART", _("Save on restart"), _("Save the active firewall configuration with all changes since " "the last start before restarting the firewall. Only do this if " "you need to preserve the active state for the next start.")), _Setting("SAVE_COUNTER", _("Save and restore counter"), _("Save on stop and Save on restart additionally " "save rule and chain counter.")), _Setting("STATUS_NUMERIC", _("Numeric status output"), _("Print addresses and ports in numeric format for the status " "output."), True, True), _Setting("STATUS_VERBOSE", _("Verbose status"), _("Print information about the number of packets and bytes plus " "the input- and outputdevice in the status " "output.")), _Setting("STATUS_LINENUMBERS", _("Status line numbers"), _("Print a counter/number for every rule in the status output."), True, True), ] def getByKey(key): for x in setting_list: if x.key == key: return x return None def getByName(name): for x in setting_list: if x.name == name: return x return None ############################################################################## class ip4tablesConfig: prefix = "IPTABLES_" def __init__(self, filename): self.filename = filename self.clear() def clear(self): self.p_config = { } self.set("%sMODULES" % self.prefix, [ ]) self.set("%sMODULES_UNLOAD" % self.prefix, "yes") self.set("%sSAVE_ON_STOP" % self.prefix, "no") self.set("%sSAVE_ON_RESTART" % self.prefix, "no") self.set("%sSAVE_COUNTER" % self.prefix, "no") self.set("%sSTATUS_NUMERIC" % self.prefix, "yes") self.set("%sSTATUS_VERBOSE" % self.prefix, "no") self.set("%sSTATUS_LINENUMBERS" % self.prefix, "yes") def get(self, key): if key in self.p_config.keys(): return self.p_config[key] return None def set(self, key, value): if key[-8:] == "_MODULES": self.p_config[key.strip()] = value else: self.p_config[key.strip()] = value.strip() def __str__(self): s = "" for (key,value) in self.p_config.items(): if s: s += '\n' s += '%s = %s' % (key, value) return s # load self.filename def read(self): self.clear() file = open(self.filename, "r") for line in file.xreadlines(): if not line: break line = line.strip() if len(line) < 1 or line[0] == '#': continue # get key/value pairs p = line.split("=") if len(p) != 2: continue key = p[0].strip() value = p[1].strip() # remove leading and trailing double quotes if len(value) > 0 and value[0] == '"' and value[-1] == '"': value = value[1:-1] if key[-8:] == "_MODULES": value = value.split() self.p_config[key] = value file.close() # save to self.filename if there are key/value changes def write(self): if len(self.p_config) < 1: # no changes: nothing to do return if os.path.exists(self.filename): shutil.copy2(self.filename, "%s.old" % self.filename) temp_dir = tempfile.mkdtemp() temp_file = "%s/%s" % (temp_dir, "config") fd = open(temp_file, "w") modified = False try: file = open(self.filename, "r") except: file = None else: for line in file.xreadlines(): if not line: break # remove newline at and on line if line[-1:] == "\n": line = line[:-1] if len(line) < 1: fd.write("\n") continue if line[0] != "#" and len(line) > 1: p = line.split("=") if len(p) != 2: fd.write(line+"\n") continue key = p[0].strip() value = p[1].strip() # remove leading and trailing double quotes if len(value) > 0 and value[0] == '"' and value[-1] == '"': value = value[1:-1] if key[-8:] == "_MODULES": value = value.split() if (key in self.p_config.keys() and \ self.p_config[key] != value) or \ key not in self.p_config.keys(): self._write(fd, key, self.p_config[key]) modified = True del self.p_config[key] else: fd.write(line+"\n") del self.p_config[key] else: fd.write(line+"\n") # write remaining key/value pairs if len(self.p_config) > 0: fd.write("\n") for (key,value) in self.p_config.items(): self._write(fd, key, value) modified = True if file: file.close() fd.close() try: file = open(self.filename, "w") except: shutil.rmtree(temp_dir) raise IOError, "Permission denied: '%s'" % self.filename os.chmod(self.filename, 0600) # copy content for line in open(temp_file, "r"): file.write(line) file.close() shutil.rmtree(temp_dir) def _write(self, fd, key, value): if isinstance(value, types.ListType) or \ isinstance(value, types.TupleType): val = " ".join(value) else: val = value fd.write('%s="%s"\n' % (key, val)) ############################################################################## class ip6tablesConfig(ip4tablesConfig): prefix = "IP6TABLES_" ############################################################################## class iptablesClass: prog = "iptables" type = "ipv4" def __init__(self, filename): self.filename = filename def write(self, conf): if self.type == "ipv4": reject_type = "icmp-host-prohibited" else: reject_type = "icmp6-adm-prohibited" custom_mangle = [ ] custom_nat = [ ] custom_filter = [ ] if conf.custom_rules and len(conf.custom_rules) > 0: for (_type, table, filename) in conf.custom_rules: if _type != self.type: continue # ignore missing files if not os.path.exists(filename) or \ not os.path.isfile(filename): continue if table == "mangle": custom_mangle.append(filename) elif table == "nat": custom_nat.append(filename) elif table == "filter": custom_filter.append(filename) if os.path.exists(self.filename): shutil.copy2(self.filename, "%s.old" % self.filename) # do we have local or remote forwarding? local_forward = False remote_forward = False if conf.forward_port: for fwd in conf.forward_port: if fwd.has_key("toaddr"): remote_forward = True else: local_forward = True mark_idx = 100 fd = open(self.filename, "w") os.chmod(self.filename, 0600) fd.write("# Firewall configuration written by system-config-firewall\n") fd.write("# Manual customization of this file is not recommended.\n") ### MANGLE ### if len(custom_mangle) > 0 or (self.type == "ipv4" and local_forward): fd.write("*mangle\n") fd.write(":PREROUTING ACCEPT [0:0]\n") fd.write(":INPUT ACCEPT [0:0]\n") fd.write(":FORWARD ACCEPT [0:0]\n") fd.write(":OUTPUT ACCEPT [0:0]\n") fd.write(":POSTROUTING ACCEPT [0:0]\n") # custom rules for filename in custom_mangle: catFile(fd, filename) if self.type == "ipv4" and \ (conf.forward_port and len(conf.forward_port) > 0): for fwd in conf.forward_port: if fwd.has_key("toaddr"): continue port = self._portStr(fwd["port"]) fwd["mark"] = mark_idx mark_idx += 1 fd.write("-A PREROUTING -i %s -p %s --dport %s " "-j MARK --set-mark 0x%x\n" % (fwd["if"], fwd["proto"], port, fwd["mark"])) fd.write("COMMIT\n") ### NAT ### # no support for nat for netfilterv6 for now if self.type == "ipv4" and \ ((conf.masq and len(conf.masq) > 0) or len(custom_nat) > 0 or \ (conf.forward_port and len(conf.forward_port) > 0)): fd.write("*nat\n") fd.write(":PREROUTING ACCEPT [0:0]\n") fd.write(":OUTPUT ACCEPT [0:0]\n") fd.write(":POSTROUTING ACCEPT [0:0]\n") # masquerading if conf.masq: for dev in conf.masq: fd.write("-A POSTROUTING -o %s -j MASQUERADE\n" % dev) # port forward if conf.forward_port: for fwd in conf.forward_port: port = self._portStr(fwd["port"]) to = "" mark = "" if fwd.has_key("toaddr"): to += fwd["toaddr"] else: mark = "-m mark --mark 0x%x " % fwd["mark"] if fwd.has_key("toport"): # the port range delimiter for DNAT is '-' to += ":%s" % self._portStr(fwd["toport"], "-") fd.write("-A PREROUTING -i %s -p %s --dport %s %s" "-j DNAT --to-destination %s\n" % \ (fwd["if"], fwd["proto"], port, mark, to)) # custom rules for filename in custom_nat: catFile(fd, filename) fd.write("COMMIT\n") ### FILTER ### fd.write("*filter\n") fd.write(":INPUT ACCEPT [0:0]\n") fd.write(":FORWARD ACCEPT [0:0]\n") fd.write(":OUTPUT ACCEPT [0:0]\n") # INPUT # accept established and related connections as early as possible # RELATED is extremely important as it matches ICMP error messages fd.write("-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT\n") # icmp self._icmp(conf, fd, "INPUT", reject_type) # trust lo fd.write("-A INPUT -i lo -j ACCEPT\n") # Always allow ipv6-dhcp if self.type == "ipv6": fd.write("-A INPUT -m state --state NEW -m udp -p udp --dport 546 -d fe80::/64 -j ACCEPT\n") # trusted interfaces if conf.trust: for dev in conf.trust: fd.write("-A INPUT -i %s -j ACCEPT\n" % dev) # forward local if self.type == "ipv4" and conf.forward_port: for fwd in conf.forward_port: if fwd.has_key("toaddr"): continue line = "-A INPUT -i %s -m state --state NEW -m %s -p %s" % \ (fwd["if"], fwd["proto"], fwd["proto"]) if fwd.has_key("toport"): line += " --dport %s" % self._portStr(fwd["toport"]) line += " -m mark --mark 0x%x" % fwd["mark"] line += " -j ACCEPT\n" fd.write(line) # open services if conf.services and len(conf.services) > 0: for service in conf.services: svc = fw_services.getByKey(service) for (port,proto) in svc.ports: _state = "" _dest = "" _port = "" if proto in [ "tcp", "udp" ]: _state = "-m state --state NEW " _proto = "-m %s -p %s " % (proto, proto) else: if self.type == "ipv4": _proto = "-p %s " % proto else: _proto = "-m ipv6header --header %s " % proto if port: _port = "--dport %s " % port if svc.destination.has_key(self.type): _dest = "-d %s " % svc.destination[self.type] fd.write("-A INPUT " + _state + _proto + _port + _dest + "-j ACCEPT\n") # open ports if conf.ports and len(conf.ports) > 0: for (ports, proto) in conf.ports: fd.write("-A INPUT -m state --state NEW -m %s -p %s --dport %s " "-j ACCEPT\n" % (proto, proto, self._portStr(ports))) # FORWARD if (conf.trust and len(conf.trust) > 0) or \ (self.type == "ipv4" and conf.masq and len(conf.masq) > 0) or \ (self.type == "ipv4" and remote_forward): # accept established and related connections fd.write("-A FORWARD -m state --state ESTABLISHED,RELATED " "-j ACCEPT\n") # icmp self._icmp(conf, fd, "FORWARD", reject_type) # trust lo fd.write("-A FORWARD -i lo -j ACCEPT\n") # trusted interfaces if conf.trust: for dev in conf.trust: fd.write("-A FORWARD -i %s -j ACCEPT\n" % dev) # allow to output to masqueraded interfaces (IPv4 only) if self.type == "ipv4" and conf.masq: for dev in conf.masq: fd.write("-A FORWARD -o %s -j ACCEPT\n" % dev) # forward remote if self.type == "ipv4" and conf.forward_port and remote_forward: for fwd in conf.forward_port: if not fwd.has_key("toaddr"): continue if fwd.has_key("toport"): port = self._portStr(fwd["toport"]) else: port = self._portStr(fwd["port"]) fd.write("-A FORWARD -i %s -m state --state NEW " "-m %s -p %s -d %s --dport %s " "-j ACCEPT\n" % (fwd["if"], fwd["proto"], fwd["proto"], fwd["toaddr"], port)) # add custom filter rules if len(custom_filter) > 0: for _filename in custom_filter: catFile(fd, _filename) # reject remaining INPUT and OUTPUT fd.write("-A INPUT -j REJECT --reject-with %s\n" % reject_type) fd.write("-A FORWARD -j REJECT --reject-with %s\n" % reject_type) # OUTPUT # no output rules, yet fd.write("COMMIT\n") fd.close() def _icmp(self, conf, fd, chain, reject_type): if self.type == "ipv4": proto = "-p icmp" match = "-m icmp --icmp-type" else: proto = "-p ipv6-icmp" match = "-m icmp6 --icmpv6-type" for key in conf.block_icmp: icmp = fw_icmp.getByKey(key) if icmp.type and self.type not in icmp.type: continue fd.write("-A %s %s %s %s -j REJECT --reject-with %s\n" % \ (chain, proto, match, key, reject_type)) fd.write("-A %s %s -j ACCEPT\n" % (chain, proto)) def _portStr(self, port, delimiter=":"): if len(port) == 1: return "%s" % port else: return "%s%s%s" % (port[0], delimiter, port[1]) def _run(self, prog, arg, verbose=False): cmd = "%s %s %s" % (prog, self.prog, arg) if not verbose: cmd += " >/dev/null 2>&1" return os.system(cmd) >> 8 def start(self, verbose=False): return self._run("/sbin/service", "start", verbose) def restart(self, verbose=False): return self._run("/sbin/service", "restart", verbose) def condrestart(self, verbose=False): return self._run("/sbin/service", "condrestart", verbose) def status(self, verbose=False): return self._run("/sbin/service", "status", verbose) def stop(self, verbose=False): return self._run("/sbin/service", "stop", verbose) def chkconfig_on(self, verbose=False): return self._run("/sbin/chkconfig", "on", verbose) def chkconfig_off(self, verbose=False): return self._run("/sbin/chkconfig", "off", verbose) def unlink(self): if os.path.exists(self.filename) and os.path.isfile(self.filename): os.unlink(self.filename) ############################################################################## class ip6tablesClass(iptablesClass): prog = "ip6tables" type = "ipv6" PKƒU[éuÃï fw_functions.pyonuW+A„¶Ñò íðeTc@sRddkZddkZd„Zd„Zd„Zd„Zd„Zd„ZdS(iÿÿÿÿNcCs‚t|tiƒo |}nP|o|iƒ}nyt|ƒ}Wn%yti|ƒ}WqldSXnX|djodS|S(Niÿÿÿÿiÿÿ(t isinstancettypestIntTypetstriptinttsockett getservbyname(tporttid((s1/usr/share/system-config-firewall/fw_functions.pyt getPortIDs   cCs§t|tiƒo&t|ƒ}|djo|fSdS|idƒ}g}xtt|ƒddƒD]}tdi|| ƒƒ}di||ƒ}t|ƒdjo†t|ƒ}|djoi|djo\||jo|i||fƒq.||jo|i||fƒq.|i|fƒqkqg|djo,|i|fƒ|t|ƒjoPqkqgqgWt|ƒdjodSt|ƒdjodS|dS(Niiÿÿÿÿt-i( RRRR tsplittxrangetlentjointappendtNone(tportsRtsplitstmatchedtitid1tport2tid2((s1/usr/share/system-config-firewall/fw_functions.pyt getPortRange's8       cCs+ytit|ƒ|ƒ}WndSX|S(N(Rt getservbyportRR(Rtprototname((s1/usr/share/system-config-firewall/fw_functions.pytgetServiceNameHs cCsPyt|dƒ}WntSXx!|iƒD]}|i|ƒq+W|iƒtS(Ntr(topentFalset xreadlinestwritetclosetTrue(tfdtfilenamet source_fdtline((s1/usr/share/system-config-firewall/fw_functions.pytcatFileOs  cCs—|djo†|idƒ}t|ƒdjotSx\tt|ƒƒD]D}yt||ƒ}WntSX|djp |djotSqGWntS(Ntt.iiiÿ(R R RR RR#(tipRRtl((s1/usr/share/system-config-firewall/fw_functions.pytcheckIPYs  cCsh| pt|ƒdjotSx/dddddgD]}||jotSq6W|djotStS(Nit t/t!t:t*t+(R RR#(tifacetch((s1/usr/share/system-config-firewall/fw_functions.pytcheckInterfacegs   (RRR RRR(R-R6(((s1/usr/share/system-config-firewall/fw_functions.pyts   !  PKƒU[¢Eâ¹(>(>fw_iptables.pycnuW+A„¶Ñò íðeTc@s¾ddkZddkZddkZddkZddkZddkZddkZddklZddk Tdfd„ƒYZ e dedƒedƒe e ƒe d ed ƒed ƒƒe d ed ƒedƒƒe dedƒedƒƒe dedƒedƒe e ƒe dedƒedƒƒe dedƒedƒe e ƒgZ d„Z d„Zdfd„ƒYZdefd „ƒYZd!fd"„ƒYZd#efd$„ƒYZdS(%iÿÿÿÿN(t_(t*t_SettingcBseZdeed„ZRS(cCs1||_||_||_||_||_dS(N(tkeytnamet descriptiontiptablest ip6tables(tselfRRRRR((s0/usr/share/system-config-firewall/fw_iptables.pyt__init__!s     N(t__name__t __module__tNonetFalseR (((s0/usr/share/system-config-firewall/fw_iptables.pyR stMODULES_UNLOADs"Unload modules on restart and stopsoTo ensure a sane state, the kernel firewall modules must be unloaded when the firewall is restarted or stopped.t SAVE_ON_STOPs Save on stops´Save the active firewall configuration with all changes since the last start before stopping the firewall. Only do this if you need to preserve the active state for the next start.tSAVE_ON_RESTARTsSave on restarts¶Save the active firewall configuration with all changes since the last start before restarting the firewall. Only do this if you need to preserve the active state for the next start.t SAVE_COUNTERsSave and restore countersXSave on stop and Save on restart additionally save rule and chain counter.tSTATUS_NUMERICsNumeric status outputsBPrint addresses and ports in numeric format for the status output.tSTATUS_VERBOSEsVerbose statuss|Print information about the number of packets and bytes plus the input- and outputdevice in the status output.tSTATUS_LINENUMBERSsStatus line numberss;Print a counter/number for every rule in the status output.cCs*x#tD]}|i|jo|SqWdS(N(t setting_listRR (Rtx((s0/usr/share/system-config-firewall/fw_iptables.pytgetByKeyFs  cCs*x#tD]}|i|jo|SqWdS(N(RRR (RR((s0/usr/share/system-config-firewall/fw_iptables.pyt getByNameLs  tip4tablesConfigcBsVeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( t IPTABLES_cCs||_|iƒdS(N(tfilenametclear(RR((s0/usr/share/system-config-firewall/fw_iptables.pyR Ws cCsÅh|_|id|igƒ|id|idƒ|id|idƒ|id|idƒ|id|idƒ|id|idƒ|id |idƒ|id |idƒdS( Ns %sMODULESs%sMODULES_UNLOADtyess%sSAVE_ON_STOPtnos%sSAVE_ON_RESTARTs%sSAVE_COUNTERs%sSTATUS_NUMERICs%sSTATUS_VERBOSEs%sSTATUS_LINENUMBERS(tp_configtsettprefix(R((s0/usr/share/system-config-firewall/fw_iptables.pyR[s cCs&||iiƒjo |i|SdS(N(RtkeysR (RR((s0/usr/share/system-config-firewall/fw_iptables.pytgetfs cCsE|ddjo||i|iƒ|iD]/\}}| id9|||i|ƒfƒq¼Wn|iot|iƒdjpG|idjo |iot|iƒdjp|idjok| od| id:ƒ|i|| d;|ƒ| id<ƒ|io)x&|iD]}| id=|ƒqžWn|idjo3|io)x&|iD]}| id>|ƒqáWn|idjoª|i o | o™x–|i D]‡} | i d ƒpq+ n| i d ƒo|i| d ƒ}n|i| dƒ}| id?| d| d| d| d |fƒq+ Wq¾ nt|ƒdjo"x|D]}t| |ƒqØ Wn| id@|ƒ| idA|ƒ| idƒ| iƒdS(CNRUsicmp-host-prohibitedsicmp6-adm-prohibiteditmangletnattfilters%s.oldttoaddridR9i€s;# Firewall configuration written by system-config-firewall s8# Manual customization of this file is not recommended. s*mangle s:PREROUTING ACCEPT [0:0] s:INPUT ACCEPT [0:0] s:FORWARD ACCEPT [0:0] s:OUTPUT ACCEPT [0:0] s:POSTROUTING ACCEPT [0:0] tporttmarkis=-A PREROUTING -i %s -p %s --dport %s -j MARK --set-mark 0x%x tiftprotosCOMMIT s*nat s#-A POSTROUTING -o %s -j MASQUERADE R's-m mark --mark 0x%x ttoports:%st-sC-A PREROUTING -i %s -p %s --dport %s %s-j DNAT --to-destination %s s*filter s8-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT tINPUTs-A INPUT -i lo -j ACCEPT tipv6sO-A INPUT -m state --state NEW -m udp -p udp --dport 546 -d fe80::/64 -j ACCEPT s-A INPUT -i %s -j ACCEPT s/-A INPUT -i %s -m state --state NEW -m %s -p %ss --dport %ss -m mark --mark 0x%xs -j ACCEPT ttcptudps-m state --state NEW s -m %s -p %s s-p %s s-m ipv6header --header %s s --dport %s s-d %s s -A INPUT s -j ACCEPT s?-A INPUT -m state --state NEW -m %s -p %s --dport %s -j ACCEPT s:-A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT tFORWARDs-A FORWARD -i lo -j ACCEPT s-A FORWARD -i %s -j ACCEPT s-A FORWARD -o %s -j ACCEPT sM-A FORWARD -i %s -m state --state NEW -m %s -p %s -d %s --dport %s -j ACCEPT s$-A INPUT -j REJECT --reject-with %s s&-A FORWARD -j REJECT --reject-with %s (RbRc(ttypet custom_rulesR1R:R;R<tisfiletappendRR=R>R t forward_portthas_keyRCR/RFRAtcatFilet_portStrtmasqt_icmpttrusttservicest fw_servicesRtportst destinationR3(Rtconft reject_typet custom_manglet custom_natt custom_filtert_typettableRt local_forwardtremote_forwardtfwdtmark_idxRIRZtdevttoR[R5tservicetsvcR]t_statet_destt_portt_protoRrt _filename((s0/usr/share/system-config-firewall/fw_iptables.pyRAósZ           *           3         " '                  " 0     !   c Cs®|idjod}d}n d}d}xd|iD]Y}ti|ƒ}|io|i|ijoq6n|id|||||fƒq6W|id||fƒdS(NRUs-p icmps-m icmp --icmp-types -p ipv6-icmps-m icmp6 --icmpv6-types*-A %s %s %s %s -j REJECT --reject-with %s s-A %s %s -j ACCEPT (Ret block_icmptfw_icmpRRA( RRtRItchainRuR]tmatchRticmp((s0/usr/share/system-config-firewall/fw_iptables.pyRnÓs   t:cCs9t|ƒdjo d|Sd|d||dfSdS(Nis%ss%s%s%si(R1(RRZt delimiter((s0/usr/share/system-config-firewall/fw_iptables.pyRlãs cCs<d||i|f}|p|d7}nti|ƒd?S(Ns%s %s %ss >/dev/null 2>&1i(tprogR:tsystem(RRtargtverbosetcmd((s0/usr/share/system-config-firewall/fw_iptables.pyt_runéscCs|idd|ƒS(Ns /sbin/servicetstart(R”(RR’((s0/usr/share/system-config-firewall/fw_iptables.pyR•ïscCs|idd|ƒS(Ns /sbin/servicetrestart(R”(RR’((s0/usr/share/system-config-firewall/fw_iptables.pyR–òscCs|idd|ƒS(Ns /sbin/servicet condrestart(R”(RR’((s0/usr/share/system-config-firewall/fw_iptables.pyR—õscCs|idd|ƒS(Ns /sbin/servicetstatus(R”(RR’((s0/usr/share/system-config-firewall/fw_iptables.pyR˜øscCs|idd|ƒS(Ns /sbin/servicetstop(R”(RR’((s0/usr/share/system-config-firewall/fw_iptables.pyR™ûscCs|idd|ƒS(Ns/sbin/chkconfigton(R”(RR’((s0/usr/share/system-config-firewall/fw_iptables.pyt chkconfig_onþscCs|idd|ƒS(Ns/sbin/chkconfigtoff(R”(RR’((s0/usr/share/system-config-firewall/fw_iptables.pyt chkconfig_offscCsDtii|iƒo*tii|iƒoti|iƒndS(N(R:R;R<RRgtunlink(R((s0/usr/share/system-config-firewall/fw_iptables.pyRžs,(R R RReR RARnRlR R”R•R–R—R˜R™R›RRž(((s0/usr/share/system-config-firewall/fw_iptables.pyRTìs  à          tip6tablesClasscBseZdZdZRS(RRa(R R RRe(((s0/usr/share/system-config-firewall/fw_iptables.pyRŸ s(R:tos.pathR?R=RMRqR‰t fw_configRt fw_functionsRRCRRRRRRRTRŸ(((s0/usr/share/system-config-firewall/fw_iptables.pyts@                  “ÿPKƒU[·5D5ÀÀ fw_nm.pyonuW+A„¶Ñò íðeTc@s¢ddkZdZdZdZdZdZdZdZd Zd Z d Z d Z d Z hde6de 6de 6de 6de 6Z ddkZeiƒZd„ZdS(iÿÿÿÿNs/org/freedesktop/NetworkManagersorg.freedesktop.NetworkManagers,org.freedesktop.NetworkManagerSystemSettingss*org.freedesktop.NetworkManagerUserSettingss%org.freedesktop.NetworkManager.Devices+org.freedesktop.NetworkManager.Device.Wireds.org.freedesktop.NetworkManager.Device.Wirelessiiiiis unknown typeswired Ethernets 802.11 WiFisGSM-based cellular WANsCDMA/IS-95-based cellular WANc Cs2h}x%ttgD]}ti|tƒ}ti|dtƒ}y|iƒ}Wn qnXxÊ|D]Â}ti||ƒ}ti|ddƒ}|i t dƒ}|i t dƒ}|t jo|i t dƒ} n'|t jo|i tdƒ} nqdht|d6t| ƒd6|t|ƒs*    PKƒU[Çú²½ ½ fw_config.pyonuW+A„¶Ñò íðeTc@s.ddkZeieidƒdZddkZd„ZddkZeeidst_s /usr/share/s.glades(C) 2007-2009 Red Hat, Inc.s1.2.27s$Thomas Woerner s!Chris Lumens s!Florian Festi sBrent Fox scThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see .s/etc/sysconfig/iptabless/etc/sysconfig/ip6tabless/etc/sysconfig/iptables-configs/etc/sysconfig/ip6tables-configs%/etc/sysconfig/system-config-firewalls*/etc/sysconfig/system-config-securitylevels/etc/selinux/configs/etc/sysconfig/selinuxs/etc/sysctl.conftppptisdntipppttuntwlantipv4tipv6tmangletnattfiltertservertdesktopt enforcingt permissivetdisabledttargeted(!tlocalet setlocaletLC_ALLRRRt __builtin__t__dict__tNonetuitAPP_NAMEtDATADIRt GLADE_NAMEt COPYRIGHTtVERSIONtAUTHORStLICENSEtIP4TABLES_RULEStIP6TABLES_RULESt IP4TABLES_CFGt IP6TABLES_CFGtCONFIGt OLD_CONFIGt SE_CONFIGt OLD_SE_CONFIGt SYSCTL_CONFIGt STD_DEVICEStFIREWALL_TYPEStFIREWALL_TABLESt DEFAULT_TYPESt SELINUX_MODEStDEFAULT_SELINUX_MODEtDEFAULT_SELINUX_TYPE(((s./usr/share/system-config-firewall/fw_config.pytsD           PKƒU[ë$En““ fw_sysctl.pycnuW+A„¶Ñò íðeTc@sGddkZddkZddkZddkZddd„ƒYZdS(iÿÿÿÿNt sysctlClasscBsYeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( cCs||_|iƒdS(N(tfilenametclear(tselfR((s./usr/share/system-config-firewall/fw_sysctl.pyt__init__s cCsh|_g|_dS(N(tp_configt p_deleted(R((s./usr/share/system-config-firewall/fw_sysctl.pyRs cCs,|iƒ}||ijo |i|SdS(N(tstripRtNone(Rtkeyt_key((s./usr/share/system-config-firewall/fw_sysctl.pytget#s  cCsE|iƒ}|iƒ|i|<||ijo|ii|ndS(N(RRRtremove(RR tvalueR ((s./usr/share/system-config-firewall/fw_sysctl.pytset)s cCsR|iƒ}||ijo|i|=n||ijo|ii|ƒndS(N(RRRtappend(RR R ((s./usr/share/system-config-firewall/fw_sysctl.pytunset/s  cCsSd}xF|iiƒD]5\}}|o|d7}n|d||f7}qW|S(Nts s%s = %s(Rtitems(RtsR R ((s./usr/share/system-config-firewall/fw_sysctl.pyt__str__6s cCsÎ|iƒt|idƒ}x¡|iƒD]“}|pPn|iƒ}t|ƒdjp|ddjoq)n|idƒ}t|ƒdjoq)n|diƒ|i|diƒ/dev/null(R%tsystemR(R((s./usr/share/system-config-firewall/fw_sysctl.pytreload¦s( t__name__t __module__RRR RRRR!R&R7(((s./usr/share/system-config-firewall/fw_sysctl.pyRs       V((R%tos.pathR"R*R(((s./usr/share/system-config-firewall/fw_sysctl.pyts  PKƒU[·5D5ÀÀ fw_nm.pycnuW+A„¶Ñò íðeTc@s¢ddkZdZdZdZdZdZdZdZd Zd Z d Z d Z d Z hde6de 6de 6de 6de 6Z ddkZeiƒZd„ZdS(iÿÿÿÿNs/org/freedesktop/NetworkManagersorg.freedesktop.NetworkManagers,org.freedesktop.NetworkManagerSystemSettingss*org.freedesktop.NetworkManagerUserSettingss%org.freedesktop.NetworkManager.Devices+org.freedesktop.NetworkManager.Device.Wireds.org.freedesktop.NetworkManager.Device.Wirelessiiiiis unknown typeswired Ethernets 802.11 WiFisGSM-based cellular WANsCDMA/IS-95-based cellular WANc Cs2h}x%ttgD]}ti|tƒ}ti|dtƒ}y|iƒ}Wn qnXxÊ|D]Â}ti||ƒ}ti|ddƒ}|i t dƒ}|i t dƒ}|t jo|i t dƒ} n'|t jo|i tdƒ} nqdht|d6t| ƒd6|t|ƒs*    PKƒU[d¦B3ÒÒconvert-confignuW+A„¶#!/usr/bin/python # # Copyright (C) 2007, 2008 Red Hat, Inc. # Authors: # Thomas Woerner # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # Converts config file from system-config-firewall-1.0.X to # system-config-firewall-1.1.X # import os, os.path, sys DATADIR = '/usr/share/system-config-firewall' import sys sys.path.append(DATADIR) from fw_config import * from fw_functions import getPortID, getServiceName from fw_sysconfig import * import fw_services import fw_compat # check euid if os.geteuid() != 0: print _("\nERROR - You must be root to run %s.") % \ os.path.basename(sys.argv[0]) sys.exit(1) ### load configuration ### config = read_sysconfig_config(compat=True) if not config: sys.exit(0) # OLD_CONFIG (system-config-securitylevel) already converted, but not 1.0 # style CONFIG (system-config-firewall) if not config.converted and len(config.services) > 0: # already new stlye file format: sys.exit(0) fw_compat.convertToServices(config) c_status = int(write_sysconfig_config(CONFIG, config) == False) if c_status != 0: print _("Failed to write %s.") % CONFIG sys.exit(c_status) PKƒU[gpô"0"0fw_services.pynuW+A„¶# # Copyright (C) 2007, 2008 Red Hat, Inc. # Authors: # Thomas Woerner # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # from fw_config import _ from fw_functions import getPortID, getServiceName class _Service: def __init__ (self, key, name, ports, description=None, modules=[ ], destination={ }, default=None): self.key = key self.name = name self.ports = ports self.description = description self.modules = modules self.destination = destination self.default = default service_list = [ _Service("ipp-client", _("Network Printing Client (IPP)"), [ ("631", "udp"), ], _("The Internet Printing Protocol (IPP) is used for " "distributed printing. IPP (over udp) provides the ability to " "get information about a printer (e.g. capability and status) " "and to control printer jobs. If you plan to use a remote " "network printer via cups, do not disable this option."), default=["desktop"]), _Service("ipp", _("Network Printing Server (IPP)"), [ ("631", "tcp"), ("631", "udp"), ], _("The Internet Printing Protocol (IPP) is used for " "distributed printing. IPP (over tcp) provides the ability to " "share printers over the network. Enable this option if you " "plan to share printers via cups over the network.")), _Service("mdns", _("Multicast DNS (mDNS)"), [ ("5353", "udp"), ], _("mDNS provides the ability to use DNS programming " "interfaces, packet formats and operating semantics in a " "small network without a conventional DNS server. If you plan " "to use Avahi, do not disable this option."), default=["desktop"], destination={"ipv4": "224.0.0.251", "ipv6": "ff02::fb"}), _Service("ipsec", _("IPsec"), [ (None, "ah"), (None, "esp"), (500, "udp"), ], _("Internet Protocol Security (IPsec) incorporates security " "for network transmissions directly into the Internet Protocol " "(IP). IPsec provides methods for both encrypting data " "and authentication for the host or network it sends to. If you " "plan to use a vpnc server or FreeS/WAN, do not disable this " "option."), default=["desktop"]), _Service("ssh", _("SSH"), [ ("22", "tcp"), ], _("Secure Shell (SSH) is a protocol for logging into and " "executing commands on remote machines. It provides secure " "encrypted communications. If you plan on accessing your " "machine remotely via SSH over a firewalled interface, enable " "this option. You need the openssh-server package installed " "for this option to be useful." ), default=["server"]), # _Service("telnet", _("Telnet"), [ ("23", "tcp"), ], # "Telnet is a protocol for logging into remote machines. It " # "is unencrypted, and provides little security from network " # "snooping attacks. Enabling telnet is not recommended. You need " # "the telnet-server package installed for this option to be " # "useful."), _Service("http", _("WWW (HTTP)"), [ ("80", "tcp"), ], _("HTTP is the protocol used to serve Web pages. If you plan to " "make your Web server publicly available, enable this option. " "This option is not required for viewing pages locally or " "developing Web pages.")), _Service("ftp", _("FTP"), [ ("21", "tcp"), ], _("FTP is a protocol used for remote file transfer. If you plan " "to make your FTP server publicly available, enable this " "option. You need the vsftpd package installed for this option " "to be useful."), modules=[ "nf_conntrack_ftp", ]), _Service("nfs", _("NFS4"), [ ("2049", "tcp"), ], _("The NFS4 protocol is used to share files via TCP networking. " "You will need to have the NFS tools installed " "and properly configure your NFS server for this option to be " "useful.")), _Service("https", _("Secure WWW (HTTPS)"), [ ("443", "tcp"), ], _("HTTPS is a modified HTTP used to serve Web pages when security " "is important. Examples are sites that require logins like " "stores or web mail. This option is not required for viewing " "pages locally or developing Web pages. You need the httpd " "package installed for this option to be useful.")), _Service("smtp", _("Mail (SMTP)"), [ ("25", "tcp"), ], _("This option allows incoming SMTP mail delivery. If you need " "to allow " "remote hosts to connect directly to your machine to deliver " "mail, enable this option. You do not need to enable this if " "you collect your mail from your ISP's server by POP3 or IMAP, " "or if you use a tool such as fetchmail. Note that an " "improperly configured SMTP server can allow remote machines " "to use your server to send spam.")), _Service("samba-client", _("Samba Client"), [ ("137", "udp"), ("138", "udp"), ], _("This option allows you to access Windows file and printer " "sharing networks. You need the samba-client " "package installed for this option to be useful."), modules=[ "nf_conntrack_netbios_ns", ], default=["desktop"]), _Service("samba", _("Samba"), [ ("137", "udp"), ("138", "udp"), ("139", "tcp"), ("445", "tcp"), ], _("This option allows you to access and participate in Windows " "file and printer sharing networks. You need the samba " "package installed for this option to be useful."), modules=[ "nf_conntrack_netbios_ns", ]), _Service("dns", _("DNS"), [ ("53", "tcp"), ("53", "udp"), ], _("The Domain Name System (DNS) is used to provide and request " "host and domain names. Enable this option, if you plan to " "provide a domain name service (e.g. with bind).")), _Service("imaps", _("IMAP over SSL"), [ ("993", "tcp"), ], _("The Internet Message Access Protocol over SSL (IMAPs) allows " "a local client to access email on a remote server in a secure " "way. If you plan to provide a IMAP over SSL service (e.g. with " "dovecot), enable this option.")), _Service("pop3s", _("POP-3 over SSL"), [ ("995", "tcp"), ], _("The Post Office Protocol version 3 (POP3) is a protocol to " "retrieve email from a remote server over a TCP/IP " "connection. Enable this option, if you plan to provide a POP3 " "service (e.g. with dovecot).")), _Service("radius", _("RADIUS"), [ ("1812", "udp"), ("1813", "udp"), ], _("The Remote Authentication Dial In User Service (RADIUS) is a " "protocol for user authentication over networks. It is mostly " "used for modem, DSL or wireless user authentication. If you " "plan to provide a RADIUS service (e.g. with freeradius), " "enable this option.")), _Service("openvpn", _("OpenVPN"), [ ("1194", "udp"), ], _("OpenVPN is a virtual private network (VPN) solution. It is " "used to create encrypted point-to-point tunnels between " "computers. If you plan to provide a VPN service, enable this " "option.")), _Service("tftp", _("TFTP"), [ ("69", "udp"), ], _("The Trivial File Transfer Protocol (TFTP) is a protocol used " "to transfer files to and from a remote machine in s simple " "way. It is normally used only for booting diskless " "workstations and also to transfer data in the Preboot " "eXecution Environment (PXE)."), modules=[ "nf_conntrack_tftp", ]), _Service("tftp-client", _("TFTP Client"), [ ], _("This option allows you to access Trivial File Transfer " "Protocol (TFTP) servers. You need the tftp " "package installed for this option to be useful."), modules=[ "nf_conntrack_tftp", ]), _Service("cluster-suite", _("Red Hat Cluster Suite"), [ # corosync/openais (5404, "udp"), (5405, "udp"), # rgmanager pre F-12, RHEL-6 #(41966, "tcp"), (41967, "tcp"), (41968, "tcp"), (41969, "tcp"), # ricci (11111, "tcp"), # dlm (21064, "tcp"), # cssd pre F-12, RHEL-6 #(50006, "tcp"), (50008, "tcp"), (50009, "tcp"), (50007, "udp"), ], _("This option allows you to use the Red Hat Cluster Suite. " "Ports are opened for openais, ricci and dlm. You need the " "Red Hat Cluster Suite installed for this option to be " "useful.")), _Service("amanda-client", _("Amanda Backup Client"), [ (10080, "udp"), ], _("The Amanda backup client option allows you to connect to a " "Amanda backup and archiving server. You need the " "amanda-client package installed for this option to be " "useful."), modules=[ "nf_conntrack_amanda", ]), _Service("bacula-client", _("Bacula Client"), [ (9102, "tcp"), ], _("This option allows a Bacula server to connect to the local " "machine to schedule backups. You need the bacula-client " "package installed for this option to be useful.")), _Service("bacula", _("Bacula"), [ (9101, "tcp"), (9102, "tcp"), (9103, "tcp"), ], _("Bacula is a network backup solution. Enable this option, if " "you plan to provide Bacula backup, file and storage " "services.")), _Service("libvirt", _("Virtual Machine Management"), [ (16509, "tcp"), ], _("Enable this option if you want to allow remote virtual " "machine management with SASL authentication and encryption " "(digest-md5 passwords or GSSAPI/Kerberos). The libvirtd " "service is needed for this option to be useful.")), _Service("libvirt-tls", _("Virtual Machine Management (TLS)"), [ (16514, "tcp"), ], _("Enable this option if you want to allow remote virtual " "machine management with TLS encryption, x509 certificates " "and optional SASL authentication. The libvirtd service is " "needed for this option to be useful.")), ] def getByKey(key): for x in service_list: if x.key == key: return x return None def getByName(name): for x in service_list: if x.name == name: return x return None def getByPort(port, proto): for x in service_list: id = getPortID(port) name = getServiceName(port, proto) if (id, proto) in x.ports or (str(id), proto) in x.ports or \ (name, proto) in x.ports: return x return None PKƒU[$»à› › fw_selinux.pynuW+A„¶# # Copyright (C) 2007 Red Hat, Inc. # Authors: # Thomas Woerner # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # import os, os.path from fw_config import OLD_SE_CONFIG, SE_CONFIG ############################################################################## def read(): filename = None if os.path.exists(SE_CONFIG) and os.path.isfile(SE_CONFIG): filename = SE_CONFIG elif os.path.exists(OLD_SE_CONFIG) and os.path.isfile(OLD_SE_CONFIG): filename = OLD_SE_CONFIG try: fd = open(filename, 'r') except: return None argv = [ ] for line in fd.xreadlines(): if not line: break line = line.strip() if len(line) < 1 or line[0] == '#': continue p = line.split("=") if len(p) != 2: continue key = p[0].strip() value = p[1].strip() if key == "SELINUX": argv.append("--selinux=%s" % value) elif key == "SELINUXTYPE": argv.append("--selinuxtype=%s" % value) fd.close() return argv def write(conf, filename=SE_CONFIG): try: fd = open(filename, "w") except: return False fd.write("# This file controls the state of SELinux on the system.\n") fd.write("# SELINUX= can take one of these three values:\n") fd.write("#\tenforcing - SELinux security policy is enforced.\n") fd.write("#\tpermissive - SELinux prints warnings instead of enforcing.\n") fd.write("#\tdisabled - SELinux is fully disabled.\n") fd.write("SELINUX=%s\n" % conf.selinux) fd.write("# SELINUXTYPE= type of policy in use. Possible values are:\n") fd.write("#\ttargeted - Only targeted network daemons are protected.\n") fd.write("#\tstrict - Full SELinux protection.\n") if conf.selinuxtype: fd.write("SELINUXTYPE=%s\n" % conf.selinuxtype) else: fd.write("#SELINUXTYPE=\n") fd.close() return True def setenforce(value): val = 0 # permissive, disabled if value == "enforcing": val = 1 return os.system("/usr/sbin/setenforce %d" % val) PKƒU[OO9P P fw_selinux.pycnuW+A„¶Ñò íðeTc@sPddkZddkZddklZlZd„Zed„Zd„ZdS(iÿÿÿÿN(t OLD_SE_CONFIGt SE_CONFIGcCsd}tiitƒotiitƒo t}n1tiitƒotiitƒo t}nyt|dƒ}WndSXg}xä|iƒD]Ö}|pPn|i ƒ}t |ƒdjp|ddjoq—n|i dƒ}t |ƒdjoq—n|di ƒ}|di ƒ}|djo|i d|ƒq—|d jo|i d |ƒq—q—W|i ƒ|S( Ntriit#t=itSELINUXs --selinux=%st SELINUXTYPEs--selinuxtype=%s(tNonetostpathtexistsRtisfileRtopent xreadlineststriptlentsplittappendtclose(tfilenametfdtargvtlinetptkeytvalue((s//usr/share/system-config-firewall/fw_selinux.pytreads8& &   $   cCs×yt|dƒ}WntSX|idƒ|idƒ|idƒ|idƒ|idƒ|id|iƒ|idƒ|id ƒ|id ƒ|io|id |iƒn|id ƒ|iƒtS( Ntws9# This file controls the state of SELinux on the system. s/# SELINUX= can take one of these three values: s3# enforcing - SELinux security policy is enforced. s=# permissive - SELinux prints warnings instead of enforcing. s(# disabled - SELinux is fully disabled. s SELINUX=%s s;# SELINUXTYPE= type of policy in use. Possible values are: s:# targeted - Only targeted network daemons are protected. s$# strict - Full SELinux protection. sSELINUXTYPE=%s s#SELINUXTYPE= (R tFalsetwritetselinuxt selinuxtypeRtTrue(tconfRR((s//usr/share/system-config-firewall/fw_selinux.pyR7s$           cCs.d}|djo d}ntid|ƒS(Nit enforcingis/usr/sbin/setenforce %d(Rtsystem(Rtval((s//usr/share/system-config-firewall/fw_selinux.pyt setenforceLs  (Rtos.patht fw_configRRRRR%(((s//usr/share/system-config-firewall/fw_selinux.pyts  PKƒU[<¼rXvvetc_services.pynuW+A„¶# # Copyright (C) 2007 Red Hat, Inc. # Authors: # Thomas Woerner # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # ETC_SERVICES = "/etc/services" def isNumber(string): try: i = int(string) except ValueError: return 0 else: return 1 class _Service: def __init__(self): self.clear() def clear(self): self.p_id = 0 self.p_protocol = "" self.p_name = "" self.p_description = "" self.p_aliases = [ ] def setID(self, id): self.p_id = id def getId(self): return self.p_id def setProtocol(self, protocol): self.p_protocol = protocol def getProtocol(self): return self.p_protocol def setName(self, name): self.p_name = name def getName(self): return self.p_name def setDescription(self, description): self.p_description = description def getDescription(self): return self.p_description def setAliases(self, aliases): self.p_aliases = aliases def getAliases(self): return self.p_aliases def __str__(self): s = "%s\t%d/%s" % (self.getName(), self.getId(), self.getProtocol()) if len(self.getAliases()) > 0: s += "\t%s" % " ".join(self.getAliases()) if self.getDescription() != "": s += "\t# %s" % self.getDescription() return s __repr__ = __str__ class _Services(list): def __init__(self): list.__init__(self) self.load() def load(self): try: fd = open(ETC_SERVICES, "r") except Exception, msg: print msg return for line in fd.xreadlines(): if not line: break if len(line) < 1 or line[0] == '#': continue line = line.strip() # remove all after '#' p = line.split("#") if len(p) < 1: continue line = p[0] if len(p) > 1: description = p[1].strip() else: description = None # remove empty lines if len(line) < 1: continue # remove entries without service name and port/protocol p = line.split() if len(p) < 2: continue # new service service = _Service() # set name and description service.setName(p[0]) if description != None: service.setDescription(description) # port and protocol? p2 = p[1].split("/") if len(p2) < 2: continue # convert to port id try: id = int(p2[0]) except ValueError: continue else: service.setID(id) # set protocol service.setProtocol(p2[1]) # append aliases service.setAliases(p[2:]) # append service self.append(service) fd.close() services = _Services() PKƒU[@D+Ô< < fw_icmp.pyonuW+A„¶PKƒU[éuÃï w fw_functions.pycnuW+A„¶PKƒU[¢Eâ¹(>(>Tfw_iptables.pyonuW+A„¶PKƒU[OO9P P »Sfw_selinux.pyonuW+A„¶PKƒU[&_98ú&ú&I]fw_services.pycnuW+A„¶PKƒU[Æ BB ‚„fw_parser.pycnuW+A„¶PKƒU[?Ûy"¶¶ÚÆetc_services.pycnuW+A„¶PKƒU[Æ BB ÐØfw_parser.pyonuW+A„¶PKƒU[½ê ð——(fw_sysconfig.pyonuW+A„¶PKƒU[Çú²½ ½ ÿ/fw_config.pycnuW+A„¶PKƒU[©@é@  ù9fw_functions.pynuW+A„¶PKƒU[®ÐNöÕ Õ (>ÿfw_iptables.pycnuW+A„¶PKƒU[·5D5ÀÀ g=fw_nm.pyonuW+A„¶PKƒU[Çú²½ ½ `Efw_config.pyonuW+A„¶PKƒU[ë$En““ ZOfw_sysctl.pycnuW+A„¶PKƒU[·5D5ÀÀ *`fw_nm.pycnuW+A„¶PKƒU[d¦B3ÒÒ#hconvert-confignuW+A„¶PKƒU[gpô"0"03ofw_services.pynuW+A„¶PKƒU[$»à› › “Ÿfw_selinux.pynuW+A„¶PKƒU[OO9P P kªfw_selinux.pycnuW+A„¶PKƒU[<¼rXvvù³etc_services.pynuW+A„¶PK(( ®Â