o
    i©¹dP
  ã                   @   sb   d dl mZmZmZmZ d dlmZmZ G dd„ deƒZG dd„ deeƒZ	G dd„ deeeƒZ
d	S )
é    )ÚPluginÚRedHatPluginÚDebianPluginÚUbuntuPlugin)ÚjoinÚnormpathc                   @   s8   e Zd ZdZdZdZdZeZdd„ Zdd„ Z	d	d
„ Z
dS )ÚNamedzBIND named serverÚnamed)ÚsystemÚservicesÚnetworkú/etc/named.confc                 C   sb   |   ddg¡ | jD ]$}|  |¡r.|   ||  |¡g¡ |  t|  |¡dƒt|  |¡dƒg¡ q
d S )Nz/etc/default/bindz/var/log/named*.logz
chroot/devzchroot/proc)Úadd_copy_specÚconfig_filesÚpath_existsÚget_dns_dirÚadd_forbidden_pathr   )ÚselfÚcfg© r   ú:/usr/lib/python3/dist-packages/sos/report/plugins/named.pyÚsetup   s    þ

þþ€úzNamed.setupc                 C   s    |   d|¡}|rt|d ƒS dS )z3 grab directory path from named{conf,boot}
        zdirectory\s+\"(.*)\"r   Ú )Údo_regex_find_allr   )r   Úconfig_fileÚdirectory_listr   r   r   r   &   s   ÿzNamed.get_dns_dirc                 C   s   d}d}|   | j||¡ d S )Nz(\s*arg \"password )[^\"]*z\1******)Údo_file_subÚ
named_conf)r   ÚmatchÚsubstr   r   r   Úpostproc0   s   zNamed.postprocN)Ú__name__Ú
__module__Ú__qualname__Ú
short_descÚplugin_nameÚprofilesr   r   r   r   r    r   r   r   r   r      s    
r   c                       s0   e Zd ZdZdZedfZdZ‡ fdd„Z‡  ZS )ÚRedHatNamedr   )r   z/etc/named.bootú/etc/sysconfig/named)Úbindc                    s:   t t| ƒ ¡  |  d¡ |  d¡ |  d¡ |  d¡ d S )Nz/etc/named/r(   zklist -ket /etc/named.keytabz/etc/named.keytab)Úsuperr'   r   r   Úadd_cmd_outputr   ©r   ©Ú	__class__r   r   r   >   s   



zRedHatNamed.setup)	r!   r"   r#   r   r   ÚfilesÚpackagesr   Ú__classcell__r   r   r-   r   r'   6   s    r'   c                       s2   e Zd ZdZdZdZeddfZ‡ fdd„Z‡  ZS )ÚDebianNamed)ú/etc/bind/named.conf)Úbind9r3   z/etc/bind/named.conf.optionsz/etc/bind/named.conf.localc                    s   t t| ƒ ¡  |  d¡ d S )Nz
/etc/bind/)r*   r2   r   r   r,   r-   r   r   r   P   s   
zDebianNamed.setup)	r!   r"   r#   r/   r0   r   r   r   r1   r   r   r-   r   r2   G   s    þr2   N)Úsos.report.pluginsr   r   r   r   Úos.pathr   r   r   r'   r2   r   r   r   r   Ú<module>   s
   )