o
    c{	                     @   sh   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 dej	Z
G d	d
 d
ejZdS )z7 Distribution specific override class for Gentoo Linux     )Any)apache_util)configurator)parser)	OsOptionsc                       sB   e Zd ZdZedddddgddZd fd
dZdddZ  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_locationreturnNc                    s.   t    | jjstd| jj| jjd< dS )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__ U/opt/certbot/lib/python3.10/site-packages/certbot_apache/_internal/override_gentoo.pyr      s   
z#GentooConfigurator._prepare_optionsGentooParserc                 C   s   t | jj| | jj| jS )zInitializes the ApacheParser)r   r   r
   r   versionr   r   r   r   
get_parser   s   zGentooConfigurator.get_parserr   N)r   r   )	__name__
__module____qualname____doc__r   OS_DEFAULTSr   r   __classcell__r   r   r   r   r   
   s    
r   c                       sL   e Zd ZdZdededdf fddZddd	Zdd
dZdddZ  Z	S )r   z+Gentoo specific ApacheParser override classargskwargsr   Nc                    s   d| _ t j|i | d S )Nz/etc/conf.d/apache2)apacheconfig_filepr   __init__)r   r%   r&   r   r   r   r(   '   s   zGentooParser.__init__c                 C   s   |    |   dS )z: Override for update_runtime_variables for custom parsing N)parse_sysconfig_varupdate_modulesr   r   r   r   update_runtime_variables,   s   z%GentooParser.update_runtime_variablesc                 C   s.   t | jd}| D ]	\}}|| j|< qdS )z: Parses Apache CLI options from Gentoo configuration file APACHE2_OPTSN)r   parse_define_filer'   items	variables)r   defineskvr   r   r   r)   1   s   z GentooParser.parse_sysconfig_varc                 C   s6   | j jjdg}t|d}|D ]	}| |  qdS )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modr   r   r   r*   8   s
   zGentooParser.update_modulesr   )
r   r    r!   r"   r   r(   r+   r)   r*   r$   r   r   r   r   r   %   s    

r   N)r"   typingr   certbot_apache._internalr   r   r   %certbot_apache._internal.configuratorr   ApacheConfiguratorr   ApacheParserr   r   r   r   r   <module>   s    