%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c
@@s�dZddlmZmZmZddlZddlZyddlZeZ	Wne
k
rieZ	nXddlm
Z
ddlZddlZddlZddlmZeje�ZdZd�Zd�Zd	�Zd
�Zdddddeddddedd�Zeed
�Zed�Zd�Z d�Z!d�Z"ed�Z#ed�Z$d�Z%d�Z&d�Z'd�Z(dd�Z)d�Z*d�Z+d�Z,d�Z-d�Z.dS(u
Manage users with the pw command

.. important::
    If you feel that Salt should be using this module to manage users on a
    minion, and it is using a different module (or gives an error similar to
    *'user.info' is not available*), see :ref:`here
    <module-provider-override>`.
i(tabsolute_importtunicode_literalstprint_functionN(tsix(tCommandExecutionErroruusercC@s$trtddkrtStdfS(uC
    Set the user module if the kernel is FreeBSD or DragonFly
    ukerneluFreeBSDu	DragonFlyusThe pw_user execution module cannot be loaded: the pwd python module is not available or the system is not FreeBSD.(uFreeBSDu	DragonFly(tHAS_PWDt
__grains__t__virtualname__tFalse(((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pyt__virtual__=scC@s�y"tj|�jjdd�}Wn&tk
rJtdj|���nX|sUiSx#t|�dkrz|jd�qXWit	j
jj|d�d6t	j
jj|d�d	6t	j
jj|d
�d6t	j
jj|d�d6Sd
S(uD
    Retrieve GECOS field info and return it in dictionary form
    u,iuUser '{0}' does not existiuiufullnameiu
roomnumberiu	workphoneu	homephoneN(
tpwdtgetpwnamtpw_gecostsplittKeyErrorRtformattlentappendtsalttutilstdatatdecode(tnametgecos_field((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pyt
_get_gecosFs"
cC@sFdj|jdd�|jdd�|jdd�|jdd��S(u�
    Accepts a dictionary entry containing GECOS field names and their values,
    and returns a full GECOS comment string, to be used with pw usermod.
    u{0},{1},{2},{3}ufullnameuu
roomnumberu	workphoneu	homephone(Rtget(t
gecos_dict((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pyt_build_gecos\scC@s�t|tj�s$tj|�}nt|�}|s:tS|||krNtStj|�}|||<dd|dt	|�g}t
d|dt�t|�}t|�j|�|kS(u:
    Common code to change a user's GECOS information
    upwuusermodu-cucmd.runtpython_shell(
t
isinstanceRtstring_typest	text_typeRRtTruetcopytdeepcopyRt__salt__tinfoR(Rtkeytvaluetpre_infot
gecos_datatcmdt	post_info((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pyt
_update_gecosgs
uc
K@s�tjjj|
�}
tjjj|
jdt��rFtj	d�n|
r\tj	d�nt
|tj�r�|j
d�}nddg}|r�|jd|g�n|r�|jd|g�n|r�|jd	dj|�g�n|dk	r|jd
|g�n|tkr'|jd�n|rC|jd|g�n|r_|jd
|g�ntjjj|�s�|jd�nti|d6|d6|	d6|
d6�}|jd|g�|jd|g�td|dt�dkS(u�
    Add a user to the minion

    CLI Example:

    .. code-block:: bash

        salt '*' user.add name <uid> <gid> <groups> <home> <shell>
    usystemu5pw_user module does not support the 'system' argumentu!Invalid kwargs passed to user.addu,upwuuseraddu-uu-gu-Gu-du-mu-Lu-su-oufullnameu
roomnumberu	workphoneu	homephoneu-cu-nucmd.retcodeRiN(RRtargstclean_kwargsRtis_truetpopRtlogtwarningRRRR
textendtjointNoneR RRR#(Rtuidtgidtgroupsthometshelltuniquetfullnamet
roomnumbert	workphonet	homephonet
createhomet
loginclasstkwargsR)R((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pytaddzs>!

cC@sttjjj|�r%tjd�nddg}|rG|jd�n|jd|g�td|dt	�dkS(	u�
    Remove a user from the minion

    CLI Example:

    .. code-block:: bash

        salt '*' user.delete name remove=True force=True
    uGpw userdel does not support force-deleting user while user is logged inupwuuserdelu-ru-nucmd.retcodeRi(
RRRR.R0terrorRR2R#R(RtremovetforceR)((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pytdelete�s
cC@s\dtkr|rtdSg}x*tj�D]}|jt|j��q.W|td<|S(u}
    Return the list of all info for all users

    CLI Example:

    .. code-block:: bash

        salt '*' user.getent
    uuser.getent(t__context__R
tgetpwallRR$tpw_name(trefreshtretR((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pytgetent�s

cC@s�t|�}|s*tdj|���n||dkr>tSddd|d|g}td|dt�t|�jd�|kS(	u{
    Change the uid for a named user

    CLI Example:

    .. code-block:: bash

        salt '*' user.chuid foo 4376
    uUser '{0}' does not existuuidupwuusermodu-uu-nucmd.runR(R$RRR R#RR(RR5R'R)((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pytchuid�s
cC@s�t|�}|s*tdj|���n||dkr>tSddd|d|g}td|dt�t|�jd�|kS(	u�
    Change the default group of the user

    CLI Example:

    .. code-block:: bash

        salt '*' user.chgid foo 4376
    uUser '{0}' does not existugidupwuusermodu-gu-nucmd.runR(R$RRR R#RR(RR6R'R)((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pytchgid�s
cC@s�t|�}|s*tdj|���n||dkr>tSddd|d|g}td|dt�t|�jd�|kS(	u�
    Change the default shell of the user

    CLI Example:

    .. code-block:: bash

        salt '*' user.chshell foo /bin/zsh
    uUser '{0}' does not existushellupwuusermodu-su-nucmd.runR(R$RRR R#RR(RR9R'R)((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pytchshells
cC@s�t|�}|s*tdj|���n||dkr>tSdd|d|g}|ri|jd�ntd|dt�t|�jd�|kS(	u�
    Set a new home directory for an existing user

    name
        Username to modify

    home
        New home directory to set

    persist : False
        Set to ``True`` to prevent configuration files in the new home
        directory from being overwritten by the files from the skeleton
        directory.

    CLI Example:

    .. code-block:: bash

        salt '*' user.chhome foo /home/users/foo True
    uUser '{0}' does not existuhomeupwuusermodu-du-mucmd.runR(R$RRR RR#RR(RR8tpersistR'R)((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pytchhomescC@s�t|tj�r$|jd�}ntt|��}|t|�krLtS|r_||7}nddddj|�d|g}td|dt	�dkS(	u�
    Change the groups to which a user belongs

    name
        Username to modify

    groups
        List of groups to set for the user. Can be passed as a comma-separated
        list or a Python list.

    append : False
        Set to ``True`` to append these groups to the user's existing list of
        groups. Otherwise, the specified groups will replace any existing
        groups for the user.

    CLI Example:

    .. code-block:: bash

        salt '*' user.chgroups foo wheel,root True
    u,upwuusermodu-Gu-nucmd.retcodeRi(
RRRR
tsettlist_groupsR R3R#R(RR7RtugrpsR)((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pytchgroups@s
!cC@st|d|�S(u�
    Change the user's Full Name

    CLI Example:

    .. code-block:: bash

        salt '*' user.chfullname foo "Foo Bar"
    ufullname(R+(RR;((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pyt
chfullnameas
cC@st|d|�S(u
    Change the user's Room Number

    CLI Example:

    .. code-block:: bash

        salt '*' user.chroomnumber foo 123
    u
roomnumber(R+(RR<((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pytchroomnumberns
cC@st|d|�S(u�
    Change the user's Work Phone

    CLI Example:

    .. code-block:: bash

        salt '*' user.chworkphone foo "7735550123"
    u	workphone(R+(RR=((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pytchworkphone{s
cC@st|d|�S(u�
    Change the user's Home Phone

    CLI Example:

    .. code-block:: bash

        salt '*' user.chhomephone foo "7735551234"
    u	homephone(R+(RR>((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pytchhomephone�s
cC@sd|t|�krtSddddj|�ddj|�g}td|dt�t|�|kS(u�
    Change the default login class of the user

    .. versionadded:: 2016.3.5

    CLI Example:

    .. code-block:: bash

        salt '*' user.chloginclass foo staff
    upwuusermodu-Lu{0}u-nucmd.runR(tget_loginclassR RR#R(RR@trootR)((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pytchloginclass�scC@si}y�tj|�}|j|d<t|�|d<|j|d<|j|d<|j|d<|j|d<|j|d<|j	j
dd	�}x#t|�d
kr�|jd�q�W|d|d
<|d|d<|d|d<|d	|d<Wnt
k
r�iSX|S(un
    Return user information

    CLI Example:

    .. code-block:: bash

        salt '*' user.info root
    ugidugroupsuhomeunameupasswdushelluuidu,iiuiufullnameiu
roomnumberiu	workphoneu	homephone(R
Rtpw_gidRStpw_dirRIt	pw_passwdtpw_shelltpw_uidRR
RRR(RRKRR((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pyR$�s(







cC@sItdddd|g�}|jd�}t|�dkrE|dSdS(	u�
    Get the login class of the user

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt '*' user.get_loginclass foo

    ucmd.run_stdoutupwuusershowu-nu:i
iu(R#R
R(Rtuserinfo((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pyRZ�scC@stjjj|�S(u�
    Return a list of groups the named user belongs to

    CLI Example:

    .. code-block:: bash

        salt '*' user.list_groups foo
    (RRtusertget_group_list(R((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pyRS�s
cC@s&tgtj�D]}|j^q�S(ur
    Return a list of all users

    CLI Example:

    .. code-block:: bash

        salt '*' user.list_users
    (tsortedR
RHRI(Rc((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pyt
list_users�s
cC@s�t|�}|s*tdj|���nt|�}|rTtdj|���nddd|d|g}td|�t|�}|d|dkr�|d|kStS(	u�
    Change the username for a named user

    CLI Example:

    .. code-block:: bash

        salt '*' user.rename name new_name
    uUser '{0}' does not existuUser '{0}' already existsupwuusermodu-lu-nucmd.rununame(R$RRR#R(Rtnew_nametcurrent_infotnew_infoR)R*((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pytrename�s
(/t__doc__t
__future__RRRR!tloggingR
R RtImportErrorRtsalt.extRtsalt.utils.argsRtsalt.utils.datatsalt.utils.usertsalt.exceptionsRt	getLoggert__name__R0RR	RRR+R4RBRFRLRMRNRORQRURVRWRXRYR\R$RZRSRfRj(((s8/usr/lib/python2.7/site-packages/salt/modules/pw_user.pyt<module>
s`


					-			#!	
	
	
	
	"		
	

Zerion Mini Shell 1.0