%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/states/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/states/user.pyo

�
���^c#@@s�dZddlmZmZmZddlZddlZddlZddl	Zddl
ZddlZddlm
Z
ddlmZmZeje�Zed�Zeeeeeeeeeeedddddeedddd	eeeeeeed
�Zeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed�"Zeed�ZdS(
u�
Management of user accounts
===========================

The user module is used to create and manage user settings, users can be set
as either absent or present

.. code-block:: yaml

    fred:
      user.present:
        - fullname: Fred Jones
        - shell: /bin/zsh
        - home: /home/fred
        - uid: 4000
        - gid: 4000
        - groups:
          - wheel
          - storage
          - games

    testuser:
      user.absent
i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionError(tstring_typest	iteritemscC@sIt|�}t|�}|r*||ksA|rE|j|�rEtStS(u4
    Determine if the groups need to be changed
    (tsettissubsettTruetFalse(tcurtwantedtremovetoldtnew((s4/usr/lib/python2.7/site-packages/salt/states/user.pyt_group_changes,s
)ui?Bic&"C@sxdtkrtd|�}ntd|�}|s9tSi} |d1krX|d}ntt|pgg|ppg��}!|r�|d|kr�|| d<n|d1k	r�|d|td|�fkr�|| d<ntd|d1k	r�|n|d�}"|"|dkr |dj|"�n||dkrP||!krP|dj|�n|"|!krl|!j|"�nt|d|!|�r�|!| d<n|r�|d|kr�|| d<n|r�|r�|n|d}#|#d1k	r�tjj	|#�r�|#| d	<q�n|r |d
|kr || d
<ndtkr�dtkr�|r�|
r�td�}$|d|$ksx|d|$kr�|	r�|d|kr�|| d<q�q�n|
r�|dd
kr�t
| d<n|d1k	r�|d|kr�|| d<n|d1k	r|d|kr|| d<n|d1k	r9|d|kr9|| d<n|d1k	rb|d|krb|| d<n|d1k	r�|d|kr�|| d<n|r|d|kr|| d<qnndtkrtjj
j�r|r|dk	rtjjj|d�tjjj|�kr|| d<qntjjj|�}tjjj|d�|d<|d1k	rz|d|krz|| d<n|r�|d|kr�|| d<n|r�|d|kr�|| d<n|r�|d|kr�|| d<n|r|d|kr|| d<nd tkrp|
d1k	rptjjj|
�}
tjjj|d!�|d!<|d!|
krp|
| d!<qpnd"tkr�|d1k	r�tjjj|�}tjjj|d#�|d#<|d#|kr�|| d#<q�nd$tkrD|d1k	rDtjjj|�}tjjj|d%�|d%<|d%|krD|| d%<qDnd&tkr�|d1k	r�tjjj|�}tjjj|d'�|d'<|d'|kr�|| d'<q�ntd(d2kr�|r�td+|�|kr�|| d,<q�q�ng}%|r&d| kr&|%jd-j|d|��n|rYd| krY|%jd.j|d|��n|%rttd/d0|%��n| S(3uU
    Return a dict of the changes required for a user if the user is present,
    otherwise return False.

    Updated in 2015.8.0 to include support for windows homedrive, profile,
    logonscript, and description fields.

    Updated in 2014.7.0 to include support for shadow attributes, all
    attributes supported as integers only.
    ushadow.infou	user.infougroupsuuidugidufile.group_to_gidufile.gid_to_groupuhomeuhomeDoesNotExistushellushadow.default_hashupasswduuempty_passwordulstchgudateuminumindaysumaxumaxdaysuinactu	inactdaysuwarnuwarndaysuexpirei����ufullnameu	homedriveuprofileulogonscriptudescriptionuuser.chroomnumberu
