HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/twisted/mail/scripts/__pycache__/mailmail.cpython-38.pyc
U

��W[U)�@sBdZddlmZddlZddlZddlZddlZzddlm	Z	Wn e
k
r`ddl	m	Z	YnXddlmZddl
mZddlmZmZddlmZdd	lmZd
Zej�d�ZdZd
Zeej�Zeed�ZGdd�d�Zdd�Z e!d�Z"dd�Z#Gdd�d�Z$dd�Z%dd�Z&da'dd�Z(dd�Z)d d!�Z*d"d#�Z+d$d%�Z,dS)&z4
Implementation module for the I{mailmail} command.
�)�print_functionN)�ConfigParser)�version)�reactor)�Logger�textFileLogObserver)�smtp)�NativeStringIOz
/etc/mailmailz~/.twisted/mailmailz	127.0.0.1z�Subject: Failed Message Delivery

  Message delivery failed.  The following occurred:

  %s
--
The Twisted sendmail application.
)Zobserverc@seZdZdZdS)�Optionsat
    Store the values of the parsed command-line options to the I{mailmail}
    script.

    @type to: L{list} of L{str}
    @ivar to: The addresses to which to deliver this message.

    @type sender: L{str}
    @ivar sender: The address from which this message is being sent.

    @type body: C{file}
    @ivar body: The object from which the message is to be read.
    N)�__name__�
__module__�__qualname__�__doc__�rr�?/usr/lib/python3/dist-packages/twisted/mail/scripts/mailmail.pyr
/sr
cCs$z
t��WSt��YSXdS�N)�os�getlogin�getpassZgetuserrrrrr@s
rzUnsupported option.c	Cs�t�}dd�|D�|_t�|_d|kr6tdt�t��d|krBt�d|krNt�d|krx||�d�d|_|j�	|j�d	|ks�d
|kr�t�d|kr�d|_
nd
|_
d|kr�d
|_
nd|_
d|ks�d|kr�d|_nd
|_d|kr�t�d|k�rd|_|j|_
g|_nd
|_g|_gggggd�}t�}d}tj��}|���s@�q�|�dd�}|d��}|j�r�|dk�r�|j�tj�|d�dg�|dk�r�d}n |dk�r�tj�|d�d|_||k�r�||�|d�|�r$|�|��q$|d�s|�d�|j��|d�s6|j�std��|�d�d�|j���|d�sT|�d�t����|�|�|j�r�|j
D]$}z|j�	|�WnYnX�ql|� dd�t|�!�tj�"��|_#|S) NcSsg|]}|�d�s|�qS)�-)�
startswith)�.0�errr�
<listcomp>Ms
z parseOptions.<locals>.<listcomp>z	--versionzmailmail version:z-bpz-bsz-F�z-iz-oiz-odbTFz-odfz-oepz-epz-omz-t)�from�to�cc�bcc�datez: r)rrrrrz
From: {}
rzNo recipients specified.zTo: {}
z, rz
Date: {}
)$r
rr�sender�printr�
SystemExit�_unsupportedOption�index�removeZ
background�printErrorsZrecipientsFromHeadersZexcludeAddressesZexludeAddressesr	�sys�stdin�readline�strip�split�lower�extend�emailZutilsZ	parseaddr�append�write�format�joinrZ
rfc822date�seek�getvalue�read�body)	�argv�oZrequiredHeaders�bufferr0�lineZhdrsZhdr�arrr�parseOptionsKs�

�

�








r<c@seZdZdZdd�ZdS)�
Configurationa�

    @ivar allowUIDs: A list of UIDs which are allowed to send mail.
    @ivar allowGIDs: A list of GIDs which are allowed to send mail.
    @ivar denyUIDs: A list of UIDs which are not allowed to send mail.
    @ivar denyGIDs: A list of GIDs which are not allowed to send mail.

    @type defaultAccess: L{bool}
    @ivar defaultAccess: L{True} if access will be allowed when no other access
    control rule matches or L{False} if it will be denied in that case.

    @ivar useraccess: Either C{'allow'} to check C{allowUID} first
    or C{'deny'} to check C{denyUID} first.

    @ivar groupaccess: Either C{'allow'} to check C{allowGID} first or
    C{'deny'} to check C{denyGID} first.

    @ivar identities: A L{dict} mapping hostnames to credentials to use when
    sending mail to that host.

    @ivar smarthost: L{None} or a hostname through which all outgoing mail will
    be sent.

    @ivar domain: L{None} or the hostname with which to identify ourselves when
    connecting to an MTA.
    cCs@g|_g|_g|_g|_d|_d|_i|_d|_d|_d|_	dS)N�denyT)
�	allowUIDs�denyUIDs�	allowGIDs�denyGIDs�
useraccess�groupaccess�
identities�	smarthost�domain�
defaultAccess)�selfrrr�__init__�szConfiguration.__init__N)rrr
rrJrrrrr=�sr=cCs�t�}t�|tj�s|St�}|�|�|j}|j}|j}|j	}d||fd||ffD]�\}}}	|�
|�rTd|fd|	ffD]~\}
}|�||
�rx|�||
�rx|�||
��
d�D]J}zt|�}Wn.tk
r�tjd|d��||d�Yq�X|�|�q�qx|�|d	�}
d
d�dd�|
�
d�D�D�}
|
ddk�r>t||d�qTt||d�qT|�
d
��r�|�d
�D]@\}}|�
dd�}t|�dk�r�tjd|d��qb||j|<�qb|�
d��r�|�dd��r�|�dd�|_|�dd��r�|�dd�|_|S)NrCrDZallowr>�,z6Illegal {prefix}ID in [{section}] section: {sectionID}r)�prefix�section�	sectionID�ordercSsg|]}|���qSr)r+�r�srrrrs�zloadConfig.<locals>.<listcomp>cSsg|]}|���qSr)r,rPrrrr s�Zidentity�:r�z.Illegal entry in [identity] section: {section})rMZ	addressesrFZdefault_domain)r=r�access�R_OKrr5r?r@rArBZhas_sectionZ
has_option�getr+�int�
ValueError�_log�error�upperr/�setattr�items�lenrErFrG)�path�c�pZauZduZagZdgrMr;�d�mode�LrNrO�hostZup�partsrrr�
loadConfig�s`


