mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
support creating groups with non-unique GIDs for testing purposes
This commit is contained in:
parent
ac2408477d
commit
b452ed5663
3 changed files with 14 additions and 2 deletions
1
changelog/62377.fixed
Normal file
1
changelog/62377.fixed
Normal file
|
@ -0,0 +1 @@
|
|||
Fix groups with duplicate GIDs are not returned by get_group_list
|
|
@ -40,8 +40,10 @@ def __virtual__():
|
|||
)
|
||||
|
||||
|
||||
def add(name, gid=None, system=False, root=None):
|
||||
def add(name, gid=None, system=False, root=None, non_unique=False):
|
||||
"""
|
||||
.. versionchanged:: 3006.0
|
||||
|
||||
Add the specified group
|
||||
|
||||
name
|
||||
|
@ -56,6 +58,11 @@ def add(name, gid=None, system=False, root=None):
|
|||
root
|
||||
Directory to chroot into
|
||||
|
||||
non_unique
|
||||
Allow creating groups with duplicate (non-unique) GIDs
|
||||
|
||||
.. versionchanged:: 3006.0
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
@ -67,6 +74,8 @@ def add(name, gid=None, system=False, root=None):
|
|||
cmd.append("-g {}".format(gid))
|
||||
if system and __grains__["kernel"] != "OpenBSD":
|
||||
cmd.append("-r")
|
||||
if non_unique:
|
||||
cmd.append("-o")
|
||||
|
||||
if root is not None:
|
||||
cmd.extend(("-R", root))
|
||||
|
|
|
@ -214,7 +214,9 @@ class TestGroup:
|
|||
def __enter__(self):
|
||||
group = self.sminion.functions.group.info(self.name)
|
||||
if not group:
|
||||
ret = self.sminion.functions.group.add(self.name, gid=self.gid)
|
||||
ret = self.sminion.functions.group.add(
|
||||
self.name, gid=self.gid, non_unique=True
|
||||
)
|
||||
assert ret
|
||||
self._delete_group = True
|
||||
log.debug("Created system group: %s", self)
|
||||
|
|
Loading…
Add table
Reference in a new issue