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

�
���^c@@s�dZddlmZmZmZddlZddlmZyddlZWne	k
ranXej
e�ZdZ
d�Zdedd�Zdd�Zd	�Zd
�Zed�Zdd�Zdd
�Zdd�Zdd�ZdS(u+
Manage groups on Linux, OpenBSD and NetBSD

.. important::
    If you feel that Salt should be using this module to manage groups on a
    minion, and it is using a different module (or gives an error similar to
    *'group.info' is not available*), see :ref:`here
    <module-provider-override>`.
i(tabsolute_importtprint_functiontunicode_literalsN(tsixugroupcC@stddkrtStdfS(u?
    Set the user module if the kernel is Linux or OpenBSD
    ukerneluLinuxuOpenBSDuNetBSDu\The groupadd execution module cannot be loaded:  only available on Linux, OpenBSD and NetBSD(uLinuxuOpenBSDuNetBSD(t
__grains__t__virtualname__tFalse(((s9/usr/lib/python2.7/site-packages/salt/modules/groupadd.pyt__virtual__scC@s�dg}|r(|jdj|��n|rNtddkrN|jd�n|j|�|d
k	r}|jd|f�ntd|dt�}|d	S(ur
    Add the specified group

    CLI Example:

    .. code-block:: bash

        salt '*' group.add foo 3456
    ugroupaddu-g {0}ukerneluOpenBSDu-ru-Rucmd.run_alltpython_shelluretcodeN(tappendtformatRtNonetextendt__salt__R(tnametgidtsystemtroottcmdtret((s9/usr/lib/python2.7/site-packages/salt/modules/groupadd.pytadd's
	
cC@sMd|g}|dk	r.|jd|f�ntd|dt�}|dS(uo
    Remove the named group

    CLI Example:

    .. code-block:: bash

        salt '*' group.delete foo
    ugroupdelu-Rucmd.run_allRuretcodeN(RRR
R(RRRR((s9/usr/lib/python2.7/site-packages/salt/modules/groupadd.pytdelete@s

cC@s6ytj|�}Wntk
r'iSXt|�SdS(uw
    Return information about a group

    CLI Example:

    .. code-block:: bash

        salt '*' group.info foo
    N(tgrptgetgrnamtKeyErrort_format_info(Rtgrinfo((s9/usr/lib/python2.7/site-packages/salt/modules/groupadd.pytinfoTs


cC@s,i|jd6|jd6|jd6|jd6S(u7
    Return formatted information in a pretty way.
    unameupasswdugidumembers(tgr_namet	gr_passwdtgr_gidtgr_mem(tdata((s9/usr/lib/python2.7/site-packages/salt/modules/groupadd.pyRfs


cC@sYdtkr|rtdSg}x'tj�D]}|jt|��q.W|td<|S(un
    Return info on all groups

    CLI Example:

    .. code-block:: bash

        salt '*' group.getent
    ugroup.getent(t__context__RtgetgrallR	R(trefreshRR((s9/usr/lib/python2.7/site-packages/salt/modules/groupadd.pytgetentps

cC@s�td|�}||kr tSdd||g}|dk	rT|jd|f�ntd|dt�td|�}||kr�||kStS(u}
    Change the gid for a named group

    CLI Example:

    .. code-block:: bash

        salt '*' group.chgid foo 4376
    ufile.group_to_gidugroupmodu-gu-Rucmd.runRN(R
tTrueRRR(RRRtpre_gidRtpost_gid((s9/usr/lib/python2.7/site-packages/salt/modules/groupadd.pytchgid�s

cC@s tjd�dko'tjd�dk}tjd�dkoQtjd�dk}tddkr�|rd	d
||g}n-|r�dd||g}nd	d
||g}|dk	r|jd|f�qn4dd||g}|dk	r|jd|f�ntd|dt�}|S(u�
    Add a user in the group.

    CLI Example:

    .. code-block:: bash

         salt '*' group.adduser foo bar

    Verifies if a valid username 'bar' as a member of an existing group 'foo',
    if not then adds it.
    u	os_familyuRedHatuosmajorreleaseu5uSuseu11ukerneluLinuxugpasswdu-auusermodu-Au--addu-Qu-Gu-Rucmd.retcodeRN(RtgetRRR
R(RtusernameRton_redhat_5t
on_suse_11Rtretcode((s9/usr/lib/python2.7/site-packages/salt/modules/groupadd.pytadduser�s
**c
	C@s�tjd�dko'tjd�dk}tjd�dkoQtjd�dk}td|�}yo||dkr�td	d
kr
|r�dd||g}n-|r�d
d||g}ndd||g}|dk	r�|jd|f�ntd|dt�}n�td	dkr�tddj|�dt�}d
dg}|jdjg|j	�D]!}	|	t
j|�kr^|	^q^��|jdj|��td|dt�}ntj
d�tS|StSWntk
r�tSXdS(u�
    Remove a user from the group.

    CLI Example:

    .. code-block:: bash

         salt '*' group.deluser foo bar

    Removes a member user 'bar' from a group 'foo'. If group is not present
    then returns True.
    u	os_familyuRedHatuosmajorreleaseu5uSuseu11u
group.infoumembersukerneluLinuxugpasswdu-duusermodu-Ru--delucmd.retcodeRuOpenBSDucmd.run_stdoutu
id -Gn {0}u-Su,u{0}u3group.deluser is not yet supported on this platformN(RR)R
RRRR
R	tjointsplitRt	text_typetlogterrorR%t	Exception(
RR*RR+R,tgrp_infoRR-touttg((s9/usr/lib/python2.7/site-packages/salt/modules/groupadd.pytdeluser�s6
**	D

c
	C@stjd�dko'tjd�dk}tjd�dkoQtjd�dk}tddkr+|rd	d
||g}nq|r�xAtd|�jd�D]&}td
dj||�dt�q�Wdd||g}nd	d||g}|d k	r|jd|f�ntd|dt�}n�tddkr	d}td|�}|r||dkrtd
dj|�dt�td
dj|d|�dt�x[|jd�D]G}	|	r�tddd||	gdt�}|dks�Pq�q�d}q�Wqntj	d�tS|S(!u�
    Replaces members of the group with a provided list.

    CLI Example:

        salt '*' group.members foo 'user1,user2,user3,...'

    Replaces a membership list for a local group 'foo'.
        foo:x:1234:user1,user2,user3,...
    u	os_familyuRedHatuosmajorreleaseu5uSuseu11ukerneluLinuxugpasswdu-Mu
group.infoumembersucmd.runugroupmod -R {0} {1}Rugroupmodu-Au	--membersu-Rucmd.retcodeuOpenBSDiunameugroupdel {0}ugroupadd -g {0} {1}ugidu,uusermodu-Giu3group.members is not yet supported on this platformN(
RR)R
R
RRRR0R2R3(
Rtmembers_listRR+R,Rt
old_memberR-R5tuser((s9/usr/lib/python2.7/site-packages/salt/modules/groupadd.pytmembers�s@** $
	
(t__doc__t
__future__RRRtloggingtsalt.extRRtImportErrort	getLoggert__name__R2RRRRRRRRR$R(R.R8R<(((s9/usr/lib/python2.7/site-packages/salt/modules/groupadd.pyt<module>
s&
	
		
#.

Zerion Mini Shell 1.0