%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/postfix.pyo

�
���^c	@@sDdZddlmZmZmZddlZddlZddlZddl	Zddl
ZddlmZej
d�Zeje�ZdZdZd�Zed	�Zed
�Zddddd
deed�Zd�Zed�Zed�Zed�Zed�Zd�Zd�Zd�Z d�Z!d�Z"dS(u�
Support for Postfix

This module is currently little more than a config file viewer and editor. It
is able to read the master.cf file (which is one style) and files in the style
of main.cf (which is a different style, that is used in multiple postfix
configuration files).

The design of this module is such that when files are edited, a minimum of
changes are made to them. Each file should look as if it has been edited by
hand; order, comments and whitespace are all preserved.
i(tabsolute_importtprint_functiontunicode_literalsN(tsixu^\su/etc/postfix/main.cfu/etc/postfix/master.cfcC@s#tjjjd�rtStdfS(u6
    Only load the module if Postfix is installed
    upostfixu;postfix execution module not loaded: postfix not installed.(tsalttutilstpathtwhichtTruetFalse(((s8/usr/lib/python2.7/site-packages/salt/modules/postfix.pyt__virtual__$sc	C@sHtjjj|d��"}tjjj|j��}WdQXg}i}x�|j�D]�}|j�s}|j�j	d�r�|j
|�qUn|j�j�}i|dd6|dd6|dd	6|d
d6|dd
6|dd6|dd6dj|d�d6}dj
|d|d�}|j
|�|||<qUW||fS(u
    Parse the master.cf file. This file is essentially a whitespace-delimited
    columnar file. The columns are: service, type, private (yes), unpriv (yes),
    chroot (yes), wakeup (never), maxproc (100), command + args.

    This function parses out the columns, leaving empty lines and comments
    intact. Where the value doesn't detract from the default, a dash (-) will
    be used.

    Returns a dict of the active config lines, and a list of the entire file,
    in order. These compliment each other.
    urNu#iuserviceiu	conn_typeiuprivateiuunpriviuchrootiuwakeupiumaxprocu iucommandu{0} {1}(RRtfilestfopentstringutilst
to_unicodetreadt
splitlineststript
startswithtappendtsplittjointformat(	Rtfh_t	full_conft	conf_listt	conf_dicttlinetcompst	conf_linetdict_key((s8/usr/lib/python2.7/site-packages/salt/modules/postfix.pyt
_parse_master-s,
!"

cC@st|�\}}|S(u|
    Return a dict of active config values. This does not include comments,
    spacing or order.

    The data returned from this function should not be used for direct
    modification of the main.cf file; other functions are available for that.

    CLI Examples:

        salt <minion> postfix.show_master
        salt <minion> postfix.show_master path=/path/to/master.cf
    (R(RRR((s8/usr/lib/python2.7/site-packages/salt/modules/postfix.pytshow_masterWs
uyunu100uc
	C@s�t|	�\}
}g}dj||�}
t||||||||�}xp|D]h}t|t�r�|d|kr�|d|kr�|j|�q�|jt|��qR|j|�qRW|
|
kr�|j|�n|r�t||	�ndj|�S(u�
    Set a single config value in the master.cf file. If the value does not
    already exist, it will be appended to the end.

    Because of shell parsing issues, '-' cannot be set as a value, as is normal
    in the master.cf file; either 'y', 'n' or a number should be used when
    calling this function from the command line. If the value used matches the
    default, it will internally be converted to a '-'. Calling this function
    from the Python API is not affected by this limitation

    The settings and their default values, in order, are: service (required),
    conn_type (required), private (y), unpriv (y), chroot (y), wakeup (n),
    maxproc (100), command (required).

    By default, this function will write out the changes to the master.cf file,
    and then returns the full contents of the file. By setting the
    ``write_conf`` option to ``False``, it will skip writing the file.

    CLI Example:

        salt <minion> postfix.set_master smtp inet n y n n 100 smtpd
    u{0} {1}userviceu	conn_typeu
(RRt_format_mastert
isinstancetdictRt_write_confR(tservicet	conn_typetprivatetunprivtchroottwakeuptmaxproctcommandt
write_confRRRtnew_confRtnew_lineR((s8/usr/lib/python2.7/site-packages/salt/modules/postfix.pyt
set_masterhs. 	
 c		C@s�|dkrd}n|dkr*d}n|dkr?d}n|dkrTd}ntj|�}|dkrxd}ndj||||||||�}|S(ua
    Format the given values into the style of line normally used in the
    master.cf file.
    uyu-unu100u4{0:9s} {1:5s} {2:7s} {3:7s} {4:7s} {5:7s} {6:7s} {7}(Rt	text_typeR(	R%R&R'R(R)R*R+R,R((s8/usr/lib/python2.7/site-packages/salt/modules/postfix.pyR!�s*						cC@sqtjjj|d��"}tjjj|j��}WdQXg}x�|j�D]�}|j�st|j	|�qOnt
jt|�r�|s�|j	|�qOnt
|dtj�s�d|d<ndj|d|g�|d<qO|j	|�qOWi}xk|D]c}|j�sqn|jd�r-qn|jd�}dj|d�j�||d	j�<qW||fS(
u�
    Parse files in the style of main.cf. This is not just a "name = value" file;
    there are other rules:

    * Comments start with #
    * Any whitespace at the beginning of a line denotes that that line is a
        continuation from the previous line.
    * The whitespace rule applies to comments.
    * Keys defined in the file may be referred to as variables further down in
        the file.
    urNi����uu
u#u=ii(RRRRR
RRRRRtretmatchtSWWSR"Rtstring_typesRRR(RRRRRtpairsR((s8/usr/lib/python2.7/site-packages/salt/modules/postfix.pyt_parse_main�s0!


 
+cC@st|�\}}|S(u�
    Return a dict of active config values. This does not include comments,
    spacing or order. Bear in mind that order is functionally important in the
    main.cf file, since keys can be referred to as variables. This means that
    the data returned from this function should not be used for direct
    modification of the main.cf file; other functions are available for that.

    CLI Examples:

        salt <minion> postfix.show_main
        salt <minion> postfix.show_main path=/path/to/main.cf
    (R7(RR6R((s8/usr/lib/python2.7/site-packages/salt/modules/postfix.pyt	show_mains
cC@s�t|�\}}g}tjdjtj|���}||kr�xk|D]A}tj||�r�|jdj||��qL|j|�qLWn|jdj||��|}t||�|S(u�
    Set a single config value in the main.cf file. If the value does not already
    exist, it will be appended to the end.

    CLI Example:

        salt <minion> postfix.set_main mailq_path /usr/bin/mailq
    u
^{0}([\s=]|$)u	{0} = {1}(R7R2tcompileRtescapeR3RR$(tkeytvalueRR6RR.tkey_line_matchR((s8/usr/lib/python2.7/site-packages/salt/modules/postfix.pytset_mains	!

cC@s�tjjj|d��o}xe|D]]}tjjj|�}t|t�re|jdj	|��n
|j|�|jd�q"WWdQXdS(u'
    Write out configuration file.
    uwu u
