← Back
Editing: postfix.cpython-38.pyc
U O6ufI � @ sZ d dl Z d dlmZmZmZmZ G dd� de�ZG dd� dee�ZG dd� deee�ZdS ) � N)�Plugin�RedHatPlugin�DebianPlugin�UbuntuPluginc @ s4 e Zd ZdZdZdZdZdd� Zdd� Zd d � Z dS )�PostfixzPostfix smtp server�postfix)Zmail�services�r c C s� ddddddddd d ddd ddddg}g }znt | �d�ddd��P}|�� D ]@}|�d�rZqJ|�d�}|d �� |krJ|�|d �� d � qJW 5 Q R X W n tk r� Y nX |S )zi list of attributes defining a location of a SSL key file we must forbid from collection Zlmtp_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�UTF-8��encoding�#�=r � )�open� path_join� readlines� startswith�split�strip�append� Exception)�self�forbid_attributes�fpaths�cffile�lineZwords� r �</usr/lib/python3/dist-packages/sos/report/plugins/postfix.py�forbidden_ssl_keys_files sB �� &z Postfix.forbidden_ssl_keys_filesc C s d}g }d}t �d�}z�t| �d�ddd���}|�� D ]|}t �dd |�}|�|�}|d kr\q6|�d��� }||kr6|�d��� } t | �d kr�q6| � |�r�| t |�d � } |�| � q6W 5 Q R X W n< tk r� } zd| j d � �}| �|� W 5 d } ~ X Y nX |S )z% Get the list of password to exclude )Zlmtp_sasl_password_mapsZsmtp_sasl_password_mapsZpostscreen_dnsbl_reply_mapZsmtp_sasl_auth_cache_namezhash:z ^(.*)=(.*)r r r r z#.*� Nr � r zError parsing main.cf: )�re�compiler r r �sub�match�groupr �lenr r r �argsZ _log_error)r r r �prefixZ option_formatr r ZoptionZ attribute�filepath�err�msgr r r �forbidden_password_files; s4 � 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 �setupa s ���z Postfix.setupN) �__name__� __module__�__qualname__Z short_descZplugin_nameZprofiles�packagesr! r/ r2 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 � �� | �d� d S )Nz /etc/mail)�superr2 r0 r1 �� __class__r r r2 x s zRedHatPostfix.setup)r3 r4 r5 �filesr6 r2 � __classcell__r r r9 r r7 s s r7 c @ s e Zd ZdZdS )� DebianPostfixr N)r3 r4 r5 r6 r r r r r= } s r= ) r$ Zsos.report.pluginsr r r r r r7 r= r r r r �<module> s f
Save File
Cancel