U
    -_g                     @   sb   d dl Z d dlZd dlmZmZ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 )	    N)PluginRedHatPluginDebianPluginUbuntuPluginc                   @   s0   e Zd ZdZdZdZdZdZdd Zdd	 Z	dS )
Krb5a:  This plugin handles the collection of kerberos authentication config
    files and logging. Users should expect to see their krb5 config(s) in the
    final archive, along with krb5 logging and `klist` output.

    kdc configs and acls will also be collected from the distribution-spcecific
    kdc directory.
    zKerberos authenticationZkrb5)ZidentitysystemNc                 C   s\   |  dd| j d| j ddg |   | j ddd | d	| j d
 | d d S )Nz/etc/krb5.confz/etc/krb5.conf.d/*z
/kadm5.aclz	/kdc.confz/var/log/kadmind.logz/var/log/krb5kdc.logZkerberos_kdc_log)Ztagszklist -ket z/.k5*zklist -ket /etc/krb5.keytab)Zadd_copy_speckdcdircollect_kinitadd_cmd_output)self r   9/usr/lib/python3/dist-packages/sos/report/plugins/krb5.pysetup   s    

z
Krb5.setupc              	   C   s   t  }d}| |rt|dddv}|D ]j}td|tjrn|dd dd	  }| 	d
| d  qtd|tjr*| 	d
| d  qq*W 5 Q R X dS )a)  
        Collect the kinit command output for the system with id_provider "AD"
        or "IPA" domains.

        While integrating the Linux M/c with AD the realmd will create a
        computer object on the AD side. The realmd and AD restrict the
        Hostname/SPN to 15 Characters.
        z/etc/sssd/sssd.confrzutf-8)encodingz\s*id_provider\s*=\s*ad.r   N   zMKRB5_TRACE=/dev/stdout                                             kinit -k 'z$'z\s*id_provider\s*=\s*ipa')
socketZgetfqdnZpath_isfileopenrematch
IGNORECASEsplitupperr
   )r   ZhostnameZ	sssd_conffliner   r   r   r	   +   s,    

 
 
zKrb5.collect_kinit)
__name__
__module____qualname____doc__Z
short_descZplugin_nameZprofilesr   r   r	   r   r   r   r   r      s   r   c                   @   s   e Zd ZdZdZdS )
RedHatKrb5)z	krb5-libszkrb5-serverz/var/kerberos/krb5kdcNr   r   r   Zpackagesr   r   r   r   r   r!   G   s   r!   c                   @   s   e Zd ZdZdZdS )
UbuntuKrb5)zkrb5-kdczkrb5-configz	krb5-userz/var/lib/krb5kdcNr"   r   r   r   r   r#   M   s   r#   )
r   r   Zsos.report.pluginsr   r   r   r   r   r!   r#   r   r   r   r   <module>   s
   7