a Ri@sRddlZddlmZmZmZmZddZddZdd Zd d Z ej d d Z dS)N)errors log_utils process_utilsutilscCs"tj|\}}tj|d|S)Nztmp.)ospathsplitjoin)fnameheadtailr-/usr/libexec/kcare/python/kcarectl/selinux.pyselinux_safe_tmpname srcCsNtrJtddd|g}tj|ddd\}}}|rJtjd|||dddS) NZ restorecon)z /usr/sbinz/sbinz-RT) catch_stdout catch_stderrz8SELinux context restoration for {0} failed with {1}: {2}F) print_msg)is_selinux_enabledrfind_cmd run_commandrlogerrorformat)dnamecmdcode_stderrrrrrestore_selinux_contextsrcCsTtjddgdd\}}}|r2tjd||dd|dD]}||vr<dSq.wrapperr)r*r+rr)rskip_if_no_selinux_module$s r,cCs,tjdr tdg\}}}ndS|dkS)Nz/usr/sbin/selinuxenabledFr)rrisfilerr)rrrrrr-s r) rrrrrrrr%r,cachedrrrrrs