%PDF- %PDF-
Direktori : /lib/python2.7/site-packages/salt/states/ |
Current File : //lib/python2.7/site-packages/salt/states/firewalld.pyo |
� ���^c @@ s" d Z d d l m Z m Z m Z d d l Z d d l m Z d d l m Z d d l Z d d l Z e j e � Z d e f d � � YZ d � Z d � Z d e d e d e d e d d d e d e d e d � Z d d d � Z d e d e d e d e d d d e d e d e d � Z d S( 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 ( t absolute_importt print_functiont unicode_literalsN( t CommandExecutionError( t nestedt ForwardingMappingc B@ s; e Z d Z d � Z d � Z d � Z d � Z d � Z RS( u Represents a port forwarding statement mapping a local port to a remote port for a specific protocol (TCP or UDP) c C@ s( | | _ | | _ | | _ | | _ d S( N( t srcportt destportt protocolt destaddr( t selfR R R R ( ( s9 /usr/lib/python2.7/site-packages/salt/states/firewalld.pyt __init__a s c C@ sF | j | j k oE | j | j k oE | j | j k oE | j | j k S( N( R R R R ( R t other( ( s9 /usr/lib/python2.7/site-packages/salt/states/firewalld.pyt __eq__g s c C@ s | j | � S( N( R ( R R ( ( s9 /usr/lib/python2.7/site-packages/salt/states/firewalld.pyt __ne__m s c C@ s4 t | j � t | j � At | j � At | j � AS( N( t hashR R R R ( R ( ( s9 /usr/lib/python2.7/site-packages/salt/states/firewalld.pyt __hash__q s &c C@ s, i | j d 6| j d 6| j d 6| j d 6S( uL Returns a pretty dictionary meant for command line output. u Source portu Destination portu Protocolu Destination address( R R R R ( R ( ( s9 /usr/lib/python2.7/site-packages/salt/states/firewalld.pyt todictw s ( t __name__t __module__t __doc__R R R R R ( ( ( s9 /usr/lib/python2.7/site-packages/salt/states/firewalld.pyR \ s c C@ sj t | j d � � d k r9 | j d � \ } } } } n | j d � \ } } } 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 :i u ( t lent splitR ( t mappingR R R R ( ( s9 /usr/lib/python2.7/site-packages/salt/states/firewalld.pyt _parse_forward� s c C@ s# t j j j d � r t St d f S( u. Ensure the firewall-cmd is available u firewall-cmduC firewall-cmd is not available, firewalld is probably not installed.( t saltt utilst patht whicht Truet False( ( ( s9 /usr/lib/python2.7/site-packages/salt/states/firewalld.pyt __virtual__� s c C@ s� | d k r+ t } t j j j d d � n t | | | | | | | | | | | | | | | | | � } | d i k r� t d � 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. u Neonuj The 'prune_services' argument default is currently True, but will be changed to False in the Neon release.u changesu firewalld.reload_rulesN( t NoneR R R t versionst warn_untilt _presentt __salt__( t namet block_icmpt prune_block_icmpt defaultt masqueradet portst prune_portst port_fwdt prune_port_fwdt servicest prune_servicest interfacest prune_interfacest sourcest prune_sourcest rich_rulest prune_rich_rulest ret( ( s9 /usr/lib/python2.7/site-packages/salt/states/firewalld.pyt present� s M c C@ s� i | d 6t d 6i d 6d d 6} | t d � k rL t d | d t �n | pU g } y t d | � } Wn'