[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@3.143.24.92: ~ $
�

=�Dg����ddlZddlZddlZddlZddlZddlmZm	Z	ddl
mZddlm
Z
ddlmZdZGd�de��ZGd	�d
��ZdS)�N)�base�	multipart)�
SysLogHandler)�Optional)�errorzAleksandr Shyshatskyc��eZdZdS)�MailSendFailedN)�__name__�
__module__�__qualname__���t/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib/python3.11/site-packages/clcommon/mail_helper.pyr	r	s�������Drr	c��eZdZdZd�Zddejdeefd�Z	ddeefd�Z
dedejfd	�Z
ddeefd
�ZdS)�
MailHelperz6Common class to send emails via local smtp or sendmailc���tjjs�tj�d��r�t
dtj���}tj�|��tj	d���}|�
|��|�tj��ntj
��tj��|_dS)Nz/dev/log)�address�facilityz3mail_helper: (%(name)s) [%(levelname)s] %(message)s)�fmt)�logging�root�handlers�os�path�existsr�
LOG_DAEMON�
addHandler�	Formatter�setFormatter�setLevel�ERROR�basicConfig�	getLogger�_log)�self�SYS_LOG�
formatter_syss   r�__init__zMailHelper.__init__s����|�$�	&��w�~�~�j�)�)�
&�'�
�]�E]�^�^�^����'�'��0�0�0� '� 1�6k� l� l� l�
��$�$�]�3�3�3�� � ���/�/�/�/��#�%�%�%��%�'�'��	�	�	rN�msg�
encoding_namec�&�	|r(|����|��}n|���}gd�}tj|tjtjtjd���5}|�|��d}|jdkrtj|j||���	ddd��dS#1swxYwYdS#ttjf$r"}tt|����|�d}~wwxYw)z�
        Alternative function that should be called
        when we cannot send email via smtp
        :type msg: email.mime.base.MIMEBase
        :type encoding_name: encoding name to encode message text
        )z/usr/sbin/sendmailz-tz-oiT)�stdin�stdout�stderr�textrN)�	as_string�encode�
subprocess�Popen�PIPE�communicate�
returncode�CalledProcessError�OSErrorr	�str)r%r)r*�	s_message�cmd�procr-�exs        r�_sendmail_consolezMailHelper._sendmail_console*sh��	2��
,��M�M�O�O�2�2�=�A�A�	�	��M�M�O�O�	�5�5�5�C��!�� �o�!��!������	
V���)�)�)�4�4�Q�7���?�a�'�'�$�7����f�U�U�U�(�	
V�	
V�	
V�	
V�	
V�	
V�	
V�	
V�	
V�	
V�	
V�	
V����	
V�	
V�	
V�	
V�	
V�	
V����6�7�	2�	2�	2� ��R���)�)�r�1�����	2���s=�A9C�;AC�>C�C�C�C�C�D�.D�Dc�x�	tjd��}|r(|����|��}n|���}|�|||��|���dS#tjtf$r"}tt|����|�d}~wwxYw)z�
        Send email using smtp protocol;
        :type from_addr: str
        :type to_addrs: List[str]
        :type msg: email.mime.base.MIMEBase
        :type encoding_name: encoding name to encode message text
        �	localhostN)
�smtplib�SMTPr0r1�sendmail�quit�
SMTPException�socketerrorr	r9)r%�	from_addr�to_addrsr)r*�
smtp_instancer:r=s        r�_sendmail_smtpzMailHelper._sendmail_smtpEs���		2�#�L��5�5�M��
,��M�M�O�O�2�2�=�A�A�	�	��M�M�O�O�	��"�"�9�h�	�B�B�B���� � � � � ���%�{�3�	2�	2�	2� ��R���)�)�r�1�����	2���s�A=B�B9�B4�4B9rGc���|ds_tj�|�d��d���|d<|j�d|d��dSdS)z{Add Message-ID to message if it is missing
        :type from_addr: str
        :type msg: multipart.MIMEMultipart
        z
Message-ID�@���)�domainzAdded Message-ID: %sN)�email�utils�
make_msgid�splitr$�debug)r%rGr)s   r�_add_message_idzMailHelper._add_message_idXso��
�<� �	G� %�� 6� 6�i�o�o�c�>R�>R�SU�>V� 6� W� W�C����I�O�O�2�C��4E�F�F�F�F�F�	G�	Grc���|j�d|||��|�||��	|�||||��dS#t$r�}|j�d��	|�|��nQ#t$rD|j�d��|j�t|����Yn
wxYwYd}~dSYd}~dSd}~wwxYw)a0
        Try to send message using local smtp;
        If that can't be done - try to use /usr/sbin/sendmail;
        :type from_addr: str
        :type to_addrs: List[str]
        :type msg: multipart.MIMEMultipart
        :type encoding_name: Optional[str] encoding name to encode message text
        z+Trying to send mail with params: %s, %s, %sz-Smtp send failed, trying to send via sendmailzcCannot send email neither via smtp nor using sendmail; Please, check your mail server configurationN)	r$rSrTrJr	r>�	exceptionrr9)r%rGrHr)r*�smtp_exceptions      rrCzMailHelper.sendmailas4��	
