name : config_zone.cpython-39.pyc
a

���g���@s�ddlZddlZddlmZddlmZmZmZddlm	Z	ddl
mZddlm
Z
ddlmZddlmZdd	lmZdd
lmZmZmZmZddlmZddlmZdd
lmZmZmZm Z Gdd�de�Z!dS)�N)�config)�dbus_to_python�%dbus_introspection_prepare_properties�!dbus_introspection_add_properties)�Zone)�ifcfg_set_zone_of_interface)�DEFAULT_ZONE_TARGET)�	Rich_Rule)�log)�DbusServiceObject)�handle_exceptions�dbus_handle_exceptions�dbus_service_method�dbus_polkit_require_auth)�errors)�
FirewallError)�portStr�portInPortRange�coalescePortRange�breakPortRangecs�	eZdZdZdZejjZe	�fdd��Z
edd��Zedd��Z
ed	d
��Zeejddd
�ed�dd���Zeejddd
�ed�dd���Zeejj�eejdd�ed�dd����Zejjejdd�dd��Zeejj�eejdd�ed��fdd�	���Zeejjd d�ed�d!d"���Zeejjdd�ed�d#d$���Zd%d&�Zeejjd d�ed�d'd(���Zeejjdd�ed�d)d*���Z eejj�ed�d+d,���Z!ejjejjdd�ed-d.���Z"eejj�ed�d/d0���Z#ejjejjdd�ed1d2���Z$eejjdd�ed�d3d4���Z%ejjejjdd�ed5d6���Z&eejjdd�ed�d7d8���Z'eejjdd�ed�d9d:���Z(eejjdd�ed�d;d<���Z)eejjdd�ed�d=d>���Z*eejjdd�ed�d?d@���Z+eejjdd�ed�dAdB���Z,eejjdd�ed�dCdD���Z-eejjdd�ed�dEdF���Z.eejjdGd�ed�dHdI���Z/eejjdGd�ed�dJdK���Z0eejjdd�ed�dLdM���Z1eejjdd�ed�dNdO���Z2eejjddPd
�ed�dQdR���Z3eejjdSd�ed�dTdU���Z4eejjdSd�ed�dVdW���Z5eejjdd�ed�dXdY���Z6eejjdd�ed�dZd[���Z7eejjddPd
�ed�d\d]���Z8eejjdGd�ed�d^d_���Z9eejjdGd�ed�d`da���Z:eejjdd�ed�dbdc���Z;eejjdd�ed�ddde���Z<eejjddPd
�ed�dfdg���Z=eejjdSd�ed�dhdi���Z>eejjdSd�ed�djdk���Z?eejjdd�ed�dldm���Z@eejjdd�ed�dndo���ZAeejjddPd
�ed�dpdq���ZBeejjdGd�ed�drds���ZCeejjdGd�ed�dtdu���ZDeejjdd�ed�dvdw���ZEeejjdd�ed�dxdy���ZFeejjddPd
�ed�dzd{���ZGeejjdPd�ed�d|d}���ZHeejjdPd�ed�d~d���ZIeejj�ed�d�d����ZJeejj�ed�d�d����ZKeejjdPd�ed�d�d����ZLeejjdPd�ed�d�d����ZMeejjdPd�ed�d�d����ZNeejj�ed�d�d����ZOeejj�ed�d�d����ZPeejjdPd�ed�d�d����ZQeejjd�d�ed�d�d����ZReejjd�d�ed�d�d����ZSeejjd�d�ed�d�d����ZTeejjd�d�ed�d�d����ZUeejjd�dPd
�ed�d�d����ZVeejjdGd�ed�d�d����ZWeejjdGd�ed�d�d����ZXeejjdd�ed�d�d����ZYeejjdd�ed�d�d����ZZeejjddPd
�ed�d�d����Z[eejjdGd�ed�d�d����Z\eejjdGd�ed�d�d����Z]eejjdd�ed�d�d����Z^eejjdd�ed�d�d����Z_eejjddPd
�ed�d�d����Z`eejjdGd�ed�d�d����ZaeejjdGd�e�dd�d����Zbeejjdd�e�dd�d����Zceejjdd�e�dd�d����ZdeejjddPd
�e�dd�d����Ze�ZfS(�FirewallDConfigZonezFirewallD main classTcs`tt|�j|i|��||_||_||_||_|d|_|d|_d|j|_	t
|tjj�dS)Nr�zconfig.zone.%d)
�superr�__init__�parentr�obj�item_id�busname�path�_log_prefixr�dbus�DBUS_INTERFACE_CONFIG_ZONE)�selfrZconf�zoner�args�kwargs��	__class__��?/usr/lib/python3.9/site-packages/firewall/server/config_zone.pyr8s

�zFirewallDConfigZone.__init__cCsdS�Nr(�r"r(r(r)�__del__EszFirewallDConfigZone.__del__cCs|��dSr*)Zremove_from_connectionr+r(r(r)�
unregisterIszFirewallDConfigZone.unregistercCs�|dkrt�|jj�S|dkr,t�|jj�S|dkrBt�|jj�S|dkrXt�|jj�S|dkrnt�|jj�Stj	�
d|��dS)N�name�filenamer�default�builtinzDorg.freedesktop.DBus.Error.InvalidArgs: Property '%s' does not exist)r �Stringrr.r/rZBooleanr0r1�
exceptions�
DBusException)r"�
property_namer(r(r)�
_get_propertyQs��z!FirewallDConfigZone._get_property�ss�v)�in_signature�
out_signatureNcCsLt|t�}t|t�}t�d|j||�|tjjkrBtj�	d|��|�
|�S)Nz%s.Get('%s', '%s')�Jorg.freedesktop.DBus.Error.UnknownInterface: Interface '%s' does not exist)r�strr
�debug1rrr r!r3r4r6)r"�interface_namer5�senderr(r(r)�Getbs


���zFirewallDConfigZone.Get�sza{sv}cCs`t|t�}t�d|j|�|tjjkr6tj�	d|��i}dD]}|�
|�||<q>tj|dd�S)Nz%s.GetAll('%s')r;)r.r/rr0r1�sv�Z	signature)rr<r
r=rrr r!r3r4r6Z
Dictionary)r"r>r?�ret�xr(r(r)�GetAllss
��zFirewallDConfigZone.GetAllZssv)r9cCslt|t�}t|t�}t|�}t�d|j|||�|j�|�|tjj	krXtj
�d|��tj
�d|��dS)Nz%s.Set('%s', '%s', '%s')r;zGorg.freedesktop.DBus.Error.PropertyReadOnly: Property '%s' is read-only)rr<r
r=rr�accessCheckrr r!r3r4)r"r>r5Z	new_valuer?r(r(r)�Set�s$


