관리-도구
편집 파일: postfix.cpython-39.opt-1.pyc
a -�_gI � @ 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)ZmailZservices�r c C s� g d�}g }z�t | �d�ddd��Z}|�� D ]@}|�d�r<q,|�d�}|d �� |v r,|�|d �� d � q,W d � n1 s�0 Y W n ty� Y n0 |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 � N)�open� path_join� readlines� startswith�split�strip�append� Exception)�self�forbid_attributes�fpaths�cffile�line�words� r �>/usr/lib/python3.9/site-packages/sos/report/plugins/postfix.py�forbidden_ssl_keys_files s � :z Postfix.forbidden_ssl_keys_filesc C s d}g }d}t �d�}z�t| �d�ddd���}|�� D ]|}t �dd |�}|�|�}|d u r\q6|�d��� }||v r6|�d��� } t | �d kr�q6| � |�r�| t |�d � } |�| � q6W d � n1 s�0 Y W n@ t�y } z&d| j d � �}| �|� W Y d } ~ n d } ~ 0 0 |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 �optionZ attribute�filepath�err�msgr r r �forbidden_password_files; s4 � . z Postfix.forbidden_password_filesc C sH | � dg� | �ddg� | �g d�� | �| �� � | �| �� � d S )Nz /etc/postfix/ZpostconfZmailq)z/etc/postfix/*.keyz/etc/postfix/*.crtz/etc/postfix/ssl/)� add_copy_specZadd_cmd_outputZadd_forbidden_pathr! r0 �r r r r �setupa s ��z Postfix.setupN) �__name__� __module__�__qualname__Z short_descZplugin_nameZprofiles�packagesr! r0 r3 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)�superr3 r1 r2 �� __class__r r r3 x s zRedHatPostfix.setup)r4 r5 r6 �filesr7 r3 � __classcell__r r r: r r8 s s r8 c @ s e Zd ZdZdS )� DebianPostfixr N)r4 r5 r6 r7 r r r r r>