N(
RRRRR
tto_strR"R#twriteR(tconfRRR((s8/usr/lib/python2.7/site-packages/salt/modules/postfix.pyR$7s

cC@s?d}td|�j�}g}tjd�}tjd�}x�|D]�}tjd|�reqGntj||�r�tj||�}|jd�}|jd�}|jd�}	|jd	�}
qGtj||�r�tj||�}|jd
�}qG|sG|ji|d6|d6|	d6|
d	6|d
6�qGqGW|S(u{
    Show contents of the mail queue

    CLI Example:

    .. code-block:: bash

        salt '*' postfix.show_queue

    umailqucmd.runut(?P<queue_id>^[A-Z0-9]+)\s+(?P<size>\d+)\s(?P<timestamp>\w{3}\s\w{3}\s\d{1,2}\s\d{2}\:\d{2}\:\d{2})\s+(?P<sender>.+)u^\s+(?P<recipient>.+)u^[-|postqueue:|Mail]uqueue_idusizeu	timestampusenderu	recipient(t__salt__RR2R9R3tgroupR(tcmdtouttqueuet
queue_patterntrecipient_patternRtmtqueue_idtsizet	timestamptsendert	recipient((s8/usr/lib/python2.7/site-packages/salt/modules/postfix.pyt
show_queueEs(
7cC@s.idd6td6}|s*tjd�n|dks�t�}d}x'|D]}|d|krL|}qLqLW|s�dj|�|d<t|d<|Sndj|�}td	|�}|d
dkr�|dkr�d|d<q*d
j|�|d<n3|dkrd|d<ndj||d�|d<|S(u�
    Delete message(s) from the mail queue

    CLI Example:

    .. code-block:: bash

        salt '*' postfix.delete 5C33CA0DEA

        salt '*' postfix.delete ALL

    uumessageuresultuRequire argument queue_iduALLuqueue_iduNo message in queue with ID {0}upostsuper -d {0}ucmd.run_alluretcodeiu!Successfully removed all messagesu.Successfully removed message with queue id {0}uUnable to removed all messagesu/Unable to remove message with queue id {0}: {1}ustderrN(RtlogterrorROtNoneRR	RB(RJtretRFt_messagetitemRDtresult((s8/usr/lib/python2.7/site-packages/salt/modules/postfix.pytdeletehs0

	




cC@s.idd6td6}|s*tjd�n|dks�t�}d}x'|D]}|d|krL|}qLqLW|s�dj|�|d<t|d<|Sndj|�}td	|�}|d
dkr�|dkr�d|d<q*d
j|�|d<n3|dkrd|d<ndj||d�|d<|S(u�
    Put message(s) on hold from the mail queue

    CLI Example:

    .. code-block:: bash

        salt '*' postfix.hold 5C33CA0DEA

        salt '*' postfix.hold ALL

    uumessageuresultuRequire argument queue_iduALLuqueue_iduNo message in queue with ID {0}upostsuper -h {0}ucmd.run_alluretcodeiu(Successfully placed all messages on holdu5Successfully placed message on hold with queue id {0}u$Unable to place all messages on holdu6Unable to place message on hold with queue id {0}: {1}ustderrN(RRPRQRORRRR	RB(RJRSRFRTRURDRV((s8/usr/lib/python2.7/site-packages/salt/modules/postfix.pythold�s0

	




cC@s.idd6td6}|s*tjd�n|dks�t�}d}x'|D]}|d|krL|}qLqLW|s�dj|�|d<t|d<|Sndj|�}td	|�}|d
dkr�|dkr�d|d<q*d
j|�|d<n3|dkrd|d<ndj||d�|d<|S(u�
    Set held message(s) in the mail queue to unheld

    CLI Example:

    .. code-block:: bash

        salt '*' postfix.unhold 5C33CA0DEA

        salt '*' postfix.unhold ALL

    uumessageuresultuRequire argument queue_iduALLuqueue_iduNo message in queue with ID {0}upostsuper -H {0}ucmd.run_alluretcodeiu&Successfully set all message as unheldu4Successfully set message as unheld with queue id {0}u$Unable to set all message as unheld.u6Unable to set message as unheld with queue id {0}: {1}ustderrN(RRPRQRORRRR	RB(RJRSRFRTRURDRV((s8/usr/lib/python2.7/site-packages/salt/modules/postfix.pytunhold�s0

	




cC@s.idd6td6}|s*tjd�n|dks�t�}d}x'|D]}|d|krL|}qLqLW|s�dj|�|d<t|d<|Sndj|�}td	|�}|d
dkr�|dkr�d|d<q*d
j|�|d<n3|dkrd|d<ndj||d�|d<|S(u�
    Requeue message(s) in the mail queue

    CLI Example:

    .. code-block:: bash

        salt '*' postfix.requeue 5C33CA0DEA

        salt '*' postfix.requeue ALL

    uumessageuresultuRequired argument queue_iduALLuqueue_iduNo message in queue with ID {0}upostsuper -r {0}ucmd.run_alluretcodeiu"Successfully requeued all messagesu/Successfully requeued message with queue id {0}uUnable to requeue all messagesu0Unable to requeue message with queue id {0}: {1}ustderrN(RRPRQRORRRR	RB(RJRSRFRTRURDRV((s8/usr/lib/python2.7/site-packages/salt/modules/postfix.pytrequeue�s0

	




(#t__doc__t
__future__RRRR2tloggingtsalt.utils.filesRtsalt.utils.pathtsalt.utils.stringutilstsalt.extRR9R4t	getLoggert__name__RPtMAIN_CFt	MASTER_CFR
RR RR0R!R7R8R>R$RORWRXRYRZ(((s8/usr/lib/python2.7/site-packages/salt/modules/postfix.pyt<module>
s@		*;	/0	#	1	1	1

Zerion Mini Shell 1.0