�����zFirewallDConfigZone.Setzsa{sv}asrCcCs2t|t�}t|�}t|�}t�d|j|||�dS)Nz&%s.PropertiesChanged('%s', '%s', '%s'))rr<r
r=r)r"r>Zchanged_propertiesZinvalidated_propertiesr(r(r)�PropertiesChanged�s

�z%FirewallDConfigZone.PropertiesChanged)r:cs8t�d|j�tt|��|j|j���}t	||t
jj�S)Nz%s.Introspect())
r
Zdebug2rrr�
IntrospectrrZget_busrrr r!)r"r?�datar&r(r)rJ�s
�
�zFirewallDConfigZone.Introspectz&(sssbsasa(ss)asba(ssss)asasasasa(ss)b)cCsDt�d|j�|j�|j�}|dtkr@t|�}d|d<t|�}|S)�get settings for zone
        z%s.getSettings()�r0)	r
r=rrZget_zone_configrr�list�tuple)r"r?�settings�	_settingsr(r(r)�getSettings�szFirewallDConfigZone.getSettingscCs4t�d|j�|j�|j�}|dtkr0d|d<|S)rLz%s.getSettings2()�targetr0)r
r=rr�get_zone_config_dictrr�r"r?rPr(r(r)�getSettings2�s
z FirewallDConfigZone.getSettings2cCs|j�|j�}d|vr"t|d�nt�}d|vr<t|d�nt�}t|t�rzt|t�d��|}t|t�d��|}nDd|vr�t|d�nt�}d|vr�t|d�nt�}||}||}|D]}	|j�	|	�r�t
tj|	��q�|D]}
|j�
|
�r�t
tj|
��q�dS)a
Assignment of interfaces/sources to zones is different from other
           zone settings in the sense that particular interface/zone can be
           part of only one zone. So make sure added interfaces/sources have
           not already been bound to another zone.�
interfaces�sourcesN)rrTr�set�
isinstancerOrZindex_ofrZgetZoneOfInterfacerrZ
ZONE_CONFLICTZgetZoneOfSource)r"rPZold_settingsZ
old_ifacesZold_sourcesZadded_ifacesZ
added_sourcesZ
new_ifacesZnew_sourcesZiface�sourcer(r(r)� _checkDuplicateInterfacesSources�s 
z4FirewallDConfigZone._checkDuplicateInterfacesSourcescCstt|�}t�d|j�|j�|�|ddkrFt|�}t|d<t|�}|�	|�|j
�|j|�|_|�
|jj�dS)�!update settings for zone
        z%s.update('...')rMr0N)rr
r=rrrGrNrrOr\rZset_zone_configr�Updatedr.)r"rPr?rQr(r(r)�update�s
zFirewallDConfigZone.updatecCslt|�}t�d|j�|j�|�d|vr>|ddkr>t|d<|�|�|j�	|j
|�|_
|�|j
j�dS)r]z%s.update2('...')rSr0N)
rr
r=rrrGrr\rZset_zone_config_dictrr^r.)r"rPr?r(r(r)�update2�s
zFirewallDConfigZone.update2cCs<t�d|j�|j�|�|j�|j�|_|�|jj	�dS)z/load default settings for builtin zone
        z%s.loadDefaults()N)
r
r=rrrGrZload_zone_defaultsrr^r.�r"r?r(r(r)�loadDefaultssz FirewallDConfigZone.loadDefaultscCst�d|j|f�dS)Nz%s.Updated('%s')�r
r=r�r"r.r(r(r)r^
szFirewallDConfigZone.UpdatedcCs:t�d|j�|j�|�|j�|j�|j�|j�dS)zremove zone
        z%s.removeZone()N)	r
r=rrrGrZremove_zonerZ
removeZonerar(r(r)�removeszFirewallDConfigZone.removecCst�d|j|f�dS)Nz%s.Removed('%s')rcrdr(r(r)�RemovedszFirewallDConfigZone.RemovedcCsFt|t�}t�d|j|�|j�|�|j�|j	|�|_	|�
|�dS)zrename zone
        z%s.rename('%s')N)rr<r
r=rrrGrZrename_zoner�Renamed)r"r.r?r(r(r)�rename%s

