관리-도구
편집 파일: policy.cpython-36.opt-1.pyc
3 @)�fϢ � @ s d ddgZ ddljZddlZddlZddlZddlmZ ddlm Z m Z ddlmZmZm Z ddlmZmZmZ dd lmZmZmZmZmZmZ dd lmZ ddlmZ ddlmZ dd lmZ dd� Z dd� Z!dd� Z"dd� Z#dd� Z$G dd � d e�Z%G dd� de�Z&ddd�Z'ddd�Z(dS ) �Policy� policy_reader� policy_writer� N)�config)�checkIP�checkIP6)�uniqify�max_policy_name_len�portStr)�DEFAULT_POLICY_TARGET�POLICY_TARGETS�DEFAULT_POLICY_PRIORITY)� IO_Object�IO_Object_ContentHandler�IO_Object_XMLGenerator� check_port�check_tcpudp�check_protocol)�rich)�log)�errors)� FirewallErrorc C s� |dkr�n�|dkr�n�|dkr�| j r`| j jrJtjdt| j �� d| _dS tj|d �| j _dS |d | jj kr�| jj j |d � ntjd|d � �n|dk�rN| j r�| j jr�tjdt| j �� d| _dS tj|d |d �| j _dS t|d � t |d � t|d d �|d f}|| jjk�r4| jjj |� ntjd|d |d � �nN|d k�r�| j �r�| j j�r�tjdt| j �� d| _dS tj|d �| j _nBt|d � |d | jjk�r�| jjj |d � ntjd |d � �n�|dk�rh| j �r.| j j�rtjdt| j �� d| _dS tj|d �| j _dS |d | jjk�rT| jjj |d � ntjd|d � �n4|dk�r�| j �r�| j j�r�tjdt| j �� d| _dS tj|d �| j _dS tjd|d � �n�|dk�r2| j �r| j j�rtjdt| j �� d| _dS tj� | j _n| jj�r&tjd� nd| j_�nj|dk�r�d}d|k�rR|d }d}d|k�rh|d }| j �r�| j j�r�tjdt| j �� d| _dS tj|d |d ||�| j _dS t|d � t |d � |�r�t|� |�r t|� �r t|� �r ttjd| ��t|d d �|d t|d �t|�f}|| jjk�rL| jjj |� n6tjd|d |d |�rld| nd|�r|d| nd� �n|dk�r@| j �r�| j j�r�tjdt| j �� d| _dS tj|d |d �| j _dS t|d � t |d � t|d d �|d f}|| jj k�r&| jj j |� ntjd|d |d � �n\|dk�r�| j �sftjd� d| _dS | j j!�r�tjd t| j �� dS d!}d }d"|k�r�|d" }d }d#|k�r�|d# }d$|k�r�|d$ j"� dLk�r�d}tj#|||�| j _!�n�|dMk�r�| j �stjd+� d| _dS | j j$�r0tjd,� d| _dS |d'k�rHtj%� | j _$nh|d(k�rxd } d-|k�rh|d- } tj&| �| j _$n8|d)k�r�tj'� | j _$n |d*k�r�|d. } tj(| �| j _$| j j$| _)�n�|d/k�r^| j �s�tjd0� dS | j j�r�tjd1� dS d }d2|k�r*|d2 }|dNk�r*tjd;� d| _dS d<|k�r<|d< nd }tj*||�| j _| j j| _)�n>|d=k�r�| j �s~tjd>� dS | j j+�r�tjd?t| j �� d| _dS tj,� | j _+| j j+| _)n�|d@k�r,d } dA}dB|k�r|dB } | dOk�rtjdE|dB � d| _dS dF|k�rt-|dF �}tj.| |dG�| _ np|dHk�r�| j)�sRtjdI� d| _dS | j)j/�rxtjdJt| j �� d| _dS |d }tj0||j1dK��| j)_/nd!S dS )PN�short�description�servicez;Invalid rule: More than one element in rule '%s', ignoring.T�namez#Service '%s' already set, ignoring.�port�protocol�-z#Port '%s/%s' already set, ignoring.�valuez$Protocol '%s' already set, ignoring.z icmp-blockz&icmp-block '%s' already set, ignoring.z icmp-typez-Invalid rule: icmp-block '%s' outside of rule� masqueradez!Masquerade already set, ignoring.zforward-port� zto-portzto-addrz#to-addr '%s' is not a valid addressz-Forward port %s/%s%s%s already set, ignoring.z >%sz @%szsource-portz*Source port '%s/%s' already set, ignoring.�destinationz)Invalid rule: Destination outside of rulez?Invalid rule: More than one destination in rule '%s', ignoring.F�address�ipset�invert�yes�true�accept�reject�drop�markz$Invalid rule: Action outside of rulez"Invalid rule: More than one action�type�setr z!Invalid rule: Log outside of rulezInvalid rule: More than one log�level�emerg�alert�crit�error�warning�notice�info�debugzInvalid rule: Invalid log level�prefix�auditz#Invalid rule: Audit outside of rulez9Invalid rule: More than one audit in rule '%s', ignoring.�ruler �family�ipv4�ipv6z&Invalid rule: Rule family "%s" invalid�priority)r: r= �limitz4Invalid rule: Limit outside of action, log and auditz9Invalid rule: More than one limit in rule '%s', ignoring.�burst)r&