
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
3
;j                 @   sR   d dl Z ddlmZmZmZmZ dd Zdd Zdd	 Zd
d Z	ej
dd ZdS )    N   )errors	log_utilsprocess_utilsutilsc             C   s"   t jj| \}}t jj|d| S )Nztmp.)ospathsplitjoin)fnameheadtail r   -/usr/libexec/kcare/python/kcarectl/selinux.pyselinux_safe_tmpname
   s    r   c             C   sN   t  rJtjdd
d| g}tj|ddd\}}}|rJtjdj| ||dd	 d S )NZ
restorecon	/usr/sbin/sbinz-RT)catch_stdoutcatch_stderrz8SELinux context restoration for {0} failed with {1}: {2}F)	print_msg)r   r   )is_selinux_enabledr   find_cmdrun_commandr   logerrorformat)dnamecmdcode_stderrr   r   r   restore_selinux_context   s    r    c             C   sV   t jddgdd\}}}|r2tjdj||ddx|jdD ]}| |kr>dS q>W d	S )
Nz/usr/sbin/semodulez-lT)r   z/SELinux modules list gathering error: '{0}' {1}zselinux modules error)status
F)r   r   r   
KcareErrorr   r	   )Zsemodule_namer   outerrliner   r   r   is_selinux_module_present   s    r'   c                s    fdd}|S )Nc                 s$   t  rtd rtjd | |S )Nlibcarez:SELinux is enabled but libcare policy module is not loaded)r   r'   r   r#   )argskwargs)clblr   r   wrapper%   s    
z*skip_if_no_selinux_module.<locals>.wrapperr   )r+   r,   r   )r+   r   skip_if_no_selinux_module$   s    r-   c              C   s,   t jjdr tjdg\} }}ndS | dkS )Nz/usr/sbin/selinuxenabledFr   )r   r   isfiler   r   )r   r   r   r   r   r   -   s    r   )r    r   r   r   r   r   r    r'   r-   cachedr   r   r   r   r   <module>   s   
	