zFirewallDConfigZone.renamecCst�d|j|f�dS)Nz%s.Renamed('%s')rcrdr(r(r)rg1szFirewallDConfigZone.RenamedcCst�d|j�|��dS)Nz%s.getVersion()r�r
r=rrRrar(r(r)�
getVersion8szFirewallDConfigZone.getVersioncCsHt|t�}t�d|j|�|j�|�t|���}||d<|�	|�dS)Nz%s.setVersion('%s')r�
rr<r
r=rrrGrNrRr_)r"�versionr?rPr(r(r)�
setVersion?s
zFirewallDConfigZone.setVersioncCst�d|j�|��dS)Nz
%s.getShort()rrirar(r(r)�getShortLszFirewallDConfigZone.getShortcCsHt|t�}t�d|j|�|j�|�t|���}||d<|�	|�dS)Nz%s.setShort('%s')rrk)r"Zshortr?rPr(r(r)�setShortSs
zFirewallDConfigZone.setShortcCst�d|j�|��dS)Nz%s.getDescription()�rirar(r(r)�getDescription`sz"FirewallDConfigZone.getDescriptioncCsHt|t�}t�d|j|�|j�|�t|���}||d<|�	|�dS)Nz%s.setDescription('%s')rprk)r"�descriptionr?rPr(r(r)�setDescriptiongs
z"FirewallDConfigZone.setDescriptioncCs.t�d|j�|��}|dtkr*|dSdS)Nz%s.getTarget()rMr0)r
r=rrRrrUr(r(r)�	getTargetwszFirewallDConfigZone.getTargetcCsTt|t�}t�d|j|�|j�|�t|���}|dkr>|nt	|d<|�
|�dS)Nz%s.setTarget('%s')r0rM)rr<r
r=rrrGrNrRrr_)r"rSr?rPr(r(r)�	setTargets
zFirewallDConfigZone.setTarget�ascCst�d|j�|��dS)Nz%s.getServices()�rirar(r(r)�getServices�szFirewallDConfigZone.getServicescCsNt|t�}t�d|jd�|��|j�|�t|���}||d<|�	|�dS)Nz%s.setServices('[%s]')�,rw�
rrNr
r=r�joinrrGrRr_)r"Zservicesr?rPr(r(r)�setServices�s

�zFirewallDConfigZone.setServicescCsft|t�}t�d|j|�|j�|�t|���}||dvrJt	t
j|��|d�|�|�
|�dS)Nz%s.addService('%s')rw�rr<r
r=rrrGrNrRrr�ALREADY_ENABLED�appendr_�r"�servicer?rPr(r(r)�
addService�s
zFirewallDConfigZone.addServicecCsft|t�}t�d|j|�|j�|�t|���}||dvrJt	t
j|��|d�|�|�
|�dS)Nz%s.removeService('%s')rw�rr<r
r=rrrGrNrRrr�NOT_ENABLEDrer_r�r(r(r)�
removeService�s
z!FirewallDConfigZone.removeService�bcCs*t|t�}t�d|j|�||��dvS)Nz%s.queryService('%s')rw�rr<r
r=rrR)r"r�r?r(r(r)�queryService�s
z FirewallDConfigZone.queryServiceza(ss)cCst�d|j�|��dS)Nz
%s.getPorts()�rirar(r(r)�getPorts�szFirewallDConfigZone.getPortscCs�g}t|t�D](}t|t�r,|�t|��q|�|�q|}t�d|jd�dd�|D���|j	�
|�t|���}||d<|�|�dS)Nz%s.setPorts('[%s]')rycss"|]}d|d|dfVqdS�z('%s, '%s')rrNr(��.0�portr(r(r)�	<genexpr>��z/FirewallDConfigZone.setPorts.<locals>.<genexpr>r��
rrNrZrrOr
r=rr{rrGrRr_�r"Zportsr?Z_portsr�rPr(r(r)�setPorts�s

�zFirewallDConfigZone.setPortsc
s�t|t�}t�t��t�d|j|��|j�|�t|���}tt	�fdd�|d��}|D]&}t
||d�r\ttj
d|�f��q\t|dd�|D��\}}|D]}	|d�t|	d	��f�q�|D]}	|d�t|	d	��f�q�|�|�dS)
Nz%s.addPort('%s', '%s')cs|d�kS�Nrr(�rE��protocolr(r)�<lambda>�r�z-FirewallDConfigZone.addPort.<locals>.<lambda>r�r�%s:%scSsg|]\}}|�qSr(r(�r��_port�	_protocolr(r(r)�
<listcomp>�r�z/FirewallDConfigZone.addPort.<locals>.<listcomp>�-�rr<r
r=rrrGrNrR�filterrrrr~rrerrr_�
r"r�r�r?rPZexisting_port_idsZport_idZadded_rangesZremoved_ranges�ranger(r�r)�addPort�s&

�
�zFirewallDConfigZone.addPortc
s�t|t�}t�t��t�d|j|��|j�|�t|���}tt	�fdd�|d��}|D]}t
||d�r\q�q\ttj
d|�f��t|dd�|D��\}}|D]}	|d�t|	d	��f�q�|D]}	|d�t|	d	��f�q�|�|�dS)
Nz%s.removePort('%s', '%s')cs|d�kSr�r(r�r�r(r)r��r�z0FirewallDConfigZone.removePort.<locals>.<lambda>r�rr�cSsg|]\}}|�qSr(r(r�r(r(r)r�r�z2FirewallDConfigZone.removePort.<locals>.<listcomp>r��rr<r
r=rrrGrNrRr�rrrr�rrerrr_r�r(r�r)�
removePort�s$

�zFirewallDConfigZone.removePortcCsXt|t�}t|t�}t�d|j||�|��dD] \}}t||�r2||kr2dSq2dS)Nz%s.queryPort('%s', '%s')r�TF�rr<r
r=rrRr�r"r�r�r?r�r�r(r(r)�	queryPort
s

�zFirewallDConfigZone.queryPortcCst�d|j�|��dS)Nz%s.getProtocols()�
rirar(r(r)�getProtocolssz FirewallDConfigZone.getProtocolscCsNt|t�}t�d|jd�|��|j�|�t|���}||d<|�	|�dS)Nz%s.setProtocols('[%s]')ryr�rz)r"Z	protocolsr?rPr(r(r)�setProtocols!s

�z FirewallDConfigZone.setProtocolscCsft|t�}t�d|j|�|j�|�t|���}||dvrJt	t
j|��|d�|�|�
|�dS)Nz%s.addProtocol('%s')r�r}�r"r�r?rPr(r(r)�addProtocol-s
zFirewallDConfigZone.addProtocolcCsft|t�}t�d|j|�|j�|�t|���}||dvrJt	t
j|��|d�|�|�
|�dS)Nz%s.removeProtocol('%s')r�r�r�r(r(r)�removeProtocol:s
z"FirewallDConfigZone.removeProtocolcCs*t|t�}t�d|j|�||��dvS)Nz%s.queryProtocol('%s')r�r�)r"r�r?r(r(r)�
queryProtocolGs
z!FirewallDConfigZone.queryProtocolcCst�d|j�|��dS)Nz%s.getSourcePorts()�rirar(r(r)�getSourcePortsQsz"FirewallDConfigZone.getSourcePortscCs�g}t|t�D](}t|t�r,|�t|��q|�|�q|}t�d|jd�dd�|D���|j	�
|�t|���}||d<|�|�dS)Nz%s.setSourcePorts('[%s]')rycss"|]}d|d|dfVqdSr�r(r�r(r(r)r�er�z5FirewallDConfigZone.setSourcePorts.<locals>.<genexpr>r�r�r�r(r(r)�setSourcePortsXs

�z"FirewallDConfigZone.setSourcePortsc
s�t|t�}t�t��t�d|j|��|j�|�t|���}tt	�fdd�|d��}|D]&}t
||d�r\ttj
d|�f��q\t|dd�|D��\}}|D]}	|d�t|	d	��f�q�|D]}	|d�t|	d	��f�q�|�|�dS)
Nz%s.addSourcePort('%s', '%s')cs|d�kSr�r(r�r�r(r)r�ur�z3FirewallDConfigZone.addSourcePort.<locals>.<lambda>r�rr�cSsg|]\}}|�qSr(r(r�r(r(r)r�zr�z5FirewallDConfigZone.addSourcePort.<locals>.<listcomp>r�r�r�r(r�r)�
addSourcePortks&

�
�z!FirewallDConfigZone.addSourcePortc
s�t|t�}t�t��t�d|j|��|j�|�t|���}tt	�fdd�|d��}|D]}t
||d�r\q�q\ttj
d|�f��t|dd�|D��\}}|D]}	|d�t|	d	��f�q�|D]}	|d�t|	d	��f�q�|�|�dS)
Nz%s.removeSourcePort('%s', '%s')cs|d�kSr�r(r�r�r(r)r��r�z6FirewallDConfigZone.removeSourcePort.<locals>.<lambda>r�rr�cSsg|]\}}|�qSr(r(r�r(r(r)r��r�z8FirewallDConfigZone.removeSourcePort.<locals>.<listcomp>r�r�r�r(r�r)�removeSourcePort�s$

�z$FirewallDConfigZone.removeSourcePortcCsXt|t�}t|t�}t�d|j||�|��dD] \}}t||�r2||kr2dSq2dS)Nz%s.querySourcePort('%s', '%s')r�TFr�r�r(r(r)�querySourcePort�s

�z#FirewallDConfigZone.querySourcePortcCst�d|j�|��dS)Nz%s.getIcmpBlocks()�rirar(r(r)�
getIcmpBlocks�sz!FirewallDConfigZone.getIcmpBlockscCsNt|t�}t�d|jd�|��|j�|�t|���}||d<|�	|�dS)Nz%s.setIcmpBlocks('[%s]')ryr�rz)r"Z	icmptypesr?rPr(r(r)�
setIcmpBlocks�s

�z!FirewallDConfigZone.setIcmpBlockscCsft|t�}t�d|j|�|j�|�t|���}||dvrJt	t
j|��|d�|�|�
|�dS)Nz%s.addIcmpBlock('%s')r�r}�r"�icmptyper?rPr(r(r)�addIcmpBlock�s
z FirewallDConfigZone.addIcmpBlockcCsft|t�}t�d|j|�|j�|�t|���}||dvrJt	t
j|��|d�|�|�
|�dS)Nz%s.removeIcmpBlock('%s')r�r�r�r(r(r)�removeIcmpBlock�s
z#FirewallDConfigZone.removeIcmpBlockcCs*t|t�}t�d|j|�||��dvS)Nz%s.queryIcmpBlock('%s')r�r�)r"r�r?r(r(r)�queryIcmpBlock�s
z"FirewallDConfigZone.queryIcmpBlockcCst�d|j�|��dS)Nz%s.getIcmpBlockInversion()�rirar(r(r)�getIcmpBlockInversion�sz)FirewallDConfigZone.getIcmpBlockInversioncCsHt|t�}t�d|j|�|j�|�t|���}||d<|�	|�dS)Nz%s.setIcmpBlockInversion('%s')r��
r�boolr
r=rrrGrNrRr_)r"�flagr?rPr(r(r)�setIcmpBlockInversion�s
z)FirewallDConfigZone.setIcmpBlockInversioncCsPt�d|j�|j�|�t|���}|dr:ttj	d��d|d<|�
|�dS)Nz%s.addIcmpBlockInversion()r��icmp-block-inversionT�r
r=rrrGrNrRrrr~r_rUr(r(r)�addIcmpBlockInversion�sz)FirewallDConfigZone.addIcmpBlockInversioncCsPt�d|j�|j�|�t|���}|ds:ttj	d��d|d<|�
|�dS)Nz%s.removeIcmpBlockInversion()r�r�F�r
r=rrrGrNrRrrr�r_rUr(r(r)�removeIcmpBlockInversion�sz,FirewallDConfigZone.removeIcmpBlockInversioncCst�d|j�|��dS)Nz%s.queryIcmpBlockInversion()r�rirar(r(r)�queryIcmpBlockInversionsz+FirewallDConfigZone.queryIcmpBlockInversioncCst�d|j�|��dS)Nz%s.getMasquerade()�rirar(r(r)�
getMasqueradesz!FirewallDConfigZone.getMasqueradecCsHt|t�}t�d|j|�|j�|�t|���}||d<|�	|�dS)Nz%s.setMasquerade('%s')r�r�)r"�
masquerader?rPr(r(r)�
setMasquerades
z!FirewallDConfigZone.setMasqueradecCsPt�d|j�|j�|�t|���}|dr:ttj	d��d|d<|�
|�dS)Nz%s.addMasquerade()r�r�Tr�rUr(r(r)�
addMasquerade"sz!FirewallDConfigZone.addMasqueradecCsPt�d|j�|j�|�t|���}|ds:ttj	d��d|d<|�
|�dS)Nz%s.removeMasquerade()r�r�Fr�rUr(r(r)�removeMasquerade-sz$FirewallDConfigZone.removeMasqueradecCst�d|j�|��dS)Nz%s.queryMasquerade()r�rirar(r(r)�queryMasquerade8sz#FirewallDConfigZone.queryMasqueradeza(ssss)cCst�d|j�|��dS)Nz%s.getForwardPorts()�	rirar(r(r)�getForwardPortsAsz#FirewallDConfigZone.getForwardPortscCs�g}t|t�D](}t|t�r,|�t|��q|�|�q|}t�d|jd�dd�|D���|j	�
|�t|���}||d<|�|�dS)Nz%s.setForwardPorts('[%s]')rycss.|]&}d|d|d|d|dfVqdS)z('%s, '%s', '%s', '%s')rrrp�Nr(r�r(r(r)r�Us��z6FirewallDConfigZone.setForwardPorts.<locals>.<genexpr>r�r�r�r(r(r)�setForwardPortsHs


��z#FirewallDConfigZone.setForwardPortsZsssscCs�t|t�}t|t�}t|t�}t|t�}t�d|j||||�|j�|�||t|�t|�f}t|���}||dvr�t	t
jd||||f��|d�|�|�
|�dS)Nz)%s.addForwardPort('%s', '%s', '%s', '%s')r��%s:%s:%s:%sr}�r"r�r��toport�toaddrr?�fwp_idrPr(r(r)�addForwardPort\s$



���z"FirewallDConfigZone.addForwardPortcCs�t|t�}t|t�}t|t�}t|t�}t�d|j||||�|j�|�||t|�t|�f}t|���}||dvr�t	t
jd||||f��|d�|�|�
|�dS)Nz,%s.removeForwardPort('%s', '%s', '%s', '%s')r�r�r�r�r(r(r)�removeForwardPortps$



���z%FirewallDConfigZone.removeForwardPortcCsbt|t�}t|t�}t|t�}t|t�}t�d|j||||�||t|�t|�f}||��dvS)Nz+%s.queryForwardPort('%s', '%s', '%s', '%s')r�r�)r"r�r�r�r�r?r�r(r(r)�queryForwardPort�s



�z$FirewallDConfigZone.queryForwardPortcCst�d|j�|��dS)Nz%s.getInterfaces()�
rirar(r(r)�
getInterfaces�sz!FirewallDConfigZone.getInterfacescCsNt|t�}t�d|jd�|��|j�|�t|���}||d<|�	|�dS)Nz%s.setInterfaces('[%s]')ryr�rz)r"rWr?rPr(r(r)�
setInterfaces�s

�z!FirewallDConfigZone.setInterfacescCstt|t�}t�d|j|�|j�|�t|���}||dvrJt	t
j|��|d�|�|�
|�t|jj|�dS)Nz%s.addInterface('%s')r�)rr<r
r=rrrGrNrRrrr~rr_rrr.�r"�	interfacer?rPr(r(r)�addInterface�s

z FirewallDConfigZone.addInterfacecCspt|t�}t�d|j|�|j�|�t|���}||dvrJt	t
j|��|d�|�|�
|�td|�dS)Nz%s.removeInterface('%s')r��)rr<r
r=rrrGrNrRrrr�rer_rr�r(r(r)�removeInterface�s

z#FirewallDConfigZone.removeInterfacecCs*t|t�}t�d|j|�||��dvS)Nz%s.queryInterface('%s')r�r�)r"r�r?r(r(r)�queryInterface�s
z"FirewallDConfigZone.queryInterfacecCst�d|j�|��dS)Nz%s.getSources()�rirar(r(r)�
getSources�szFirewallDConfigZone.getSourcescCsNt|t�}t�d|jd�|��|j�|�t|���}||d<|�	|�dS)Nz%s.setSources('[%s]')ryr�rz)r"rXr?rPr(r(r)�
setSources�s

�zFirewallDConfigZone.setSourcescCsft|t�}t�d|j|�|j�|�t|���}||dvrJt	t
j|��|d�|�|�
|�dS)Nz%s.addSource('%s')r�r}�r"r[r?rPr(r(r)�	addSource�s
zFirewallDConfigZone.addSourcecCsft|t�}t�d|j|�|j�|�t|���}||dvrJt	t
j|��|d�|�|�
|�dS)Nz%s.removeSource('%s')r�r�r�r(r(r)�removeSource�s
z FirewallDConfigZone.removeSourcecCs*t|t�}t�d|j|�||��dvS)Nz%s.querySource('%s')r�r�)r"r[r?r(r(r)�querySource�s
zFirewallDConfigZone.querySourcecCst�d|j�|��dS)Nz%s.getRichRules()�rirar(r(r)�getRichRulessz FirewallDConfigZone.getRichRulescCs\t|t�}t�d|jd�|��|j�|�t|���}dd�|D�}||d<|�	|�dS)Nz%s.setRichRules('[%s]')rycSsg|]}tt|d���qS)��rule_str)r<r	)r��rr(r(r)r�r�z4FirewallDConfigZone.setRichRules.<locals>.<listcomp>r�rz)r"Zrulesr?rPr(r(r)�setRichRuless

�z FirewallDConfigZone.setRichRulescCstt|t�}t�d|j|�|j�|�t|���}tt	|d��}||dvrXt
tj|��|d�
|�|�|�dS)Nz%s.addRichRule('%s')r�r�)rr<r
r=rrrGrNrRr	rrr~rr_�r"�ruler?rPr�r(r(r)�addRichRules
zFirewallDConfigZone.addRichRulecCstt|t�}t�d|j|�|j�|�t|���}tt	|d��}||dvrXt
tj|��|d�
|�|�|�dS)Nz%s.removeRichRule('%s')r�r�)rr<r
r=rrrGrNrRr	rrr�rer_r�r(r(r)�removeRichRule)s
z"FirewallDConfigZone.removeRichRulecCs8t|t�}t�d|j|�tt|d��}||��dvS)Nz%s.queryRichRule('%s')r�r�)rr<r
r=rr	rR)r"r�r?r�r(r(r)�
queryRichRule7s
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)g�__name__�
__module__�__qualname__�__doc__Z
persistentrr ZPK_ACTION_CONFIGZdefault_polkit_auth_requiredrrr
r,r-r6rZPROPERTIES_IFACEr@rFrrHr��signalrIZPK_ACTION_INFOZINTROSPECTABLE_IFACErJr!rRrVr\r_r`rbr^rerfrhrgrjrmrnrorqrsrtrurxr|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�r�r�r�r�r��
__classcell__r(r(r&r)r0s�


��


��	��

�	��
��
��
��
��	�
�
������
��	�
�
������
��	�
�
���
	
	���
	
	��������	�����	�
�
���
���r)"r Zdbus.serviceZfirewallrZfirewall.dbus_utilsrrrZfirewall.core.io.zonerZfirewall.core.fw_ifcfgrZfirewall.core.baserZfirewall.core.richr	Zfirewall.core.loggerr
Zfirewall.server.dbusrZfirewall.server.decoratorsrr
rrrZfirewall.errorsrZfirewall.functionsrrrrrr(r(r(r)�<module>s	

© 2025 Cubjrnet7