%PDF- %PDF-
| Direktori : /proc/thread-self/root/proc/self/root/usr/lib/python2.7/site-packages/salt/states/ |
| Current File : //proc/thread-self/root/proc/self/root/usr/lib/python2.7/site-packages/salt/states/csf.pyo |
�
���^c @@ s� d Z d d l m Z m Z m Z d d l Z d d l m Z e j e � Z
d � Z d d d d d d d
e
d � Z d d d d d d e
d � Z d d d
� Z d � Z e
d � Z e
d � Z e
d � Z e
d � Z d S( u"
CSF Ip tables management
========================
:depends: - csf utility
:configuration: See http://download.configserver.com/csf/install.txt
for setup instructions.
.. code-block:: yaml
Simply allow/deny rules:
csf.rule_present:
ip: 1.2.3.4
method: allow
i ( t absolute_importt print_functiont unicode_literalsN( t sixc C@ s d S( Nu csf( ( ( ( s3 /usr/lib/python2.7/site-packages/salt/states/csf.pyt __virtual__ s u tcpu inu du su c
C@ s8 i | d 6i d 6t d 6d d 6}
| } t d d | d | d | d
| d | d | d
| d | d | � } | ru |
S| r� d j | � } n t d j | � }
|
| d | d
| d | d | d
| d | d | �} | r� d } n | rt d � r| d 7} q| d 7} t |
d <n | |
d <d |
d d <|
S( ut
Ensure iptable rule exists.
name
The ip address or CIDR for the rule.
method
The type of rule. Either 'allow' or 'deny'.
port
Optional port to be open or closed for the
iptables rule.
proto
The protocol. Either 'tcp', or 'udp'.
Only applicable if port is specified.
direction
The diretion of traffic to apply the rule to.
Either 'in', or 'out'. Only applicable if
port is specified.
port_origin
Specifies either the source or destination
port is relevant for this rule. Only applicable
if port is specified. Either 's', or 'd'.
ip_origin
Specifies whether the ip in this rule refers to
the source or destination ip. Either 's', or
'd'. Only applicable if port is specified.
ttl
How long the rule should exist. If supplied,
`csf.tempallow()` or csf.tempdeny()` are used.
comment
An optional comment to appear after the rule
as a #comment .
reload
Reload the csf service after applying this rule.
Default false.
u nameu changesu resultu Rule already exists.u commentu
csf.existst methodt ipt portt protot directiont port_origint ip_origint ttlt commentu temp{0}u csf.{0}u Rule has been added.u
csf.reloadu Csf reloaded.u Unable to reload csf.u Createdu Rule( t Truet __salt__t formatt False( t nameR R R R R
R R R
t reloadt retR t existst funct rule( ( s3 /usr/lib/python2.7/site-packages/salt/states/csf.pyt rule_present sJ 7
c C@ s | } i | d 6i d 6t d 6d d 6}
t d | | d | d | d | d
| d | d | �} | si |
St d
d | d | d | d | d | d
| d | d d d | � } | r� d }
n | r� t d � r� |
d 7}
q� |
d 7}
n |
|
d <d |
d d <|
S( u
Ensure iptable is not present.
name
The ip address or CIDR for the rule.
method
The type of rule. Either 'allow' or 'deny'.
port
Optional port to be open or closed for the
iptables rule.
proto
The protocol. Either 'tcp', 'udp'.
Only applicable if port is specified.
direction
The diretion of traffic to apply the rule to.
Either 'in', or 'out'. Only applicable if
port is specified.
port_origin
Specifies either the source or destination
port is relevant for this rule. Only applicable
if port is specified. Either 's', or 'd'.
ip_origin
Specifies whether the ip in this rule refers to
the source or destination ip. Either 's', or
'd'. Only applicable if port is specified.
ttl
How long the rule should exist. If supplied,
`csf.tempallow()` or csf.tempdeny()` are used.
reload
Reload the csf service after applying this rule.
Default false.
u nameu changesu resultu Rule not present.u commentu
csf.existsR R R R
R R u csf.remove_ruleR R R
u u Rule has been removed.u
csf.reloadu Csf reloaded.u Csf unable to be reloaded.u Removedu Rule( R R ( R R R R R R
R R R R R R R R
( ( s3 /usr/lib/python2.7/site-packages/salt/states/csf.pyt rule_absent� sB 1
c C@ s t t j j t j | � � } t } i d j | � d 6i d 6t d 6d d 6} t d d | d | � } | j � } t d
| � } xK | D]C } t
j d | | � t
j d | � | | | k r� t } q� q� W| rt d
| d | d | �} d | d d <| | d <n | S( u�
Ensure ports are open for a protocol, in a direction.
e.g. - proto='tcp', direction='in' would set the values
for TCP_IN in the csf.conf file.
ports
A list of ports that should be open.
proto
The protocol. May be one of 'tcp', 'udp',
'tcp6', or 'udp6'.
direction
Choose 'in', 'out', or both to indicate the port
should be opened for inbound traffic, outbound
traffic, or both.
u ,u nameu changesu resultu Ports open.u commentu
csf.get_portsR R u csf.build_directionsu current_ports[direction]: %su ports: %su csf.allow_portsu Changedu Ports( t listR t movest mapt text_typeR t joinR R t uppert logt trace( R t portsR R t diffR t
current_portst
directionst result( ( s3 /usr/lib/python2.7/site-packages/salt/states/csf.pyt
ports_open� s&