�	���E�y�RZ�\_�`�`�`����Y��,�,�,�		5����	�8�S�-�H�H�H�H�H���	5�	5�	5��I�O�O�K�L�L�L�
5��&�&�s�+�+�+�+��!�
5�
5�
5��	�#�#�%S�T�T�T��	����N� 3� 3�4�4�4�4�4�
5����,�+�+�+�+�+�5�4�4�4�4�4�����	5���s<�A�
C,�C'�4B
�	C'�
AC�C'�C�C'�'C,)N)r
rr�__doc__r(�	mime_base�MIMEBaserr9r>rJr�
MIMEMultipartrTrCr
rrrrs�������@�@�
(�
(�
(�2�2�Y�%7�2��QT�
�2�2�2�2�62�2�h�s�m�2�2�2�2�&G��G�9�3J�G�G�G�G�5�5���
�5�5�5�5�5�5rr)�email.utilsrOrrrAr2�
email.mimerrYr�logging.handlersr�typingr�_socketrrF�
__author__�	Exceptionr	rr
rr�<module>rcs�����������	�	�	�	���������3�3�3�3�3�3�3�3�*�*�*�*�*�*�������(�(�(�(�(�(�
#�
�	�	�	�	�	�Y�	�	�	�Z5�Z5�Z5�Z5�Z5�Z5�Z5�Z5�Z5�Z5r

Filemanager

Name Type Size Permission Actions
__init__.cpython-311.pyc File 1.54 KB 0644
clcagefs.cpython-311.pyc File 15.5 KB 0644
clcaptain.cpython-311.pyc File 4.31 KB 0644
clconfig.cpython-311.pyc File 3.19 KB 0644
clconfpars.cpython-311.pyc File 16.37 KB 0644
clcustomscript.cpython-311.pyc File 1.85 KB 0644
cldebug.cpython-311.pyc File 1.29 KB 0644
clemail.cpython-311.pyc File 2.42 KB 0644
clexception.cpython-311.pyc File 1.7 KB 0644
clfunc.cpython-311.pyc File 11.95 KB 0644
clhook.cpython-311.pyc File 6.16 KB 0644
cllog.cpython-311.pyc File 2.78 KB 0644
cloutput.cpython-311.pyc File 846 B 0644
clproc.cpython-311.pyc File 8.93 KB 0644
clpwd.cpython-311.pyc File 11.97 KB 0644
clquota.cpython-311.pyc File 1.79 KB 0644
clsec.cpython-311.pyc File 1.55 KB 0644
clwpos_lib.cpython-311.pyc File 20.95 KB 0644
const.cpython-311.pyc File 293 B 0644
evr_utils.cpython-311.pyc File 5.06 KB 0644
features.cpython-311.pyc File 6.08 KB 0644
group_info_reader.cpython-311.pyc File 6.46 KB 0644
lock.cpython-311.pyc File 1.97 KB 0644
mail_helper.cpython-311.pyc File 7.2 KB 0644
mysql_lib.cpython-311.pyc File 10.01 KB 0644
php_conf_reader.cpython-311.pyc File 11.29 KB 0644
sysctl.cpython-311.pyc File 10.42 KB 0644
ui_config.cpython-311.pyc File 4.69 KB 0644
utils.cpython-311.pyc File 40.28 KB 0644
utils_cmd.cpython-311.pyc File 4.19 KB 0644