
    M/e{	                         d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ  G d dej                        Z
 G d	 d
ej                        Zy)z7 Distribution specific override class for Gentoo Linux     )Any)apache_util)configurator)parser)	OsOptionsc                   J     e Zd ZdZ edddddgd      Zd
 fdZdd	Z xZS )GentooConfiguratorz1Gentoo specific ApacheConfigurator override classz/etc/apache2z/etc/apache2/vhosts.dz*.conf
apache2ctlrestart)server_root
vhost_rootvhost_filesrestart_cmd_altchallenge_locationc                     t         |           | j                  j                  st	        d      | j                  j
                  | j                  j                  d<   y)z
        Override the options dictionary initialization in order to support
        alternative restart cmd used in Gentoo.
        z1OS option restart_cmd_alt must be set for Gentoo.r   N)super_prepare_optionsoptionsr   
ValueErrorctl)self	__class__s    J/usr/lib/python3/dist-packages/certbot_apache/_internal/override_gentoo.pyr   z#GentooConfigurator._prepare_options   sG    
 	 "||++PQQ*.,,*:*:$$Q'    c                     t        | j                  j                  | | j                  j                  | j                        S )zInitializes the ApacheParser)GentooParserr   r   r   versionr   s    r   
get_parserzGentooConfigurator.get_parser   s2    LL$$dDLL,C,CT\\S 	Sr   returnN)r!   r   )	__name__
__module____qualname____doc__r   OS_DEFAULTSr   r   __classcell__r   s   @r   r	   r	   
   s/    ;"*%y12K;Sr   r	   c                   H     e Zd ZdZdededdf fdZd
dZd
dZd
d	Z xZ	S )r   z+Gentoo specific ApacheParser override classargskwargsr!   Nc                 2    d| _         t        |   |i | y )Nz/etc/conf.d/apache2)apacheconfig_filepr   __init__)r   r*   r+   r   s      r   r.   zGentooParser.__init__'   s    "7$)&)r   c                 D    | j                          | j                          y)z: Override for update_runtime_variables for custom parsing N)parse_sysconfig_varupdate_modulesr   s    r   update_runtime_variablesz%GentooParser.update_runtime_variables,   s      "r   c                     t        j                  | j                  d      }|j                         D ]  \  }}|| j                  |<    y)z: Parses Apache CLI options from Gentoo configuration file APACHE2_OPTSN)r   parse_define_filer-   items	variables)r   defineskvs       r   r0   z GentooParser.parse_sysconfig_var1   sE    //0G0G0>@MMO 	"DAq !DNN1	"r   c                     | j                   j                  j                  dg}t        j                  |d      }|D ]!  }| j                  |j                                # y)z:Get loaded modules from httpd process, and add them to DOMmodulesz(.*)_moduleN)r   r   r   r   parse_from_subprocessadd_modstrip)r   mod_cmdmatchesmods       r   r1   zGentooParser.update_modules8   sQ    $$,,00)<33G^L 	&CLL%	&r   r    )
r"   r#   r$   r%   r   r.   r2   r0   r1   r'   r(   s   @r   r   r   %   s/    5*c *S *T *

"&r   r   N)r%   typingr   certbot_apache._internalr   r   r   %certbot_apache._internal.configuratorr   ApacheConfiguratorr	   ApacheParserr    r   r   <module>rI      s=    =  0 1 + ;S88 S6&6&& &r   