����rgcCst��dSr�r�stop)�resultrrr�success:srkcCst��|adSr)rri�failed)�frrr�failure@srncCs.t�||j|j|j�}|�tt�t�	�dSr)
r�sendmailr rr6ZaddCallbacksrkrnr�run)re�options�identrbrrrroGsrocCsf|jg}d�tjdtj�d��}t�}|j|d�tt	|�
��}t�d|||�}|�dd��dS)Nz2"Internally Generated Message ({})"<postmaster@{}>r�ascii��fileZ	localhostcSst��Srrh)�_rrr�<lambda>V�zsenderror.<locals>.<lambda>)
r r1r'r7r�DNSNAME�decoder	�printTraceback�	ERROR_FMTr4roZaddBoth)rnrqZ	recipientr rZr6rbrrr�	senderrorNs
�r}cCs�t��}t��}|jdkr8||jkr(dS||jkrTdSn||jkrFdS||jkrTdS|jdkr|||jkrldS||jkr�dSn||jkr�dS||jkr�dS|j	S)Nr>TF)
r�getuid�getgidrCr@r?rDrBrArH)�confZuid�gidrrrr>Zs*









r>cCs�ttjdd��}tt�}tt�}t|�s2t|�r@t�d�dS|j	pN|j	pNt
}|j��}|�
|j�|jrv|jt_n|jr�|jt_t|||�tr�|jr�tjtjd�td��n
tt|�dS)NrzPermission deniedrt)r<r'r7rg�
GLOBAL_CFG�	LOCAL_CFGr>rYrZrF�	SMARTHOSTrE�copy�updaterGrryrorlr&r{�stderrr"r})r8ZgConfZlConfrerrrrrrpxs&



rp)-rZ
__future__rZemail.utilsr.rr'r�configparserr�ImportErrorZtwisted.copyrightrZtwisted.internetrZtwisted.loggerrrZtwisted.mailrZtwisted.python.compatr	r�r_�
expanduserr�r�r|r�Z_logObserverrYr
rr"r#r<r=rgrkrlrnror}r>rprrrr�<module>sB


}+G