mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
fixes saltstack/salt#65029 support for pysss can be removed
This commit is contained in:
parent
28be150d1a
commit
34bf45ee27
2 changed files with 24 additions and 52 deletions
|
@ -24,15 +24,6 @@ authenticated against. This defaults to `login`
|
|||
|
||||
The Python interface to PAM does not support authenticating as ``root``.
|
||||
|
||||
.. note:: Using PAM groups with SSSD groups on python2.
|
||||
|
||||
To use sssd with the PAM eauth module and groups the `pysss` module is
|
||||
needed. On RedHat/CentOS this is `python-sss`.
|
||||
|
||||
This should not be needed with python >= 3.3, because the `os` modules has the
|
||||
`getgrouplist` function.
|
||||
|
||||
|
||||
.. note:: This module executes itself in a subprocess in order to user the system python
|
||||
and pam libraries. We do this to avoid openssl version conflicts when
|
||||
running under a salt onedir build.
|
||||
|
|
|
@ -31,13 +31,6 @@ try:
|
|||
except ImportError:
|
||||
HAS_GRP = False
|
||||
|
||||
try:
|
||||
import pysss
|
||||
|
||||
HAS_PYSSS = True
|
||||
except ImportError:
|
||||
HAS_PYSSS = False
|
||||
|
||||
try:
|
||||
import salt.utils.win_functions
|
||||
|
||||
|
@ -289,47 +282,35 @@ def get_group_list(user, include_default=True):
|
|||
return []
|
||||
group_names = None
|
||||
ugroups = set()
|
||||
if hasattr(os, "getgrouplist"):
|
||||
# Try os.getgrouplist, available in python >= 3.3
|
||||
log.trace("Trying os.getgrouplist for '%s'", user)
|
||||
try:
|
||||
user_group_list = sorted(os.getgrouplist(user, pwd.getpwnam(user).pw_gid))
|
||||
local_grall = _getgrall()
|
||||
local_gids = sorted(lgrp.gr_gid for lgrp in local_grall)
|
||||
max_idx = -1
|
||||
# Try os.getgrouplist, available in python >= 3.3
|
||||
log.trace("Trying os.getgrouplist for '%s'", user)
|
||||
try:
|
||||
user_group_list = sorted(os.getgrouplist(user, pwd.getpwnam(user).pw_gid))
|
||||
local_grall = _getgrall()
|
||||
local_gids = sorted(lgrp.gr_gid for lgrp in local_grall)
|
||||
max_idx = -1
|
||||
local_max = local_gids[max_idx]
|
||||
while local_max >= 65000:
|
||||
max_idx -= 1
|
||||
local_max = local_gids[max_idx]
|
||||
while local_max >= 65000:
|
||||
max_idx -= 1
|
||||
local_max = local_gids[max_idx]
|
||||
user_group_list_local = [
|
||||
lgrp for lgrp in user_group_list if lgrp <= local_max
|
||||
]
|
||||
user_group_list_remote = [
|
||||
rgrp for rgrp in user_group_list if rgrp > local_max
|
||||
]
|
||||
local_group_names = [
|
||||
_group.gr_name
|
||||
for _group in local_grall
|
||||
if _group.gr_gid in user_group_list_local
|
||||
]
|
||||
remote_group_names = [
|
||||
grp.getgrgid(group_id).gr_name for group_id in user_group_list_remote
|
||||
]
|
||||
group_names = local_group_names + remote_group_names
|
||||
except Exception: # pylint: disable=broad-except
|
||||
pass
|
||||
elif HAS_PYSSS:
|
||||
# Try pysss.getgrouplist
|
||||
log.trace("Trying pysss.getgrouplist for '%s'", user)
|
||||
try:
|
||||
group_names = list(pysss.getgrouplist(user))
|
||||
except Exception: # pylint: disable=broad-except
|
||||
pass
|
||||
user_group_list_local = [lgrp for lgrp in user_group_list if lgrp <= local_max]
|
||||
user_group_list_remote = [rgrp for rgrp in user_group_list if rgrp > local_max]
|
||||
local_group_names = [
|
||||
_group.gr_name
|
||||
for _group in local_grall
|
||||
if _group.gr_gid in user_group_list_local
|
||||
]
|
||||
remote_group_names = [
|
||||
grp.getgrgid(group_id).gr_name for group_id in user_group_list_remote
|
||||
]
|
||||
group_names = local_group_names + remote_group_names
|
||||
except Exception: # pylint: disable=broad-except
|
||||
pass
|
||||
|
||||
if group_names is None:
|
||||
# Fall back to generic code
|
||||
# Include the user's default group to match behavior of
|
||||
# os.getgrouplist() and pysss.getgrouplist()
|
||||
# os.getgrouplist()
|
||||
log.trace("Trying generic group list for '%s'", user)
|
||||
group_names = [g.gr_name for g in grp.getgrall() if user in g.gr_mem]
|
||||
try:
|
||||
|
|
Loading…
Add table
Reference in a new issue