%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/shadow.pyc

�
���^c@@sfdZddlmZmZmZddlZddlZyddlZWnek
r]nXddl	Z
ddlZ
ddlZ
ddl
mZddlmZyddlZ
eZWnek
r�eZnXd�Zd�Zd�Zd	�Zd
�Zd�Zddd
�Zd�Zd�Zd�Zed�Z d�Z!d�Z"d�Z#d�Z$dS(u,
Manage the shadow file on Linux systems

.. important::
    If you feel that Salt should be using this module to manage passwords on a
    minion, and it is using a different module (or gives an error similar to
    *'shadow.info' is not available*), see :ref:`here
    <module-provider-override>`.
i(tabsolute_importtunicode_literalstprint_functionN(tCommandExecutionError(tsixcC@stjdd�dkS(NukerneluuLinux(t
__grains__tget(((s7/usr/lib/python2.7/site-packages/salt/modules/shadow.pyt__virtual__"scC@sdS(u�
    Returns the default hash used for unset passwords

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.default_hash
    u!((((s7/usr/lib/python2.7/site-packages/salt/modules/shadow.pytdefault_hash&s
cC@s�yitj|�}i|jd6|jd6|jd6|jd6|jd6|jd6|jd6|j	d6}WnJt
k
r�id	d6d	d6d	d6d	d6d	d6d	d6d	d6d	d6SX|S(
u�
    Return information for the specified user

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.info root
    unameupasswdulstchguminumaxuwarnuinactuexpireu(tspwdtgetspnamtsp_namtsp_pwdt	sp_lstchgtsp_mintsp_maxtsp_warntsp_inactt	sp_expiretKeyError(tnametdatatret((s7/usr/lib/python2.7/site-packages/salt/modules/shadow.pytinfo3s,








	cC@sxt|�}||dkr tSdj||�}td|dt�t|�}|d|dkrt|d|kStS(u�
    Set the number of days of inactivity after a password has expired before
    the account is locked. See man chage.

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.set_inactdays username 7
    uinactuchage -I {0} {1}ucmd.runtpython_shell(RtTruetformatt__salt__tFalse(Rt	inactdaystpre_infotcmdt	post_info((s7/usr/lib/python2.7/site-packages/salt/modules/shadow.pyt
set_inactdaysUscC@sxt|�}||dkr tSdj||�}td|dt�t|�}|d|dkrt|d|kStS(u�
    Set the maximum number of days during which a password is valid.
    See man chage.

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.set_maxdays username 90
    umaxuchage -M {0} {1}ucmd.runR(RRRRR(RtmaxdaysRRR ((s7/usr/lib/python2.7/site-packages/salt/modules/shadow.pytset_maxdayskscC@sxt|�}||dkr tSdj||�}td|dt�t|�}|d|dkrt|d|kStS(u�
    Set the minimum number of days between password changes. See man chage.

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.set_mindays username 7
    uminuchage -m {0} {1}ucmd.runR(RRRRR(RtmindaysRRR ((s7/usr/lib/python2.7/site-packages/salt/modules/shadow.pytset_mindays�s
usha512cC@s.tstd��ntjjj|||�S(uX
    .. versionadded:: 2014.7.0

    Generate hashed password

    .. note::

        When called this function is called directly via remote-execution,
        the password argument may be displayed in the system's process list.
        This may be a security risk on certain systems.

    password
        Plaintext password to be hashed.

    crypt_salt
        Crpytographic salt. If not given, a random 8-character salt will be
        generated.

    algorithm
        The following hash algorithms are supported:

        * md5
        * blowfish (not in mainline glibc, only available in distros that add it)
        * sha256
        * sha512 (default)

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.gen_password 'I_am_password'
        salt '*' shadow.gen_password 'I_am_password' crypt_salt='I_am_salt' algorithm=sha256
    ujgen_password is not available on this operating system because the "crypt" python module is not available.(t	HAS_CRYPTRtsalttutilstpycryptotgen_hash(tpasswordt
crypt_saltt	algorithm((s7/usr/lib/python2.7/site-packages/salt/modules/shadow.pytgen_password�s"cC@sNdj|�}td|dtdd�t|�}|doM|d|kS(u�
    .. versionadded:: 2014.7.0

    Delete the password from name user

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.del_password username
    u
passwd -d {0}ucmd.runRtoutput_logleveluquietupasswduname(RRRR(RRtuinfo((s7/usr/lib/python2.7/site-packages/salt/modules/shadow.pytdel_password�scC@swt|�}|ddkr tS|djd�r7tSdj|�}td|dt�t|�}|djd�S(u�
    .. versionadded:: 2016.11.0

    Lock the password from specified user

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.lock_password username
    unameuupasswdu!u
passwd -l {0}ucmd.runR(RRt
startswithRRR(RRRR ((s7/usr/lib/python2.7/site-packages/salt/modules/shadow.pyt
lock_password�scC@syt|�}|ddkr tS|dddkr8tSdj|�}td|dt�t|�}|dddkS(	u�
    .. versionadded:: 2016.11.0

    Unlock the password from name user

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.unlock_password username
    unameuupasswdiu!u
passwd -u {0}ucmd.runR(RRRRR(RRRR ((s7/usr/lib/python2.7/site-packages/salt/modules/shadow.pytunlock_password�sc

C@s�tjjj|�s�tddkr7dj|�}nd}i}tjj|�sY|Sg}tjj	j
|d���}x�|D]�}tjjj|�}|j
�jd�}|d|kr�|j|�q�ntjj�tjdd	d	�}	||d	<tj|	j�|d
<dj|�}|jdj|��q�WWdQXtjj	j
|d
��<}g|D]}
tjjj|
�^qg}|j|�WdQXt|�}|d|kSdj||�}td|dtdd�t|�}|d|kSdS(u}
    Set the password for a named user. The password must be a properly defined
    hash. The password hash can be generated with this command:

    ``python -c "import crypt; print crypt.crypt('password',
    '\$6\$SALTsalt')"``

    ``SALTsalt`` is the 8-character crpytographic salt. Valid characters in the
    salt are ``.``, ``/``, and any alphanumeric character.

    Keep in mind that the $6 represents a sha512 hash, if your OS is using a
    different hashing algorithm this needs to be changed accordingly

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.set_password root '$1$UYCIxa628.9qXjpQCjM4a..'
    uosuALTu/etc/tcb/{0}/shadowu/etc/shadowurbu:ii�iiu{0}
Nuw+upasswduusermod -p {0} {1}ucmd.runRR/uquiet(R'R(Rtis_trueRRtostpathtisfiletfilestfopentstringutilst
to_unicodetstriptsplittappendtdatetimettodayRt	text_typetdaystjointto_strt
writelinesRRR(
RR+tuse_usermodts_fileRtlinestfp_tlinetcompstchanged_datet_lR0R((s7/usr/lib/python2.7/site-packages/salt/modules/shadow.pytset_passwords:

"
 (cC@sxt|�}||dkr tSdj||�}td|dt�t|�}|d|dkrt|d|kStS(u�
    Set the number of days of warning before a password change is required.
    See man chage.

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.set_warndays username 7
    uwarnuchage -W {0} {1}ucmd.runR(RRRRR(RtwarndaysRRR ((s7/usr/lib/python2.7/site-packages/salt/modules/shadow.pytset_warndays?scC@s,dd||g}td|dt�dkS(u�
    Sets the value for the date the password was last changed to days since the
    epoch (January 1, 1970). See man chage.

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.set_date username 0
    uchageu-ducmd.retcodeRi(RR(RtdateR((s7/usr/lib/python2.7/site-packages/salt/modules/shadow.pytset_dateUscC@s,dd||g}td|dt�dkS(u$
    .. versionchanged:: 2014.7.0

    Sets the value for the date the account expires as days since the epoch
    (January 1, 1970). Using a value of -1 will clear expiration. See man
    chage.

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.set_expire username -1
    uchageu-Eucmd.retcodeRi(RR(RtexpireR((s7/usr/lib/python2.7/site-packages/salt/modules/shadow.pyt
set_expiredscC@s&tgtj�D]}|j^q�S(u�
    .. versionadded:: 2018.3.0

    Return a list of all shadow users

    CLI Example:

    .. code-block:: bash

        salt '*' shadow.list_users
    (tsortedR	tgetspallR(tuser((s7/usr/lib/python2.7/site-packages/salt/modules/shadow.pyt
list_usersvs(%t__doc__t
__future__RRRR6R@R	tImportErrortsalt.utils.dataR'tsalt.utils.filestsalt.utils.stringutilstsalt.exceptionsRtsalt.extRtsalt.utils.pycryptoRR&RRRRR!R#R%tNoneR.R1R3R4RORQRSRURY(((s7/usr/lib/python2.7/site-packages/salt/modules/shadow.pyt<module>
s@



		
	"			*			9			

Zerion Mini Shell 1.0