관리-도구
편집 파일: functions.cpython-36.opt-1.pyc
3 @)�fy � @ s� d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dl m Z d dlmZ d dl mZ d d lmZ d d lmZ d dlmZ d dlmZ d d lmZ dd� ZdS )� N)�config)� FirewallError)�FirewallConfig)�zone_reader)�service_reader)�ipset_reader)�icmptype_reader)� helper_reader)� policy_reader)�Direct)�LockdownWhitelist)�firewalld_confc - C s| t | �}t|jtjtjgd�t|jtjtj gd�t |jtjtj gd�t|jtjtjgd�t|jtjtjgd�t|jtjtjgd�d�}�x |j� D � ]�}x�|| d D ]�}tjj|�s�q�x�ttj|��D ]�}|j d�r�yD|| d ||�}|d k� r�||_!|j"|j#� � || d |� W q� t$k �rT } zt$|j%d ||j&f ��W Y d d }~X q� t'k �r� } zt'd ||f ��W Y d d }~X q�X q�W q�W q�W tjj(tj)��r:y$t*tj)�}|j+� |j,|j-� � W np t$k �r } zt$|j%d tj)|j&f ��W Y d d }~X n6 t'k �r8 } zt'd tj)|f ��W Y d d }~X nX tjj(tj.��r�y$t/tj.�}|j+� |j,|j-� � W np t$k �r� } zt$|j%d tj.|j&f ��W Y d d }~X n6 t'k �r� } zt'd tj.|f ��W Y d d }~X nX tjj(tj0��rxyt1tj0�}|j+� W np t$k �rB } zt$|j%d tj0|j&f ��W Y d d }~X n6 t'k �rv } zt'd tj0|f ��W Y d d }~X nX d S )N)�reader�add�dirs)Zipset�helperZicmptypeZservice�zone�policyr z.xmlr r r r z'%s': %s)r r )2r r Z add_ipsetr ZFIREWALLD_IPSETSZETC_FIREWALLD_IPSETSr Z add_helperZFIREWALLD_HELPERSZETC_FIREWALLD_HELPERSr Zadd_icmptypeZFIREWALLD_ICMPTYPESZETC_FIREWALLD_ICMPTYPESr Zadd_serviceZFIREWALLD_SERVICESZETC_FIREWALLD_SERVICESr Zadd_zoneZFIREWALLD_ZONESZETC_FIREWALLD_ZONESr Zadd_policy_objectZFIREWALLD_POLICIESZETC_FIREWALLD_POLICIES�keys�os�path�isdir�sorted�listdir�endswith� fw_configZcheck_config_dictZexport_config_dictr �code�msg� Exception�isfileZFIREWALLD_DIRECTr �read�check_configZ export_configZLOCKDOWN_WHITELISTr ZFIREWALLD_CONFr ) �fwr Zreadersr Z_dir�file�obj�errorr � r&