HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/group.cpython-310.pyc
o

�N�g '�@sHdZddlZddlZddlZd
dd�Z						ddd�Zdd	�ZdS)a1
Management of user groups
=========================

The group module is used to create and manage group settings, groups can be
either present or absent. User/Group names can be passed to the ``adduser``,
``deluser``, and ``members`` parameters. ``adduser`` and ``deluser`` can be used
together but not with ``members``.

In Windows, if no domain is specified in the user or group name (i.e.
``DOMAIN\username``) the module will assume a local user or group.

.. code-block:: yaml

    cheese:
      group.present:
        - gid: 7648
        - system: True
        - addusers:
          - user1
          - users2
        - delusers:
          - foo

    cheese:
      group.present:
        - gid: 7648
        - system: True
        - members:
          - foo
          - bar
          - user1
          - user2
�Nc		sbtd|���s
dStjj��r:�drdd��dD��d<|r(dd�|D�}|r1dd�|D�}|r:dd�|D�}i}i}|rfzt|�}�d	|krO||d	<Wnttfyed|d
<d|d<|YSw|d
ur~|s~t�d��	|�r}t�d�|d<n|r�t�d��	|�r�||d<|r��fdd�|D�}|r�||d<|r��fdd�|D�}|r�||d<|S)zp
    Return a dict of the changes required for a group if the group is present,
    otherwise return False.
    �
group.infoF�memberscSsg|]}|���qS�)�lower��.0�userrr�E/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/group.py�
<listcomp>7sz_changes.<locals>.<listcomp>cS�g|]}tjj�|����qSr��salt�utilsZ
win_functionsZget_sam_namerrrrr	r
9��cSrrrrrrr	r
=rcSrrrrrrr	r
Ar�gid�resultzInvalid gid�commentN�deluserscsg|]
}|�dvr|�qS�rrr��lgrprr	r
Z��adduserscsg|]
}|�dvr|�qSrrrrrr	r
_r)
�__salt__r
r�platformZ
is_windows�int�	TypeError�
ValueError�set�symmetric_difference)	�namerrrrZchange�retZ
users_2addZ
users_2delrrr	�_changes*s^������r"FcCs6|idd|�d�d�}|dur!|dus|dur!d|d<d|d<|S|r8|r8t|��t|��s8d|d<d	|d<|St|||||�}|r�d
|d<|��D]\}	}
|d|	�d|
�d�7<qJtd
rgd|d<|S|��D]C\}	}
|	dkr}td|||d�qk|	dkr�|
D]	}td||�q�qk|	dkr�|
D]	}td||�q�qk|	dkr�td|d�|��qkqktjtdj	j
�dd�t|||||�}|r�d|d<|dd7<d|i|d<nddi|d<|du�r�td
r�d|d<d|�d �|d<|Std�}|du�r,|�s,d}
|D]}|d|k�r|d!}
n�q|
du�r,d|d<d"�|||
�|d<|Std#||||d$��r�d}|�rAd�|�}|�rId�|�}|�rStd||�tjtdj	j
�dd�d%|�d&�|d<td'|�|d<t|||||�}|�r�d|d<d(�|�|d<d|i|d<|Sd|d<d)|��|d<|S)*a
    .. versionchanged:: 3006.0

    Ensure that a group is present

    Args:

        name (str):
            The name of the group to manage

        gid (str):
            The group id to assign to the named group; if left empty, then the
            next available group id will be assigned. Ignored on Windows

        system (bool):
            Whether or not the named group is a system group.  This is essentially
            the '-r' option of 'groupadd'. Ignored on Windows

        addusers (list):
            List of additional users to be added as a group members. Cannot
            conflict with names in delusers. Cannot be used in conjunction with
            members.

        delusers (list):
            Ensure these user are removed from the group membership. Cannot
            conflict with names in addusers. Cannot be used in conjunction with
            members.

        members (list):
            Replace existing group members with a list of new members. Cannot be
            used in conjunction with addusers or delusers.

        non_unique (bool):
            Allow creating groups with duplicate (non-unique) GIDs

            .. versionadded:: 3006.0

    Example:

    .. code-block:: yaml

        # Adds DOMAIN\db_admins and Administrators to the local db_admin group
        # Removes Users
        db_admin:
          group.present:
            - addusers:
              - DOMAIN\db_admins
              - Administrators
            - delusers:
              - Users

        # Ensures only DOMAIN\domain_admins and the local Administrator are
        # members of the local Administrators group. All other users are
        # removed
        Administrators:
          group.present:
            - members:
              - DOMAIN\domain_admins
              - Administrator
    T�Group z is present and up to date�r �changesrrNrzaError: Conflicting options "members" with "addusers" and/or "delusers" can not be used together. rz?Error. Same user(s) can not be added and deleted simultaneouslyz6The following group attributes are set to be changed:
z: �
�testrzgroup.chgid)�
non_uniquerz
group.adduserrz
group.deluserrz
group.members�,z	test.pingzgroup.getentFz!Some changes could not be appliedZFailedr%ZFinalz All changes applied successfullyz set to be addedr z?Group {} is not present but gid {} is already taken by group {}z	group.add)r�systemr(z
New group z createdrz@Group {} has been created but, some changes could not be appliedzFailed to create new group )
r�
isdisjointr"�items�__opts__r�join�sys�modules�
__module__�__context__�pop�format)r rr*rrrr(r!r%�key�valrZgrpsZ	gid_grouprZgrp_membersrrr	�presentfs�F
�����

�

�

���r7cCs�|iddd�}td|�}|rEtdr!d|d<d|�d	�|d
<|Std|�|d<|dr<|di|d<d
|��|d
<|Sd|��|d
<|Sd|d
<|S)z�
    Ensure that the named group is absent

    Args:
        name (str):
            The name of the group to remove

    Example:

    .. code-block:: yaml

        # Removes the local group `db_admin`
        db_admin:
          group.absent
    T�r$rr'Nrr#z is set for removalrzgroup.deleter%zRemoved group zFailed to remove group zGroup not present)rr-)r r!Zgrp_inforrr	�absents r9)NNNN)NFNNNF)�__doc__r/Zsalt.utils.platformr
Zsalt.utils.win_functionsr"r7r9rrrr	�<module>s#
>
�9