File: //lib/python3/dist-packages/sos/report/plugins/__pycache__/postfix.cpython-38.pyc
U
i��d� � @ sZ d dl mZmZmZmZ d dlZG dd� de�ZG dd� dee�ZG dd� deee�ZdS ) � )�Plugin�RedHatPlugin�DebianPlugin�UbuntuPluginNc @ s4 e Zd ZdZdZdZdZdd� Zdd� Zd d
� Z dS )�PostfixzPostfix smtp server�postfix)Zmail�services�r c C s� ddddddddd d
ddd
ddddg}g }d zjt | �d�d��P}|�� D ]@}|�d�rXqH|�d�}|d �� |krH|�|d �� d � qHW 5 Q R X W 5 |� S X )NZlmtp_tls_dkey_fileZlmtp_tls_eckey_fileZlmtp_tls_key_fileZsmtp_tls_dkey_fileZsmtp_tls_eckey_fileZsmtp_tls_key_fileZsmtpd_tls_dkey_fileZsmtpd_tls_eckey_fileZsmtpd_tls_key_fileZ"tls_legacy_public_key_fingerprintsZtlsproxy_tls_dkey_fileZtlsproxy_tls_eckey_fileZtlsproxy_tls_key_fileZsmtpd_tls_dh1024_param_fileZsmtpd_tls_dh512_param_fileZtlsproxy_tls_dh1024_param_fileZtlsproxy_tls_dh512_param_file�/etc/postfix/main.cf�r�#�=r � )�open� path_join� readlines�
startswith�split�strip�append)�self�forbid_attributes�fp�cffile�lineZwords� r �</usr/lib/python3/dist-packages/sos/report/plugins/postfix.py�forbidden_ssl_keys_files s8 �
&z Postfix.forbidden_ssl_keys_filesc
C s� d}g }d}t �d�}z�t| �d�d���}|�� D ]|}t �dd|�}|�|�}|d krXq2|�d��� }||kr2|�d ��� } t | �d
kr�q2| �
|�r�| t |�d � } |�| � q2W 5 Q R X W n< tk
r� }
zd|
j
d
� �}| �|� W 5 d }
~
X Y nX |S )N)Zlmtp_sasl_password_mapsZsmtp_sasl_password_mapsZpostscreen_dnsbl_reply_mapZsmtp_sasl_auth_cache_namezhash:z
^(.*)=(.*)r
r z#.*� r � r zError parsing main.cf: )�re�compiler r r �sub�match�groupr �lenr r � Exception�argsZ
_log_error)r r r �prefixZ
option_formatr r ZoptionZ attribute�filepath�e�msgr r r �forbidden_password_files9 s.
z Postfix.forbidden_password_filesc C sJ | � dg� | �ddg� | �dddg� | �| �� � | �| �� � d S )Nz
/etc/postfix/ZpostconfZmailqz/etc/postfix/*.keyz/etc/postfix/*.crtz/etc/postfix/ssl/)�
add_copy_specZadd_cmd_outputZadd_forbidden_pathr r, �r r r r �setup] s ���z
Postfix.setupN)
�__name__�
__module__�__qualname__Z
short_descZplugin_nameZprofiles�packagesr r, r/ r r r r r s #$r c s$ e Zd ZdZdZ� fdd�Z� ZS )�
RedHatPostfix)z/etc/rc.d/init.d/postfixr c s t t| ��� | �d� d S )Nz /etc/mail)�superr4 r/ r- r. �� __class__r r r/ t s zRedHatPostfix.setup)r0 r1 r2 �filesr3 r/ �
__classcell__r r r6 r r4 o s r4 c s e Zd ZdZ� fdd�Z� ZS )�
DebianPostfixr c s t t| ��� d S )N)r5 r: r/ r. r6 r r r/ } s zDebianPostfix.setup)r0 r1 r2 r3 r/ r9 r r r6 r r: y s r: ) Zsos.report.pluginsr r r r r r r4 r: r r r r �<module> s a