%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/states/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/states/firewalld.pyc

�
���^c@@s"dZddlmZmZmZddlZddlmZddlm	Z	ddl
ZddlZej
e�Zdefd��YZd�Zd	�Zdededededddededed
�Zddd�Zdededededddededed�ZdS(
u
Management of firewalld

.. versionadded:: 2015.8.0

The following example applies changes to the public zone, blocks echo-reply
and echo-request packets, does not set the zone to be the default, enables
masquerading, and allows ports 22/tcp and 25/tcp.
It will be applied permanently and directly before restart/reload.

.. code-block:: yaml

    public:
      firewalld.present:
        - name: public
        - block_icmp:
          - echo-reply
          - echo-request
        - default: False
        - masquerade: True
        - ports:
          - 22/tcp
          - 25/tcp

The following example applies changes to the public zone, enables
masquerading and configures port forwarding TCP traffic from port 22
to 2222, and forwards TCP traffic from port 80 to 443 at 192.168.0.1.

.. code-block:: yaml

  my_zone:
    firewalld.present:
      - name: public
      - masquerade: True
      - port_fwd:
        - 22:2222:tcp
        - 80:443:tcp:192.168.0.1

The following example binds the public zone to interface eth0 and to all
packets coming from the 192.168.1.0/24 subnet. It also removes the zone
from all other interfaces or sources.

.. code-block:: yaml

  public:
    firewalld.present:
      - name: public
      - interfaces:
        - eth0
      - sources:
        - 192.168.1.0/24

Here, we define a new service that encompasses TCP ports 4505 4506:

.. code-block:: yaml

  saltmaster:
    firewalld.service:
      - name: saltmaster
      - ports:
        - 4505/tcp
        - 4506/tcp

To make this new service available in a zone, the following can be used, which
would allow access to the salt master from the 10.0.0.0/8 subnet:

.. code-block:: yaml

  saltzone:
    firewalld.present:
      - name: saltzone
      - services:
        - saltmaster
      - sources:
        - 10.0.0.0/8
i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionError(tnestedtForwardingMappingcB@s;eZdZd�Zd�Zd�Zd�Zd�ZRS(u
    Represents a port forwarding statement mapping a local port to a remote
    port for a specific protocol (TCP or UDP)
    cC@s(||_||_||_||_dS(N(tsrcporttdestporttprotocoltdestaddr(tselfRRRR	((s9/usr/lib/python2.7/site-packages/salt/states/firewalld.pyt__init__as			cC@sF|j|jkoE|j|jkoE|j|jkoE|j|jkS(N(RRRR	(R
tother((s9/usr/lib/python2.7/site-packages/salt/states/firewalld.pyt__eq__gscC@s|j|�S(N(R
(R
R((s9/usr/lib/python2.7/site-packages/salt/states/firewalld.pyt__ne__mscC@s4t|j�t|j�At|j�At|j�AS(N(thashRRRR	(R
((s9/usr/lib/python2.7/site-packages/salt/states/firewalld.pyt__hash__qs&cC@s,i|jd6|jd6|jd6|jd6S(uL
        Returns a pretty dictionary meant for command line output.
        uSource portuDestination portuProtocoluDestination address(RRRR	(R
((s9/usr/lib/python2.7/site-packages/salt/states/firewalld.pyttodictws



(t__name__t
__module__t__doc__RR
RRR(((s9/usr/lib/python2.7/site-packages/salt/states/firewalld.pyR\s				cC@sjt|jd��dkr9|jd�\}}}}n|jd�\}}}d}t||||�S(u�
    Parses a port forwarding statement in the form used by this state:

    from_port:to_port:protocol[:destination]

    and returns a ForwardingMapping object
    u:iu(tlentsplitR(tmappingRRRR	((s9/usr/lib/python2.7/site-packages/salt/states/firewalld.pyt_parse_forward�s
cC@s#tjjjd�rtStdfS(u.
    Ensure the firewall-cmd is available
    ufirewall-cmduCfirewall-cmd is not available, firewalld is probably not installed.(tsalttutilstpathtwhichtTruetFalse(((s9/usr/lib/python2.7/site-packages/salt/states/firewalld.pyt__virtual__�scC@s�|
dkr+t}
tjjjdd�nt||||||||||	|
|||
|||�}|dikr�td�n|S(u
    Ensure a zone has specific attributes.

    name
        The zone to modify.

    default : None
        Set this zone as the default zone if ``True``.

    masquerade : False
        Enable or disable masquerade for a zone.

    block_icmp : None
        List of ICMP types to block in the zone.

    prune_block_icmp : False
        If ``True``, remove all but the specified block_icmp from the zone.

    ports : None
        List of ports to add to the zone.

    prune_ports : False
        If ``True``, remove all but the specified ports from the zone.

    port_fwd : None
        List of port forwards to add to the zone.

    prune_port_fwd : False
        If ``True``, remove all but the specified port_fwd from the zone.

    services : None
        List of services to add to the zone.

    prune_services : True
        If ``True``, remove all but the specified services from the zone.
        .. note:: Currently defaults to True for compatibility, but will be changed to False in a future release.

    interfaces : None
        List of interfaces to add to the zone.

    prune_interfaces : False
        If ``True``, remove all but the specified interfaces from the zone.

    sources : None
        List of sources to add to the zone.

    prune_sources : False
        If ``True``, remove all but the specified sources from the zone.

    rich_rules : None
        List of rich rules to add to the zone.

    prune_rich_rules : False
        If ``True``, remove all but the specified rich rules from the zone.
    uNeonujThe 'prune_services' argument default is currently True, but will be changed to False in the Neon release.uchangesufirewalld.reload_rulesN(tNoneRRRtversionst
warn_untilt_presentt__salt__(tnamet
block_icmptprune_block_icmptdefaultt
masqueradetportstprune_portstport_fwdtprune_port_fwdtservicestprune_servicest
interfacestprune_interfacestsourcest
prune_sourcest
rich_rulestprune_rich_rulestret((s9/usr/lib/python2.7/site-packages/salt/states/firewalld.pytpresent�sM
c
	C@s�i|d6td6id6dd6}|td�krLtd|dt�n|pUg}ytd	|�}Wn'tk
r�}d
j|�|d<|SXt|�t|�}t|�t|�}xZ|D]R}tds�ytd||�Wqtk
r}d
j|�|d<|SXq�q�WxZ|D]R}tds&ytd
||�Wqxtk
rt}d
j|�|d<|SXq&q&W|s�|r�|djii|d6|d6d6�n|p�g}ytd|�}	Wn'tk
r�}d
j|�|d<|SXt|�t|	�}
t|	�t|�}xZ|
D]R}tds.ytd||�Wq�tk
r|}d
j|�|d<|SXq.q.WxZ|D]R}tds�ytd||�Wq�tk
r�}d
j|�|d<|SXq�q�W|
s�|r|djii|	d6|d6d6�n|dikr4td�nt|d<|dikredj|�|d<|Stdr�d|d<dj|�|d<|Sdj|�|d<|S(u{
    Ensure the service exists and encompasses the specified ports and
    protocols.

    .. versionadded:: 2016.11.0
    unameuresultuchangesuucommentufirewalld.get_servicesufirewalld.new_servicetrestartufirewalld.get_service_portsu
Error: {0}utestufirewalld.add_service_portufirewalld.remove_service_portuoldunewuportsufirewalld.get_service_protocolsufirewalld.add_service_protocolu!firewalld.remove_service_protocolu	protocolsufirewalld.reload_rulesu&'{0}' is already in the desired state.u$Configuration for '{0}' will change.u'{0}' was configured.N(	RR$Rtformattsett__opts__tupdateRR (
R%R*t	protocolsR6t_current_portsterrt	new_portst	old_portstportt_current_protocolst
new_protocolst
old_protocolsR((s9/usr/lib/python2.7/site-packages/salt/states/firewalld.pytservice�s�	

















c5C@si|d6td6id6dd6}ytddt�}Wn'tk
rb}dj|�|d<|SX||kr�td	s�ytd
|�Wq�tk
r�}dj|�|d<|SXn|djii|d6|d6|6�n|s�|r#|p�g}g}g}ytd
|dt�}Wn'tk
rH}dj|�|d<|SX|rJytddt�}Wn'tk
r�}dj|�|d<|SXx;t|�t|�D]#}tj	d|�|j
|�q�Wt|�t|�}xc|D]X}td	s�ytd||dt�WqCtk
r?}dj|�|d<|SXq�q�Wn|r�t|�t|�}xc|D]X}td	smytd||dt�Wq�tk
r�}dj|�|d<|SXqmqmWn|s�|r#|s�t|t|�B�}n|djii|d6|d6d6�q#n|r�ytd�}Wn'tk
rc}dj|�|d<|SX||kr�td	s�ytd|�Wq�tk
r�}dj|�|d<|SXn|djii|d6|d6d6�q�nytd|dt�}Wn'tk
r(}dj|�|d<|SX|r�|r�td	s�ytd|dt�Wq�tk
r�}dj|�|d<|SXn|djiidd6dd6d6�n�|r3|r3td	s
ytd|dt�Wq
tk
r}dj|�|d<|SXn|djiidd6dd6d6�n|s?|r�|pHg}ytd|dt�}Wn'tk
r�}dj|�|d<|SXt|�t|�}g}xf|D]^}td	s�y!td||dtdt�Wqtk
r}dj|�|d<|SXq�q�W|r�t|�t|�}xc|D]X}td	s7ytd||dt�Wq�tk
r�}dj|�|d<|SXq7q7Wn|s�|r�|s�t|t|�B�}n|djii|d6|d6d 6�q�n|s�|rf	|pg}ytd!|dt�}Wn'tk
rH}dj|�|d<|SXg|D]} t| �^qP}g|D]7} t
d"| d#d$| d%d&| d'd(| d)�^qo}t|�t|�}!g}"x{|!D]s} td	s�y6td*|| j| j| j| jdtdt�WqBtk
r>}dj|�|d<|SXq�q�W|r�t|�t|�}"xx|"D]m} td	siy0td+|| j| j| j| jdt�Wq�tk
r�}dj|�|d<|SXqiqiWn|!s�|"rf	|s	t|!t|�B�}n|djiig|D]} | j�^q	d6g|D]} | j�^q?	d6d,6�qf	n|	sr	|
r|	p{	g}	ytd-|dt�}#Wn'tk
r�	}dj|�|d<|SXt|	�t|#�}$g}%x`|$D]X}&td	s�	ytd.|&|dt�Wq=
tk
r9
}dj|�|d<|SXq�	q�	W|
r�
t|#�t|	�}%xc|%D]X}'td	sd
ytd/|'|dt�Wq�
tk
r�
}dj|�|d<|SXqd
qd
Wn|$s�
|%r|
s�
t|$t|#�B�}	n|djii|#d6|	d6d06�qn|s&|r�|p/g}ytd1|dt�}(Wn'tk
ru}dj|�|d<|SXt|�t|(�})g}*x`|)D]X}+td	s�ytd2||+dt�Wq�tk
r�}dj|�|d<|SXq�q�W|rwt|(�t|�}*xc|*D]X}+td	sytd3||+dt�Wqptk
rl}dj|�|d<|SXqqWn|)s�|*r�|s�t|)t|(�B�}n|djii|(d6|d6d46�q�n|
s�|r�|
p�g}
ytd5|dt�},Wn'tk
r)
}dj|�|d<|SXt|
�t|,�}-g}.x`|-D]X}/td	sM
ytd6||/dt�Wq�
tk
r�
}dj|�|d<|SXqM
qM
W|r+t|,�t|
�}.xc|.D]X}/td	s�
ytd7||/dt�Wq$tk
r }dj|�|d<|SXq�
q�
Wn|-s7|.r�|sVt|-t|,�B�}
n|djii|,d6|
d6d86�q�n|s�|r6|p�g}ytd9|dt�}0Wn'tk
r�}dj|�|d<|SXt|�t|0�}1g}2x`|1D]X}3td	sytd:||3dt�WqYtk
rU}dj|�|d<|SXqqW|r�t|0�t|�}2xc|2D]X}3td	s�ytd;||3dt�Wq�tk
r�}dj|�|d<|SXq�q�Wn|1s�|2r6|s
t|1t|0�B�}n|djii|0d6|d6d<6�q6n|dikrgt|d<d=j|�|d<|Std	r�dA|d<tt_g}4|4jd>j|��|4jtj|d�j��d?j|4�|d<i|d<|St|d<d@j|�|d<|S(Bu0
    Ensure a zone has specific attributes.
    unameuresultuchangesuucommentufirewalld.get_zonest	permanentu
Error: {0}utestufirewalld.new_zoneuoldunewufirewalld.list_icmp_blockufirewalld.get_icmp_typesu%s is an invalid ICMP typeufirewalld.block_icmpufirewalld.allow_icmpu
icmp_typesufirewalld.default_zoneufirewalld.set_default_zoneudefaultufirewalld.get_masqueradeufirewalld.add_masqueradeuMasquerading successfully set.u
masqueradeufirewalld.remove_masqueradeu#Masquerading successfully disabled.ufirewalld.list_portsufirewalld.add_porttforce_masqueradeufirewalld.remove_portuportsufirewalld.list_port_fwdRuSource portRuDestination portRuProtocolR	uDestination addressufirewalld.add_port_fwdufirewalld.remove_port_fwduport_fwdufirewalld.list_servicesufirewalld.add_serviceufirewalld.remove_serviceuservicesufirewalld.get_interfacesufirewalld.add_interfaceufirewalld.remove_interfaceu
interfacesufirewalld.get_sourcesufirewalld.add_sourceufirewalld.remove_sourceusourcesufirewalld.get_rich_rulesufirewalld.add_rich_ruleufirewalld.remove_rich_ruleu
rich_rulesu&'{0}' is already in the desired state.u$Configuration for '{0}' will change:u
u'{0}' was configured.N(RR$RRR9R;R<R:tlogterrortremovetlistRRRRRR	RR Rtappendtoutputtrstriptjoin(5R%R&R'R(R)R*R+R,R-R.R/R0R1R2R3R4R5R6tzonesR?tnew_icmp_typestold_icmp_typest_current_icmp_blockst_valid_icmp_typest	icmp_typetdefault_zonetmasquerade_retR>R@RARBt_current_port_fwdtfwdtnew_port_fwdtold_port_fwdt_current_servicestnew_servicestold_servicestnew_servicetold_servicet_current_interfacestnew_interfacestold_interfacest	interfacet_current_sourcestnew_sourcestold_sourcestsourcet_current_rich_rulestnew_rich_rulestold_rich_rulest	rich_ruletcomment((s9/usr/lib/python2.7/site-packages/salt/states/firewalld.pyR#^s�






























!





A



 
.


































	 

(Rt
__future__RRRtloggingtsalt.exceptionsRtsalt.outputRtsalt.utils.pathRtsalt.utils.versionst	getLoggerRRItobjectRRRR RR7RFR#(((s9/usr/lib/python2.7/site-packages/salt/states/firewalld.pyt<module>MsX&		Nb

Zerion Mini Shell 1.0