
¡\\Ë
  ã               @   s©   d  Z  d d l Z d d l Z d d l m Z d d l m Z d d l m Z d d l m	 Z	 e j
 j e j ƒ Gd d „  d e j ƒ ƒ Z Gd	 d
 „  d
 e	 j ƒ Z d S)z7 Distribution specific override class for Gentoo Linux é    N)Ú
interfaces)Úapache_util)Úconfigurator)Úparserc            #       sÁ   e  Z d  Z d Z e d d d d d d d d	 d
 d d d d g d d d g d d d g d d d g d d d d d d d d d d d d d e j d d ƒ ƒ Z ‡  f d  d! †  Z d" d# „  Z	 ‡  S)$ÚGentooConfiguratorz1Gentoo specific ApacheConfigurator override classÚserver_rootz/etc/apache2Ú
vhost_rootz/etc/apache2/vhosts.dZvhost_filesz*.confZ	logs_rootz/var/log/apache2ÚctlZ
apache2ctlZversion_cmdz-vZrestart_cmdZgracefulÚrestart_cmd_altZrestartZconftest_cmdZ
configtestZenmodNZdismodZle_vhost_extz-le-ssl.confZhandle_modulesFZhandle_sitesZchallenge_locationZMOD_SSL_CONF_SRCÚcertbot_apachezoptions-ssl-apache.confc                s1   t  t |  ƒ j ƒ  |  j d ƒ |  j d d <d S)z„
        Override the options dictionary initialization in order to support
        alternative restart cmd used in Gentoo.
        r	   r
   r   N)Úsuperr   Ú_prepare_optionsÚoptionZoptions)Úself)Ú	__class__© ú@/usr/lib/python3/dist-packages/certbot_apache/override_gentoo.pyr   $   s    z#GentooConfigurator._prepare_optionsc             C   s1   t  |  j |  j d ƒ |  j d ƒ |  j d |  ƒS)zInitializes the ApacheParserr   r   r   )ÚGentooParserZaugr   Úversion)r   r   r   r   Ú
get_parser,   s    zGentooConfigurator.get_parser)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚdictÚpkg_resourcesZresource_filenameZOS_DEFAULTSr   r   r   r   )r   r   r      s*   r   c                   sL   e  Z d  Z d Z ‡  f d d †  Z d d „  Z d d „  Z d d	 „  Z ‡  S)
r   z+Gentoo specific ApacheParser override classc                s&   d |  _  t t |  ƒ j | | Ž  d  S)Nz/etc/conf.d/apache2)Úapacheconfig_filepr   r   Ú__init__)r   ÚargsÚkwargs)r   r   r   r   5   s    	zGentooParser.__init__c             C   s   |  j  ƒ  |  j ƒ  d S)z: Override for update_runtime_variables for custom parsing N)Úparse_sysconfig_varÚupdate_modules)r   r   r   r   Úupdate_runtime_variables:   s    
z%GentooParser.update_runtime_variablesc             C   sA   t  j |  j d ƒ } x% | j ƒ  D] } | | |  j | <q" Wd S)z: Parses Apache CLI options from Gentoo configuration file ZAPACHE2_OPTSN)r   Zparse_define_filer   ÚkeysÚ	variables)r   ZdefinesÚkr   r   r   r    ?   s    	z GentooParser.parse_sysconfig_varc             C   sR   |  j  j d ƒ d g } |  j | d ƒ } x! | D] } |  j | j ƒ  ƒ q1 Wd S)z:Get loaded modules from httpd process, and add them to DOMr	   Úmodulesz(.*)_moduleN)r   r   Zparse_from_subprocessZadd_modÚstrip)r   Zmod_cmdZmatchesÚmodr   r   r   r!   F   s    zGentooParser.update_modules)r   r   r   r   r   r"   r    r!   r   r   )r   r   r   3   s
   r   )r   r   Zzope.interfaceÚzopeZcertbotr   r   r   r   r   Z	interfaceZproviderZIPluginFactoryZApacheConfiguratorr   ZApacheParserr   r   r   r   r   Ú<module>   s   &