roomnumberuuser.chworkphoneu	workphoneuuser.chhomephoneu	homephoneuuser.chotheruotherukerneluOpenBSDuFreeBSDuuser.get_loginclassu
loginclassu�Changing uid ({0} -> {1}) not permitted, set allow_uid_change to True to force this change. Note that this will not change file ownership.u�Changing gid ({0} -> {1}) not permitted, set allow_gid_change to True to force this change. Note that this will not change file ownership.u-Encountered error checking for needed changestinfoN(uOpenBSDuFreeBSD(t__salt__R	tNonetsortedRRRtostpathtisdirRtsalttutilstplatformt
is_windowst	dateutilststrftimetdatatdecodet
__grains__tappendtformatR(&tnametuidtgidtgroupstoptional_groupst
remove_groupsthomet
createhometpasswordtenforce_passwordtempty_passwordtshelltfullnamet
roomnumbert	workphonet	homephonetothert
loginclasstdatetmindaystmaxdayst	inactdaystwarndaystexpiret
win_homedrivetwin_profiletwin_logonscripttwin_descriptiontallow_uid_changetallow_gid_changetlshadtlusrtchanget
wanted_groupstdefault_grptnewhometdefault_hashterrors((s4/usr/lib/python2.7/site-packages/salt/states/user.pyt_changes7s�)
"
,











@




c#:%C@s�|	r�|
r�tjd�idd6dd6dd6dd	6}#y�td
|�djdd
�\}$}%}&}'|%dkr�tjd�ntjdj|#j|%���td|	d|&d|#j|%��}	Wq�tk
r�tjd�td|	�}	q�Xn|dzk	r#t
jjj
|�}n|dzk	rGt
jjj
|�}n|dzk	rkt
jjj
|�}n|dzk	r�t
jjj
|�}n|dzk	r�t
jjj
|�}ntdd{kr�t}ni|d6id6td6dj|�d6}(xS|||gD]B})t|)t�rd|)krdj|)�|(d<t|(d<|(SqW|r�g|D]}*td|*�sZ|*^qZ}+|+r�djdj|+��|(d<t|(d<|(Sn|r$g|D]}*td|*�r�|*^q�},xIg|D]}*|*|,kr�|*^q�D]}-tjd |-|�qWndz},|rl|rlx3t|�j|�D]}.tjd!|.|�qLWn|r�td"|�}|d#kr�d$j|�|(d<t|(d<|(Snygt|||||,||||	|||
|||||||||||||||||!|"�}/Wn+tk
rF}0t|(d<|0j|(d<|(SX|/r<
td%r�dz|(d<d&|(d<xgt|/�D]Y\}1}2|1dkr�d'}2n|1d(kr�|r�d)}1n|(dcd*j|1|2�7<qxW|(Sd
tkr�td
|�}3ntdd|krtd-|�}4ntd.|�}5x&t|/�D]\}1}2|1dkrn|rntd/||	�q8n|1dkr�|r�tjd0�q8n|1d1kr�|2r�td2|�q8n|1d3kr�td4||�q8n|1d5kr5d6|/kr5tdd}krtd7||2�q8td7||2d8t�q8n|1d6kr�tdd~kretd7||2�ntd7||2d8t�tjj|2�s8td9|2|5d:|5d;d<�q8q8n|1d=kr�td>||�q8n|1d?kr�td@||�q8n|1dAkrtdB||�q8n|1dCkrBtdD||�q8n|1dEkretdF||�q8n|1dGkr�tdHdI|dJ|2�q8n|1dKkr�tdHdI|dL|2�q8n|1dMkr�tdHdI|dN|2�q8n|1dOkr	tdHdI|dP|2�q8n|1dQkr6tdRj|1�||2|�q8tdRj|1�||2�q8Wtd.|�}6i}7d
tkr�|3d|	kr�td
|�}7ntddkr�td-|�}8nx7|6D]/}1|6|1|5|1kr�|6|1|(d|1<q�q�Wd
tkr\	xW|7D]L}1|3|1|7|1kr		|1dkr@	d'|(d|1<qU	|7|1|(d|1<q		q		Wntdd�kr�	|8|4kr�	|8|(ddS<n|(dr�	dTj|�|(d<nt|||||,||||	|||
||||||||||||||||dUtdVt�}/|/r8
dWj|/�|(d<t|(d<n|(S|/tkr�td%rs
dz|(d<dXj|�|(d<|(S|r�
|,r�
|j|,�n|,r�
|,}nt
jjj �s*i|d6|d:6|d;6|dQ6|d56|
dY6|dZ6|d[6|d\6|d]6|d^6|d_6|d`6|da6| db6|dS6}9nEi	|d6|	dc6|d\6|dd6|dQ6|d56|de6|df6|dg6}9tdh|9�r�dij|�|(d<td.|�|(d<|s�d#|(dd5<nd
tkrXt
jjj �rXt
jjj!�rX|	ra|ratd/||	�td
|�}7|7d|	krPdjj|d'�|(d<t|(d<nd'|(ddc<n|r�|	r�td2|�td
|�}7|7dd#kr�dkj|�|(d<t|(d<nd#|(ddc<n|dzk	r>
td4||�td
|�}7|7dl|kr-
dmj||�|(d<t|(d<n||(dd3<n|r�
td>||�td
|�}7|7dn|kr�
doj||�|(d<t|(d<n||(dd=<n|rtd@||�td
|�}7|7dp|krdqj||�|(d<t|(d<n||(dd?<n|rtdB||�td
|�}7|7dr|krndsj||�|(d<t|(d<n||(ddA<n|r�tdD||�td
|�}7|7dt|kr�duj||�|(d<t|(d<n||(ddC<n|r�tdF||�td
|�}7|7dE|krDdvj||�|(d<t|(d<n||(ddE<q�q�t
jjj �rN|	r�|r�tdw||	�s�djj|d'�|(d<t|(d<nd'|(dd<n|r�tdF||�td
|�}7t
jj"j#|7dE�t
jj"j#|�kr6dvj||�|(d<t|(d<n|7dE|(ddx<q�q�t
jjj!�r�|	r�|r�td/||	�s�djj|d'�|(d<t|(d<nd'|(dd<q�q�dyj|�|(d<t|(d<n|(S(�u
    Ensure that the named user is present with the specified properties

    name
        The name of the user to manage

    uid
        The user id to assign. If not specified, and the user does not exist,
        then the next available uid will be assigned.

    gid
        The id of the default group to assign to the user. Either a group name
        or gid can be used. If not specified, and the user does not exist, then
        he next available gid will be assigned.

    gid_from_name : False
        If ``True``, the default group id will be set to the id of the group
        with the same name as the user. If the group does not exist the state
        will fail.

    allow_uid_change : False
        Set to ``True`` to allow the state to update the uid.

        .. versionadded:: 2018.3.1

    allow_gid_change : False
        Set to ``True`` to allow the state to update the gid.

        .. versionadded:: 2018.3.1

    groups
        A list of groups to assign the user to, pass a list object. If a group
        specified here does not exist on the minion, the state will fail.
        If set to the empty list, the user will be removed from all groups
        except the default group. If unset, salt will assume current groups
        are still wanted (see issue #28706).

    optional_groups
        A list of groups to assign the user to, pass a list object. If a group
        specified here does not exist on the minion, the state will silently
        ignore it.

    NOTE: If the same group is specified in both "groups" and
    "optional_groups", then it will be assumed to be required and not optional.

    remove_groups
        Remove groups that the user is a member of that weren't specified in
        the state, Default is ``True``.

    home
        The custom login directory of user. Uses default value of underlying
        system if not set. Notice that this directory does not have to exist.
        This also the location of the home directory to create if createhome is
        set to True.

    createhome : True
        If set to ``False``, the home directory will not be created if it
        doesn't already exist.

        .. warning::
            Not supported on Windows or Mac OS.

            Additionally, parent directories will *not* be created. The parent
            directory for ``home`` must already exist.

    nologinit : False
        If set to ``True``, it will not add the user to lastlog and faillog
        databases.

        .. note::
            Not supported on Windows or Mac OS.

    password
        A password hash to set for the user. This field is only supported on
        Linux, FreeBSD, NetBSD, OpenBSD, and Solaris. If the ``empty_password``
        argument is set to ``True`` then ``password`` is ignored.
        For Windows this is the plain text password.
        For Linux, the hash can be generated with ``openssl passwd -1``.

    .. versionchanged:: 0.16.0
       BSD support added.

    hash_password
        Set to True to hash the clear text password. Default is ``False``.


    enforce_password
        Set to False to keep the password from being changed if it has already
        been set and the password hash differs from what is specified in the
        "password" field. This option will be ignored if "password" is not
        specified, Default is ``True``.

    empty_password
        Set to True to enable password-less login for user, Default is ``False``.

    shell
        The login shell, defaults to the system default shell

    unique
        Require a unique UID, Default is ``True``.

    system
        Choose UID in the range of FIRST_SYSTEM_UID and LAST_SYSTEM_UID, Default is
        ``False``.

    loginclass
        The login class, defaults to empty
        (BSD only)

    User comment field (GECOS) support (currently Linux, BSD, and MacOS
    only):

    The below values should be specified as strings to avoid ambiguities when
    the values are loaded. (Especially the phone and room number fields which
    are likely to contain numeric data)

    fullname
        The user's full name

    roomnumber
        The user's room number (not supported in MacOS)

    workphone
        The user's work phone number (not supported in MacOS)

    homephone
        The user's home phone number (not supported in MacOS)

    other
        The user's other attribute (not supported in MacOS)
        If GECOS field contains more than 4 commas, this field will have the rest of 'em

    .. versionchanged:: 2014.7.0
       Shadow attribute support added.

    Shadow attributes support (currently Linux only):

    The below values should be specified as integers.

    date
        Date of last change of password, represented in days since epoch
        (January 1, 1970).

    mindays
        The minimum number of days between password changes.

    maxdays
        The maximum number of days between password changes.

    inactdays
        The number of days after a password expires before an account is
        locked.

    warndays
        Number of days prior to maxdays to warn users.

    expire
        Date that account expires, represented in days since epoch (January 1,
        1970).

    The below parameters apply to windows only:

    win_homedrive (Windows Only)
        The drive letter to use for the home directory. If not specified the
        home directory will be a unc path. Otherwise the home directory will be
        mapped to the specified drive. Must be a letter followed by a colon.
        Because of the colon, the value must be surrounded by single quotes. ie:
        - win_homedrive: 'U:

        .. versionchanged:: 2015.8.0

    win_profile (Windows Only)
        The custom profile directory of the user. Uses default value of
        underlying system if not set.

        .. versionchanged:: 2015.8.0

    win_logonscript (Windows Only)
        The full path to the logon script to run when the user logs in.

        .. versionchanged:: 2015.8.0

    win_description (Windows Only)
        A brief description of the purpose of the users account.

        .. versionchanged:: 2015.8.0
    uHashing a clear text passwordumd5u1ublowfishu2ausha256u5usha512u6ushadow.infoupasswdu$iu7Using MD5 for hashing passwords is considered insecure!u;Re-using existing shadow salt for hashing password using {}ushadow.gen_passwordt
crypt_saltt	algorithmuINo existing shadow salt found, defaulting to a randomly generated new oneukerneluDarwinuWindowsunameuchangesuresultu"User {0} is present and up to dateucommentu,uUnsupported char ',' in {0}u
group.infou+The following group(s) are not present: {0}u0Optional group "%s" for user "%s" is not presentuCGroup "%s" specified in both groups and optional_groups for user %sufile.group_to_giduu,Default group with name "{0}" is not presentutestu5The following user attributes are set to be changed:
uXXX-REDACTED-XXXugroupu
ensure groupsu	{0}: {1}
uOpenBSDuFreeBSDuuser.get_loginclassu	user.infoushadow.set_passwordu0No password will be set when empty_password=Trueuempty_passwordushadow.del_passwordudateushadow.set_dateuhomeuhomeDoesNotExistuuser.chhometpersistu
file.mkdiruuidugidi�umindaysushadow.set_mindaysumaxdaysushadow.set_maxdaysu	inactdaysushadow.set_inactdaysuwarndaysushadow.set_warndaysuexpireushadow.set_expireu
win_homedriveuuser.updateR"t	homedriveuwin_profiletprofileuwin_logonscripttlogonscriptuwin_descriptiontdescriptionugroupsu
user.ch{0}u
loginclassuUpdated user {0}R>R?u&These values could not be changed: {0}uUser {0} set to be addedushelluuniqueusystemufullnameu
roomnumberu	workphoneu	homephoneuotheru
createhomeu	nologinitupasswordudescriptionu	homedriveuprofileulogonscriptuuser.adduNew user {0} createdu2User {0} created but failed to set password to {1}u-User {0} created but failed to empty passwordulstchgu:User {0} created but failed to set last change date to {1}uminu6User {0} created but failed to set minimum days to {1}umaxu6User {0} created but failed to set maximum days to {1}uinactu7User {0} created but failed to set inactive days to {1}uwarnu3User {0} created but failed to set warn days to {1}u5User {0} created but failed to set expire days to {1}uuser.setpassworduexpiration_dateuFailed to create new user {0}N(uDarwinuWindows(uOpenBSDuFreeBSD(uDarwinuWindows(uDarwinuWindows(uOpenBSDuFreeBSD(uOpenBSDuFreeBSD($tlogtdebugRtsplittwarningR!tgett
ValueErrorRRRRRRRR	Rt
isinstanceRtjoinRtintersectionRHRtstrerrort__opts__RRRRtextendRRt	is_darwinRR(:R"R#R$t
gid_from_nameR%R&R'R(R)R*t
hash_passwordR+R,R-tuniquetsystemR.R/R0R1R2R3R4R5R6R7R8R9R:R;R<R=t	nologinitR>R?t
algorithmst_talgotshadow_salttshadow_hashtrettgecos_fieldtxtmissing_groupstpresent_optgroupstmissing_optgrouptisectedtchangestexctkeytvalR@tlcpretpretposttsposttlcposttparams((s4/usr/lib/python2.7/site-packages/salt/states/user.pytpresent�s��

,)

	

)








		 
"


	





















.


cC@sci|d6id6td6dd6}td|�}|rLtdrcd|d<dj|�|d<|Sttjjj	|��}td	|||�|d<tg|D]}td
|�r�|^q��}|dr+i|d<x)||D]}d|ddj|�<q�Wd|d|<d
j|�|d<nt
|d<dj|�|d<|Sdj|�|d<|S(u�
    Ensure that the named user is absent

    name
        The name of the user to remove

    purge
        Set purge to True to delete all of the user's files as well as the user,
        Default is ``False``.

    force
        If the user is logged in, the absent state will fail. Set the force
        option to True to remove the user even if they are logged in. Not
        supported in FreeBSD and Solaris, Default is ``False``.
    unameuchangesuresultuucommentu	user.infoutestuUser {0} set for removaluuser.deleteu
group.infouremovedu	{0} groupuRemoved user {0}uFailed to remove user {0}uUser {0} is not presentN(RRRZRR!RRRtusertget_group_listR	(R"tpurgetforceRgRAtbeforegroupstgtaftergroups((s4/usr/lib/python2.7/site-packages/salt/states/user.pytabsentcs0



/


(t__doc__t
__future__RRRRtloggingtsalt.utils.dataRtsalt.utils.dateutilstsalt.utils.platformtsalt.utils.usertsalt.exceptionsRtsalt.ext.sixRRt	getLoggert__name__RPR	RRRRHRxR�(((s4/usr/lib/python2.7/site-packages/salt/states/user.pyt<module>s����b

Zerion Mini Shell 1.0