a «°i ã@sTdZddgZddlZddlZddlmZddlmZddlm Z dd„Z d d„Z dS) z.Functions to search for and change ifcfg filesÚsearch_ifcfg_of_interfaceÚifcfg_set_zone_of_interfaceéN)Úconfig)Úlog)ÚifcfgcCs¶tj tj¡sdStt tj¡ƒD]`}| d¡s2q"dD]}| |¡r6q6q6d|vrRq"t dtj|fƒ}|  ¡|  d¡|kr"|Sq"dtj|f}tj |¡r²t |ƒ}|  ¡|SdS)z6search ifcfg file for the interface in config.IFCFGDIRNzifcfg-)z.bakz.origz.rpmnewz.rpmorigz.rpmsavez-rangeÚ.z%s/%sZDEVICEz %s/ifcfg-%s) ÚosÚpathÚexistsrZIFCFGDIRÚsortedÚlistdirÚ startswithÚendswithrÚreadÚget)Ú interfaceÚfilenameZignoredÚ ifcfg_file©rú:/usr/lib/python3.9/site-packages/firewall/core/fw_ifcfg.pyr!s(    cCsl|dur d}t|ƒ}|durh| d¡|krh| d¡dur@|dksht d||jf¡| d|¡| ¡dS)zYSet zone (ZONE=) in the ifcfg file that uses the interface (DEVICE=)NÚZZONEzSetting ZONE=%s in '%s')rrrZdebug1rÚsetÚwrite)Úzonerrrrrr?s ÿÿ ) Ú__doc__Ú__all__rZos.pathZfirewallrZfirewall.core.loggerrZfirewall.core.io.ifcfgrrrrrrrÚs