3
��g
� @ sT d Z ddgZddlZddlZddlmZ ddlmZ ddlm Z dd� Z
d d� ZdS )
z.Functions to search for and change ifcfg files�search_ifcfg_of_interface�ifcfg_set_zone_of_interface� N)�config)�log)�ifcfgc C s� t jjtj�sdS xttt jtj��D ]`}|jd�s4q$xd
D ]}|j|�r:q:q:W d |krXq$t d
tj|f �}|j
� |jd�| kr$|S q$W dtj| f }t jj|�r�t |�}|j
� |S dS )z6search ifcfg file for the interface in config.IFCFGDIRNzifcfg-�.bak�.orig�.rpmnew�.rpmorig�.rpmsave�-range�.z%s/%sZDEVICEz%s/ifcfg-%s)r r r r
r r )�os�path�existsr ZIFCFGDIR�sorted�listdir�
startswith�endswithr �read�get)� interface�filenameZignored�
ifcfg_file� r �/usr/lib/python3.6/fw_ifcfg.pyr ! s*
c C sn | dkrd} t |�}|dk rj|jd�| krj|jd�dko>| dk rjtjd| |jf � |jd| � |j� dS )zYSet zone (ZONE=<zone>) in the ifcfg file that uses the interface
(DEVICE=<interface>)N� ZZONEzSetting ZONE=%s in '%s')r r r Zdebug1r �set�write)Zzoner r r r r r ? s )�__doc__�__all__r Zos.pathZfirewallr Zfirewall.core.loggerr Zfirewall.core.io.ifcfgr r r r r r r �<module> s