ó
æ”\c           @   s~   d  d l  Z  d d l m Z d d l Td  d l Z d  d l m Z d  d l m	 Z	 e j
 j ƒ  Z d e j f d „  ƒ  YZ d S(	   iÿÿÿÿNi   (   t   base(   t   *(   t
   exceptions(   t   commandst   SelinuxPluginc           B   sq   e  Z d  Z e d „  ƒ Z d „  Z e d „  ƒ Z d „  Z d „  Z e	 d ƒ d „  ƒ Z
 e d ƒ d „  ƒ Z RS(	   s&   
	Plugin for tuning SELinux options.
	c         C   s@   d } t  j j | ƒ s< d } t  j j | ƒ s< d  } q< n  | S(   Ns   /sys/fs/selinuxs   /selinux(   t   ost   patht   existst   None(   t   selfR   (    (    s@   /usr/lib/python2.7/site-packages/tuned/plugins/plugin_selinux.pyt   _get_selinux_path   s    c         O   sw   t  ƒ  |  _ |  j ƒ  |  _ |  j d  k r< t j d ƒ ‚ n  t j j	 |  j d d ƒ |  _
 t t |  ƒ j | | Ž  d  S(   NsF   SELinux is not enabled on your system or incompatible version is used.t   avct   cache_threshold(   R   t   _cmdR
   t   _selinux_pathR   R   t   NotSupportedPluginExceptionR   R   t   joint   _cache_threshold_patht   superR   t   __init__(   R	   t   argst   kwargs(    (    s@   /usr/lib/python2.7/site-packages/tuned/plugins/plugin_selinux.pyR      s    c         C   s   i d  d 6S(   Nt   avc_cache_threshold(   R   (   R	   (    (    s@   /usr/lib/python2.7/site-packages/tuned/plugins/plugin_selinux.pyt   _get_config_options    s    c         C   s   t  | _ t | _ d  S(   N(   t   Truet   _has_static_tuningt   Falset   _has_dynamic_tuning(   R	   t   instance(    (    s@   /usr/lib/python2.7/site-packages/tuned/plugins/plugin_selinux.pyt   _instance_init&   s    	c         C   s   d  S(   N(    (   R	   R   (    (    s@   /usr/lib/python2.7/site-packages/tuned/plugins/plugin_selinux.pyt   _instance_cleanup*   s    R   c         C   sS   | d  k r d  St | ƒ } | d k rK | sG |  j j |  j | ƒ n  | Sd  Sd  S(   Ni    (   R   t   intR   t   write_to_fileR   (   R	   t   valuet   simt	   threshold(    (    s@   /usr/lib/python2.7/site-packages/tuned/plugins/plugin_selinux.pyt   _set_avc_cache_threshold-   s    c         C   s5   |  j  j |  j ƒ } t | ƒ d k r1 t | ƒ Sd  S(   Ni    (   R   t	   read_fileR   t   lenR   R   (   R	   R!   (    (    s@   /usr/lib/python2.7/site-packages/tuned/plugins/plugin_selinux.pyt   _get_avc_cache_threshold9   s    
(   t   __name__t
   __module__t   __doc__t   classmethodR
   R   R   R   R   t   command_setR$   t   command_getR'   (    (    (    s@   /usr/lib/python2.7/site-packages/tuned/plugins/plugin_selinux.pyR   
   s   				(   R   t    R    t
   decoratorst
   tuned.logst   tunedt   tuned.pluginsR   t   tuned.utils.commandsR   t   logst   gett   logt   PluginR   (    (    (    s@   /usr/lib/python2.7/site-packages/tuned/plugins/plugin_selinux.pyt   <module>   s   
