dbfdg 3 wh@sjddlZddlmZddlmZddlmZddlmZddZd d Zd d Zd dZ ej ddZ dS)N) process_utils) log_utils)errors)utilscCs"tjj|\}}tjj|d|S)Nztmp.)ospathsplitjoin)fnameheadtailr-/usr/libexec/kcare/python/kcarectl/selinux.pyselinux_safe_tmpname srcCsNtrJtjdd d|g}tj|ddd\}}}|rJtjdj|||dd dS) NZ restorecon /usr/sbin/sbinz-RT) catch_stdout catch_stderrz8SELinux context restoration for {0} failed with {1}: {2}F) print_msg)rr)is_selinux_enabledrfind_cmd run_commandrlogerrorformat)dnamecmdcode_stderrrrrrestore_selinux_contexts r cCsRtjddgdd\}}}|r.tjdj||x|jdD]}||kr:dSq:WdS)Nz/usr/sbin/semodulez-lT)rz/SELinux modules list gathering error: '{0}' {1} F)rrr KcareErrorrr )Z semodule_namerouterrlinerrris_selinux_module_presentsr&csfdd}|S)Ncs$trtd rtjd||S)Nlibcarez:SELinux is enabled but libcare policy module is not loaded)rr&rr")argskwargs)clblrrwrapper(s z*skip_if_no_selinux_module..wrapperr)r*r+r)r*rskip_if_no_selinux_module's r,cCs,tjjdr tjdg\}}}ndS|dkS)Nz/usr/sbin/selinuxenabledFr)rrisfilerr)rrrrrr0s r) rrrrrrr r&r,cachedrrrrrs