3 YÉjW´ã@søddlmZddlZeejd<ddlZddlZddlZddlZddl m Z ddl m Z m Z mZddlmZddlmZddlmZdd lmZdd lmZdd lmZmZmZdd l mZdd lmZddl m!Z!m"Z"m#Z#m$Z$Gdd„dejj%j&ƒZ'dS)é)ÚGObjectNZgobject)Úconfig)Údbus_to_pythonÚ%dbus_introspection_prepare_propertiesÚ!dbus_introspection_add_properties)ÚZone)Úifcfg_set_zone_of_interface)ÚDEFAULT_ZONE_TARGET)Ú Rich_Rule)Úlog)Úhandle_exceptionsÚdbus_handle_exceptionsÚdbus_service_method)Úerrors)Ú FirewallError)ÚportStrÚportInPortRangeÚcoalescePortRangeÚbreakPortRangecs¨ eZdZdZdZejjZe ‡fdd„ƒZ e dd„ƒZ e dd„ƒZ e d d „ƒZeejd d d �e dºdd„ƒƒZeejddd �e d»dd„ƒƒZejjjejjƒeejdd�e d¼dd„ƒƒƒZejjejdd�dd„ƒZejjjejjƒeejdd�e d½‡fdd„ ƒƒƒZeejjd d�e d¾d!d"„ƒƒZeejjdd�e d¿d#d$„ƒƒZd%d&„Z eejjd d�e dÀd'd(„ƒƒZ!eejjdd�e dÁd)d*„ƒƒZ"eejjƒe dÂd+d,„ƒƒZ#ejjejjdd�e d-d.„ƒƒZ$eejjƒe dÃd/d0„ƒƒZ%ejjejjdd�e d1d2„ƒƒZ&eejjdd�e dÄd3d4„ƒƒZ'ejjejjdd�e d5d6„ƒƒZ(eejjdd�e dÅd7d8„ƒƒZ)eejjdd�e dÆd9d:„ƒƒZ*eejjdd�e dÇd;d<„ƒƒZ+eejjdd�e dÈd=d>„ƒƒZ,eejjdd�e dÉd?d@„ƒƒZ-eejjdd�e dÊdAdB„ƒƒZ.eejjdd�e dËdCdD„ƒƒZ/eejjdd�e dÌdEdF„ƒƒZ0eejjdGd�e dÍdHdI„ƒƒZ1eejjdGd�e dÎdJdK„ƒƒZ2eejjdd�e dÏdLdM„ƒƒZ3eejjdd�e dÐdNdO„ƒƒZ4eejjddPd �e dÑdQdR„ƒƒZ5eejjdSd�e dÒdTdU„ƒƒZ6eejjdSd�e dÓdVdW„ƒƒZ7eejjd d�e dÔdXdY„ƒƒZ8eejjd d�e dÕdZd[„ƒƒZ9eejjd dPd �e dÖd\d]„ƒƒZ:eejjdGd�e d×d^d_„ƒƒZ;eejjdGd�e dØd`da„ƒƒZeejjddPd �e dÛdfdg„ƒƒZ?eejjdSd�e dÜdhdi„ƒƒZ@eejjdSd�e dÝdjdk„ƒƒZAeejjd d�e dÞdldm„ƒƒZBeejjd d�e dßdndo„ƒƒZCeejjd dPd �e dàdpdq„ƒƒZDeejjdGd�e dádrds„ƒƒZEeejjdGd�e dâdtdu„ƒƒZFeejjdd�e dãdvdw„ƒƒZGeejjdd�e dädxdy„ƒƒZHeejjddPd �e dådzd{„ƒƒZIeejjdPd�e dæd|d}„ƒƒZJeejjdPd�e dçd~d„ƒƒZKeejjƒe dèd€d�„ƒƒZLeejjƒe déd‚dƒ„ƒƒZMeejjdPd�e dêd„d…„ƒƒZNeejjdPd�e dëd†d‡„ƒƒZOeejjdPd�e dìdˆd‰„ƒƒZPeejjƒe dídŠd‹„ƒƒZQeejjƒe dîdŒd�„ƒƒZReejjdPd�e dïdŽd�„ƒƒZSeejjd�d�e dðd‘d’„ƒƒZTeejjd�d�e dñd“d”„ƒƒZUeejjd•d�e dòd–d—„ƒƒZVeejjd•d�e dód˜d™„ƒƒZWeejjd•dPd �e dôdšd›„ƒƒZXeejjdGd�e dõdœd�„ƒƒZYeejjdGd�e dödždŸ„ƒƒZZeejjdd�e d÷d d¡„ƒƒZ[eejjdd�e død¢d£„ƒƒZ\eejjddPd �e dùd¤d¥„ƒƒZ]eejjdGd�e dúd¦d§„ƒƒZ^eejjdGd�e dûd¨d©„ƒƒZ_eejjdd�e düdªd«„ƒƒZ`eejjdd�e dýd¬d­„ƒƒZaeejjddPd �e dþd®d¯„ƒƒZbeejjdGd�e dÿd°d±„ƒƒZceejjdGd�e �dd²d³„ƒƒZdeejjdd�e �dd´dµ„ƒƒZeeejjdd�e �dd¶d·„ƒƒZfeejjddPd �e �dd¸d¹„ƒƒZg‡ZhS(ÚFirewallDConfigZonezFirewallD main classTcs\tt|ƒj||Ž||_||_||_||_|d|_|d|_d|j|_ t |tj j ƒdS)Nrézconfig.zone.%d) ÚsuperrÚ__init__ÚparentrÚobjÚitem_idÚbusnameÚpathÚ _log_prefixrÚdbusÚDBUS_INTERFACE_CONFIG_ZONE)ÚselfrZconfZzonerÚargsÚkwargs)Ú __class__©ú!/usr/lib/python3.6/config_zone.pyr=s   zFirewallDConfigZone.__init__cCsdS)Nr%)r!r%r%r&Ú__del__JszFirewallDConfigZone.__del__cCs |jƒdS)N)Zremove_from_connection)r!r%r%r&Ú unregisterNszFirewallDConfigZone.unregistercCs‚|dkrtj|jjƒS|dkr,tj|jjƒS|dkrBtj|jjƒS|dkrXtj|jjƒS|dkrntj|jjƒStj j d|ƒ‚dS)NÚnameÚfilenamerÚdefaultÚbuiltinzDorg.freedesktop.DBus.Error.InvalidArgs: Property '%s' does not exist) rÚStringrr)r*rZBooleanr+r,Ú exceptionsÚ DBusException)r!Ú property_namer%r%r&Ú _get_propertyVsz!FirewallDConfigZone._get_propertyZssÚv)Ú in_signatureÚ out_signatureNcCsLt|tƒ}t|tƒ}tjd|j||ƒ|tjjkrBtjj d|ƒ‚|j |ƒS)Nz%s.Get('%s', '%s')zJorg.freedesktop.DBus.Error.UnknownInterface: Interface '%s' does not exist) rÚstrr Údebug1rrrr r.r/r1)r!Úinterface_namer0Úsenderr%r%r&ÚGetgs    zFirewallDConfigZone.GetÚsza{sv}cCsdt|tƒ}tjd|j|ƒ|tjjkr6tjj d|ƒ‚i}xd D]}|j |ƒ||<q@Wtj |dd �S) Nz%s.GetAll('%s')zJorg.freedesktop.DBus.Error.UnknownInterface: Interface '%s' does not existr)r*rr+r,Zsv)Ú signature)r)r*rr+r,) rr5r r6rrrr r.r/r1Z Dictionary)r!r7r8ÚretÚxr%r%r&ÚGetAllxs   zFirewallDConfigZone.GetAllZssv)r3cCslt|tƒ}t|tƒ}t|ƒ}tjd|j|||ƒ|jj|ƒ|tjj krXtj j d|ƒ‚tj j d|ƒ‚dS)Nz%s.Set('%s', '%s', '%s')zJorg.freedesktop.DBus.Error.UnknownInterface: Interface '%s' does not existzGorg.freedesktop.DBus.Error.PropertyReadOnly: Property '%s' is read-only) rr5r r6rrÚ accessCheckrrr r.r/)r!r7r0Z new_valuer8r%r%r&ÚSet‰s      zFirewallDConfigZone.Setzsa{sv}as)r;cCs2t|tƒ}t|ƒ}t|ƒ}tjd|j|||ƒdS)Nz&%s.PropertiesChanged('%s', '%s', '%s'))rr5r r6r)r!r7Zchanged_propertiesZinvalidated_propertiesr%r%r&ÚPropertiesChanged�s   z%FirewallDConfigZone.PropertiesChanged)r4cs8tjd|jƒtt|ƒj|j|jjƒƒ}t ||t j j ƒS)Nz%s.Introspect()) r Zdebug2rrrÚ IntrospectrrZget_busrrrr )r!r8Údata)r$r%r&rB¦s  zFirewallDConfigZone.Introspectz&(sssbsasa(ss)asba(ssss)asasasasa(ss)b)cCsDtjd|jƒ|jj|jƒ}|dtkr@t|ƒ}d|d<t|ƒ}|S)zget settings for zone z%s.getSettings()ér+) r r6rrZget_zone_configrr ÚlistÚtuple)r!r8ÚsettingsÚ _settingsr%r%r&Ú getSettings´s zFirewallDConfigZone.getSettingscCs4tjd|jƒ|jj|jƒ}|dtkr0d|d<|S)zget settings for zone z%s.getSettings2()Útargetr+)r r6rrÚget_zone_config_dictrr )r!r8rGr%r%r&Ú getSettings2Ãs  z FirewallDConfigZone.getSettings2c Cs|jj|jƒ}d|kr"t|dƒntƒ}d|kr|ddkr>t|d<|j|ƒ|jj |j |ƒ|_ |j |j j ƒdS)z!update settings for zone z%s.update2('...')rJr+N) rr r6rrr?r rRrZset_zone_config_dictrrSr))r!rGr8r%r%r&Úupdate2ùs  zFirewallDConfigZone.update2cCs<tjd|jƒ|jj|ƒ|jj|jƒ|_|j|jj ƒdS)z/load default settings for builtin zone z%s.loadDefaults()N) r r6rrr?rZload_zone_defaultsrrSr))r!r8r%r%r&Ú loadDefaultss z FirewallDConfigZone.loadDefaultscCstjd|j|fƒdS)Nz%s.Updated('%s'))r r6r)r!r)r%r%r&rSszFirewallDConfigZone.UpdatedcCs:tjd|jƒ|jj|ƒ|jj|jƒ|jj|jƒdS)zremove zone z%s.removeZone()N) r r6rrr?rZ remove_zonerZ removeZone)r!r8r%r%r&Úremoves zFirewallDConfigZone.removecCstjd|j|fƒdS)Nz%s.Removed('%s'))r r6r)r!r)r%r%r&ÚRemoved#szFirewallDConfigZone.RemovedcCsFt|tƒ}tjd|j|ƒ|jj|ƒ|jj|j |ƒ|_ |j |ƒdS)zrename zone z%s.rename('%s')N) rr5r r6rrr?rZ rename_zonerÚRenamed)r!r)r8r%r%r&Úrename*s   zFirewallDConfigZone.renamecCstjd|j|fƒdS)Nz%s.Renamed('%s'))r r6r)r!r)r%r%r&rY6szFirewallDConfigZone.RenamedcCstjd|jƒ|jƒdS)Nz%s.getVersion()r)r r6rrI)r!r8r%r%r&Ú getVersion=szFirewallDConfigZone.getVersioncCsHt|tƒ}tjd|j|ƒ|jj|ƒt|jƒƒ}||d<|j |ƒdS)Nz%s.setVersion('%s')r) rr5r r6rrr?rErIrT)r!Úversionr8rGr%r%r&Ú setVersionDs    zFirewallDConfigZone.setVersioncCstjd|jƒ|jƒdS)Nz %s.getShort()r)r r6rrI)r!r8r%r%r&ÚgetShortQszFirewallDConfigZone.getShortcCsHt|tƒ}tjd|j|ƒ|jj|ƒt|jƒƒ}||d<|j |ƒdS)Nz%s.setShort('%s')r) rr5r r6rrr?rErIrT)r!Zshortr8rGr%r%r&ÚsetShortXs    zFirewallDConfigZone.setShortcCstjd|jƒ|jƒdS)Nz%s.getDescription()é)r r6rrI)r!r8r%r%r&ÚgetDescriptionesz"FirewallDConfigZone.getDescriptioncCsHt|tƒ}tjd|j|ƒ|jj|ƒt|jƒƒ}||d<|j |ƒdS)Nz%s.setDescription('%s')r`) rr5r r6rrr?rErIrT)r!Ú descriptionr8rGr%r%r&ÚsetDescriptionls    z"FirewallDConfigZone.setDescriptioncCs.tjd|jƒ|jƒ}|dtkr*|dSdS)Nz%s.getTarget()rDr+)r r6rrIr )r!r8rGr%r%r&Ú getTarget|szFirewallDConfigZone.getTargetcCsTt|tƒ}tjd|j|ƒ|jj|ƒt|jƒƒ}|dkr>|nt |d<|j |ƒdS)Nz%s.setTarget('%s')r+rD) rr5r r6rrr?rErIr rT)r!rJr8rGr%r%r&Ú setTarget„s    zFirewallDConfigZone.setTargetÚascCstjd|jƒ|jƒdS)Nz%s.getServices()é)r r6rrI)r!r8r%r%r&Ú getServices‘szFirewallDConfigZone.getServicescCsNt|tƒ}tjd|jdj|ƒƒ|jj|ƒt|jƒƒ}||d<|j |ƒdS)Nz%s.setServices('[%s]')ú,rg) rrEr r6rÚjoinrr?rIrT)r!Zservicesr8rGr%r%r&Ú setServices˜s     zFirewallDConfigZone.setServicescCsft|tƒ}tjd|j|ƒ|jj|ƒt|jƒƒ}||dkrJt t j |ƒ‚|dj |ƒ|j |ƒdS)Nz%s.addService('%s')rg)rr5r r6rrr?rErIrrÚALREADY_ENABLEDÚappendrT)r!Úservicer8rGr%r%r&Ú addService¤s     zFirewallDConfigZone.addServicecCsft|tƒ}tjd|j|ƒ|jj|ƒt|jƒƒ}||dkrJt t j |ƒ‚|dj |ƒ|j |ƒdS)Nz%s.removeService('%s')rg)rr5r r6rrr?rErIrrÚ NOT_ENABLEDrWrT)r!rnr8rGr%r%r&Ú removeService±s     z!FirewallDConfigZone.removeServiceÚbcCs*t|tƒ}tjd|j|ƒ||jƒdkS)Nz%s.queryService('%s')rg)rr5r r6rrI)r!rnr8r%r%r&Ú queryService¾s z FirewallDConfigZone.queryServiceza(ss)cCstjd|jƒ|jƒdS)Nz %s.getPorts()é)r r6rrI)r!r8r%r%r&ÚgetPortsÈszFirewallDConfigZone.getPortscCsŽg}x6t|tƒD](}t|tƒr.|jt|ƒƒq|j|ƒqW|}tjd|jdjdd„|Dƒƒƒ|j j |ƒt|j ƒƒ}||d<|j |ƒdS)Nz%s.setPorts('[%s]')ricss"|]}d|d|dfVqdS)z ('%s, '%s')rrNr%)Ú.0Úportr%r%r&ú Üsz/FirewallDConfigZone.setPorts..rt) rrErPrmrFr r6rrjrr?rIrT)r!Úportsr8Ú_portsrwrGr%r%r&ÚsetPortsÏs    zFirewallDConfigZone.setPortsc sút|tƒ}tˆtƒ‰tjd|j|ˆƒ|jj|ƒt|jƒƒ}tt ‡fdd„|dƒƒ}x.|D]&}t ||dƒr^t t j d|ˆfƒ‚q^Wt|dd„|Dƒƒ\}}x$|D]} |djt| d ƒˆfƒq¦Wx$|D]} |djt| d ƒˆfƒqÌW|j|ƒdS) Nz%s.addPort('%s', '%s')cs |dˆkS)Nrr%)r=)Úprotocolr%r&Úìsz-FirewallDConfigZone.addPort..rtrz%s:%scSsg|] \}}|‘qSr%r%)rvÚ_portÚ _protocolr%r%r&ú ñsz/FirewallDConfigZone.addPort..ú-)rr5r r6rrr?rErIÚfilterrrrrlrrWrrmrT) r!rwr|r8rGÚexisting_port_idsÚport_idÚ added_rangesÚremoved_rangesÚranger%)r|r&ÚaddPortâs"        zFirewallDConfigZone.addPortc süt|tƒ}tˆtƒ‰tjd|j|ˆƒ|jj|ƒt|jƒƒ}tt ‡fdd„|dƒƒ}x0|D]}t ||dƒr^Pq^Wt t j d|ˆfƒ‚t|dd„|Dƒƒ\}}x$|D]} |djt| d ƒˆfƒq¨Wx$|D]} |djt| d ƒˆfƒqÎW|j|ƒdS) Nz%s.removePort('%s', '%s')cs |dˆkS)Nrr%)r=)r|r%r&r}sz0FirewallDConfigZone.removePort..rtrz%s:%scSsg|] \}}|‘qSr%r%)rvr~rr%r%r&r€sz2FirewallDConfigZone.removePort..r�)rr5r r6rrr?rErIr‚rrrrprrWrrmrT) r!rwr|r8rGrƒr„r…r†r‡r%)r|r&Ú removePortøs"        zFirewallDConfigZone.removePortcCsZt|tƒ}t|tƒ}tjd|j||ƒx.|jƒdD]\}}t||ƒr4||kr4dSq4WdS)Nz%s.queryPort('%s', '%s')rtTF)rr5r r6rrIr)r!rwr|r8r~rr%r%r&Ú queryPorts   zFirewallDConfigZone.queryPortcCstjd|jƒ|jƒdS)Nz%s.getProtocols()é )r r6rrI)r!r8r%r%r&Ú getProtocolssz FirewallDConfigZone.getProtocolscCsNt|tƒ}tjd|jdj|ƒƒ|jj|ƒt|jƒƒ}||d<|j |ƒdS)Nz%s.setProtocols('[%s]')rir‹) rrEr r6rrjrr?rIrT)r!Z protocolsr8rGr%r%r&Ú setProtocols&s     z FirewallDConfigZone.setProtocolscCsft|tƒ}tjd|j|ƒ|jj|ƒt|jƒƒ}||dkrJt t j |ƒ‚|dj |ƒ|j |ƒdS)Nz%s.addProtocol('%s')r‹)rr5r r6rrr?rErIrrrlrmrT)r!r|r8rGr%r%r&Ú addProtocol2s     zFirewallDConfigZone.addProtocolcCsft|tƒ}tjd|j|ƒ|jj|ƒt|jƒƒ}||dkrJt t j |ƒ‚|dj |ƒ|j |ƒdS)Nz%s.removeProtocol('%s')r‹)rr5r r6rrr?rErIrrrprWrT)r!r|r8rGr%r%r&ÚremoveProtocol?s     z"FirewallDConfigZone.removeProtocolcCs*t|tƒ}tjd|j|ƒ||jƒdkS)Nz%s.queryProtocol('%s')r‹)rr5r r6rrI)r!r|r8r%r%r&Ú queryProtocolLs z!FirewallDConfigZone.queryProtocolcCstjd|jƒ|jƒdS)Nz%s.getSourcePorts()é)r r6rrI)r!r8r%r%r&ÚgetSourcePortsVsz"FirewallDConfigZone.getSourcePortscCsŽg}x6t|tƒD](}t|tƒr.|jt|ƒƒq|j|ƒqW|}tjd|jdjdd„|Dƒƒƒ|j j |ƒt|j ƒƒ}||d<|j |ƒdS)Nz%s.setSourcePorts('[%s]')ricss"|]}d|d|dfVqdS)z ('%s, '%s')rrNr%)rvrwr%r%r&rxjsz5FirewallDConfigZone.setSourcePorts..r‘) rrErPrmrFr r6rrjrr?rIrT)r!ryr8rzrwrGr%r%r&ÚsetSourcePorts]s    z"FirewallDConfigZone.setSourcePortsc sút|tƒ}tˆtƒ‰tjd|j|ˆƒ|jj|ƒt|jƒƒ}tt ‡fdd„|dƒƒ}x.|D]&}t ||dƒr^t t j d|ˆfƒ‚q^Wt|dd„|Dƒƒ\}}x$|D]} |djt| d ƒˆfƒq¦Wx$|D]} |djt| d ƒˆfƒqÌW|j|ƒdS) Nz%s.addSourcePort('%s', '%s')cs |dˆkS)Nrr%)r=)r|r%r&r}zsz3FirewallDConfigZone.addSourcePort..r‘rz%s:%scSsg|] \}}|‘qSr%r%)rvr~rr%r%r&r€sz5FirewallDConfigZone.addSourcePort..r�)rr5r r6rrr?rErIr‚rrrrlrrWrrmrT) r!rwr|r8rGrƒr„r…r†r‡r%)r|r&Ú addSourcePortps"        z!FirewallDConfigZone.addSourcePortc süt|tƒ}tˆtƒ‰tjd|j|ˆƒ|jj|ƒt|jƒƒ}tt ‡fdd„|dƒƒ}x0|D]}t ||dƒr^Pq^Wt t j d|ˆfƒ‚t|dd„|Dƒƒ\}}x$|D]} |djt| d ƒˆfƒq¨Wx$|D]} |djt| d ƒˆfƒqÎW|j|ƒdS) Nz%s.removeSourcePort('%s', '%s')cs |dˆkS)Nrr%)r=)r|r%r&r}�sz6FirewallDConfigZone.removeSourcePort..r‘rz%s:%scSsg|] \}}|‘qSr%r%)rvr~rr%r%r&r€–sz8FirewallDConfigZone.removeSourcePort..r�)rr5r r6rrr?rErIr‚rrrrprrWrrmrT) r!rwr|r8rGrƒr„r…r†r‡r%)r|r&ÚremoveSourcePort†s"        z$FirewallDConfigZone.removeSourcePortcCsZt|tƒ}t|tƒ}tjd|j||ƒx.|jƒdD]\}}t||ƒr4||kr4dSq4WdS)Nz%s.querySourcePort('%s', '%s')r‘TF)rr5r r6rrIr)r!rwr|r8r~rr%r%r&ÚquerySourcePort�s   z#FirewallDConfigZone.querySourcePortcCstjd|jƒ|jƒdS)Nz%s.getIcmpBlocks()é)r r6rrI)r!r8r%r%r&Ú getIcmpBlocks­sz!FirewallDConfigZone.getIcmpBlockscCsNt|tƒ}tjd|jdj|ƒƒ|jj|ƒt|jƒƒ}||d<|j |ƒdS)Nz%s.setIcmpBlocks('[%s]')rir—) rrEr r6rrjrr?rIrT)r!Z icmptypesr8rGr%r%r&Ú setIcmpBlocks´s     z!FirewallDConfigZone.setIcmpBlockscCsft|tƒ}tjd|j|ƒ|jj|ƒt|jƒƒ}||dkrJt t j |ƒ‚|dj |ƒ|j |ƒdS)Nz%s.addIcmpBlock('%s')r—)rr5r r6rrr?rErIrrrlrmrT)r!Úicmptyper8rGr%r%r&Ú addIcmpBlockÀs     z FirewallDConfigZone.addIcmpBlockcCsft|tƒ}tjd|j|ƒ|jj|ƒt|jƒƒ}||dkrJt t j |ƒ‚|dj |ƒ|j |ƒdS)Nz%s.removeIcmpBlock('%s')r—)rr5r r6rrr?rErIrrrprWrT)r!ršr8rGr%r%r&ÚremoveIcmpBlockÍs     z#FirewallDConfigZone.removeIcmpBlockcCs*t|tƒ}tjd|j|ƒ||jƒdkS)Nz%s.queryIcmpBlock('%s')r—)rr5r r6rrI)r!ršr8r%r%r&ÚqueryIcmpBlockÚs z"FirewallDConfigZone.queryIcmpBlockcCstjd|jƒ|jƒdS)Nz%s.getIcmpBlockInversion()é)r r6rrI)r!r8r%r%r&ÚgetIcmpBlockInversionäsz)FirewallDConfigZone.getIcmpBlockInversioncCsHt|tƒ}tjd|j|ƒ|jj|ƒt|jƒƒ}||d<|j |ƒdS)Nz%s.setIcmpBlockInversion('%s')rž) rÚboolr r6rrr?rErIrT)r!Úflagr8rGr%r%r&ÚsetIcmpBlockInversionës    z)FirewallDConfigZone.setIcmpBlockInversioncCsPtjd|jƒ|jj|ƒt|jƒƒ}|dr:ttj dƒ‚d|d<|j |ƒdS)Nz%s.addIcmpBlockInversion()ržzicmp-block-inversionT) r r6rrr?rErIrrrlrT)r!r8rGr%r%r&ÚaddIcmpBlockInversionös   z)FirewallDConfigZone.addIcmpBlockInversioncCsPtjd|jƒ|jj|ƒt|jƒƒ}|ds:ttj dƒ‚d|d<|j |ƒdS)Nz%s.removeIcmpBlockInversion()ržzicmp-block-inversionF) r r6rrr?rErIrrrprT)r!r8rGr%r%r&ÚremoveIcmpBlockInversions   z,FirewallDConfigZone.removeIcmpBlockInversioncCstjd|jƒ|jƒdS)Nz%s.queryIcmpBlockInversion()rž)r r6rrI)r!r8r%r%r&ÚqueryIcmpBlockInversion sz+FirewallDConfigZone.queryIcmpBlockInversioncCstjd|jƒ|jƒdS)Nz%s.getMasquerade()é)r r6rrI)r!r8r%r%r&Ú getMasqueradesz!FirewallDConfigZone.getMasqueradecCsHt|tƒ}tjd|j|ƒ|jj|ƒt|jƒƒ}||d<|j |ƒdS)Nz%s.setMasquerade('%s')r¦) rr r r6rrr?rErIrT)r!Ú masquerader8rGr%r%r&Ú setMasquerades    z!FirewallDConfigZone.setMasqueradecCsPtjd|jƒ|jj|ƒt|jƒƒ}|dr:ttj dƒ‚d|d<|j |ƒdS)Nz%s.addMasquerade()r¦r¨T) r r6rrr?rErIrrrlrT)r!r8rGr%r%r&Ú addMasquerade's   z!FirewallDConfigZone.addMasqueradecCsPtjd|jƒ|jj|ƒt|jƒƒ}|ds:ttj dƒ‚d|d<|j |ƒdS)Nz%s.removeMasquerade()r¦r¨F) r r6rrr?rErIrrrprT)r!r8rGr%r%r&ÚremoveMasquerade2s   z$FirewallDConfigZone.removeMasqueradecCstjd|jƒ|jƒdS)Nz%s.queryMasquerade()r¦)r r6rrI)r!r8r%r%r&ÚqueryMasquerade=sz#FirewallDConfigZone.queryMasqueradeza(ssss)cCstjd|jƒ|jƒdS)Nz%s.getForwardPorts()é )r r6rrI)r!r8r%r%r&ÚgetForwardPortsFsz#FirewallDConfigZone.getForwardPortscCsŽg}x6t|tƒD](}t|tƒr.|jt|ƒƒq|j|ƒqW|}tjd|jdjdd„|Dƒƒƒ|j j |ƒt|j ƒƒ}||d<|j |ƒdS)Nz%s.setForwardPorts('[%s]')ricss.|]&}d|d|d|d|dfVqdS)z('%s, '%s', '%s', '%s')rrr`éNr%)rvrwr%r%r&rxZsz6FirewallDConfigZone.setForwardPorts..r­) rrErPrmrFr r6rrjrr?rIrT)r!ryr8rzrwrGr%r%r&ÚsetForwardPortsMs      z#FirewallDConfigZone.setForwardPortsZsssscCsªt|tƒ}t|tƒ}t|tƒ}t|tƒ}tjd|j||||ƒ|jj|ƒ||t|ƒt|ƒf}t|jƒƒ}||dkrŽt t j d||||fƒ‚|dj |ƒ|j |ƒdS)Nz)%s.addForwardPort('%s', '%s', '%s', '%s')r­z %s:%s:%s:%s)rr5r r6rrr?rErIrrrlrmrT)r!rwr|ÚtoportÚtoaddrr8Úfwp_idrGr%r%r&ÚaddForwardPortas        z"FirewallDConfigZone.addForwardPortcCsªt|tƒ}t|tƒ}t|tƒ}t|tƒ}tjd|j||||ƒ|jj|ƒ||t|ƒt|ƒf}t|jƒƒ}||dkrŽt t j d||||fƒ‚|dj |ƒ|j |ƒdS)Nz,%s.removeForwardPort('%s', '%s', '%s', '%s')r­z %s:%s:%s:%s)rr5r r6rrr?rErIrrrprWrT)r!rwr|r±r²r8r³rGr%r%r&ÚremoveForwardPortus        z%FirewallDConfigZone.removeForwardPortcCsbt|tƒ}t|tƒ}t|tƒ}t|tƒ}tjd|j||||ƒ||t|ƒt|ƒf}||jƒdkS)Nz+%s.queryForwardPort('%s', '%s', '%s', '%s')r­)rr5r r6rrI)r!rwr|r±r²r8r³r%r%r&ÚqueryForwardPort‰s    z$FirewallDConfigZone.queryForwardPortcCstjd|jƒ|jƒdS)Nz%s.getInterfaces()é )r r6rrI)r!r8r%r%r&Ú getInterfaces™sz!FirewallDConfigZone.getInterfacescCsNt|tƒ}tjd|jdj|ƒƒ|jj|ƒt|jƒƒ}||d<|j |ƒdS)Nz%s.setInterfaces('[%s]')rir·) rrEr r6rrjrr?rIrT)r!rMr8rGr%r%r&Ú setInterfaces s     z!FirewallDConfigZone.setInterfacescCstt|tƒ}tjd|j|ƒ|jj|ƒt|jƒƒ}||dkrJt t j |ƒ‚|dj |ƒ|j |ƒt|jj|ƒdS)Nz%s.addInterface('%s')r·)rr5r r6rrr?rErIrrrlrmrTrrr))r!Ú interfacer8rGr%r%r&Ú addInterface¬s      z FirewallDConfigZone.addInterfacecCspt|tƒ}tjd|j|ƒ|jj|ƒt|jƒƒ}||dkrJt t j |ƒ‚|dj |ƒ|j |ƒtd|ƒdS)Nz%s.removeInterface('%s')r·Ú)rr5r r6rrr?rErIrrrprWrTr)r!rºr8rGr%r%r&ÚremoveInterface»s      z#FirewallDConfigZone.removeInterfacecCs*t|tƒ}tjd|j|ƒ||jƒdkS)Nz%s.queryInterface('%s')r·)rr5r r6rrI)r!rºr8r%r%r&ÚqueryInterfaceÊs z"FirewallDConfigZone.queryInterfacecCstjd|jƒ|jƒdS)Nz%s.getSources()é )r r6rrI)r!r8r%r%r&Ú getSourcesÕszFirewallDConfigZone.getSourcescCsNt|tƒ}tjd|jdj|ƒƒ|jj|ƒt|jƒƒ}||d<|j |ƒdS)Nz%s.setSources('[%s]')rir¿) rrEr r6rrjrr?rIrT)r!rNr8rGr%r%r&Ú setSourcesÜs     zFirewallDConfigZone.setSourcescCsft|tƒ}tjd|j|ƒ|jj|ƒt|jƒƒ}||dkrJt t j |ƒ‚|dj |ƒ|j |ƒdS)Nz%s.addSource('%s')r¿)rr5r r6rrr?rErIrrrlrmrT)r!rQr8rGr%r%r&Ú addSourceès     zFirewallDConfigZone.addSourcecCsft|tƒ}tjd|j|ƒ|jj|ƒt|jƒƒ}||dkrJt t j |ƒ‚|dj |ƒ|j |ƒdS)Nz%s.removeSource('%s')r¿)rr5r r6rrr?rErIrrrprWrT)r!rQr8rGr%r%r&Ú removeSourceõs     z FirewallDConfigZone.removeSourcecCs*t|tƒ}tjd|j|ƒ||jƒdkS)Nz%s.querySource('%s')r¿)rr5r r6rrI)r!rQr8r%r%r&Ú querySources zFirewallDConfigZone.querySourcecCstjd|jƒ|jƒdS)Nz%s.getRichRules()é )r r6rrI)r!r8r%r%r&Ú getRichRules sz FirewallDConfigZone.getRichRulescCs\t|tƒ}tjd|jdj|ƒƒ|jj|ƒt|jƒƒ}dd„|Dƒ}||d<|j |ƒdS)Nz%s.setRichRules('[%s]')ricSsg|]}tt|d�ƒ‘qS))Úrule_str)r5r )rvÚrr%r%r&r€sz4FirewallDConfigZone.setRichRules..rÅ) rrEr r6rrjrr?rIrT)r!Zrulesr8rGr%r%r&Ú setRichRuless     z FirewallDConfigZone.setRichRulescCstt|tƒ}tjd|j|ƒ|jj|ƒt|jƒƒ}tt |d�ƒ}||dkrXt t j |ƒ‚|dj |ƒ|j|ƒdS)Nz%s.addRichRule('%s'))rÇrÅ)rr5r r6rrr?rErIr rrrlrmrT)r!Úruler8rGrÇr%r%r&Ú addRichRule s     zFirewallDConfigZone.addRichRulecCstt|tƒ}tjd|j|ƒ|jj|ƒt|jƒƒ}tt |d�ƒ}||dkrXt t j |ƒ‚|dj |ƒ|j|ƒdS)Nz%s.removeRichRule('%s'))rÇrÅ)rr5r r6rrr?rErIr rrrprWrT)r!rÊr8rGrÇr%r%r&ÚremoveRichRule.s     z"FirewallDConfigZone.removeRichRulecCs8t|tƒ}tjd|j|ƒtt|d�ƒ}||jƒdkS)Nz%s.queryRichRule('%s'))rÇrÅ)rr5r r6rr rI)r!rÊr8rÇr%r%r&Ú queryRichRule<s z!FirewallDConfigZone.queryRichRule)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)iÚ__name__Ú __module__Ú __qualname__Ú__doc__Z persistentrrZPK_ACTION_CONFIGZdefault_polkit_auth_requiredr rr r'r(r1rZPROPERTIES_IFACEr9r>ÚslipZpolkitZ require_authr@rnÚsignalrAZPK_ACTION_INFOZINTROSPECTABLE_IFACErBr rIrLrRrTrUrVrSrWrXrZrYr[r]r^r_rarcrdrerhrkrorqrsrur{rˆr‰rŠrŒr�rŽr�r�r’r“r”r•r–r˜r™r›rœr�rŸr¢r£r¤r¥r§r©rªr«r¬r®r°r´rµr¶r¸r¹r»r½r¾rÀrÁrÂrÃrÄrÆrÉrËrÌrÍÚ __classcell__r%r%)r$r&r5sf                                           r)(Z gi.repositoryrÚsysÚmodulesrZ dbus.serviceZ slip.dbusrÒZslip.dbus.serviceZfirewallrZfirewall.dbus_utilsrrrZfirewall.core.io.zonerZfirewall.core.fw_ifcfgrZfirewall.core.baser Zfirewall.core.richr Zfirewall.core.loggerr Zfirewall.server.decoratorsr r rrZfirewall.errorsrZfirewall.functionsrrrrrnZObjectrr%r%r%r&Ús$