Retrieve remote groups information using SSSD InfoPipe (#2240) #2279
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2240
Fixes #1580
@phillxnet, ready for review
As detailed in #2240, we currently fail to fetch and list groups information after joining and AD or LDAP server, until a machine or rockstor service restart. This has been tracked down to some issue with
grp
not being able to fetch the groups information of such remote users until after agunicorn
or rockstor service restart. This pull request (PR) thus proposes to implement a fail-over mechanism to fetch this groups information in such cases based on the D-Bus API of SSSD: InfoPipe.Logic and implementation
Overall description
The error described in #2240 occurs when trying to fetch the groups information of a remote user. This ultimately boils down the fact that we are using two different approaches to fetch users and groups. While users are fetched from the system database using
getent passwd
, the groups information is based on the pythongrp
module. As the former sees remote users (in these conditions) but the latter does not, we end up in a situation where we askgrp
to retrieve information on a group it doesn't know, thereby causing the error.As a result, this PR proposes to implement a new way to fetch the groups information based on the D-Bus API built in SSSD: InfoPipe. Instead of completely replacing the existing way we fetch groups, this PR proposes to use the InfoPipe-based mechanisms as a fail-over if
grp
fails to fetch this information.Implementation details
New packages needed
This PR requires 2 additional packages:
sssd-dbus
: the D-Bus responder of SSSDpython-dbus-python
: dbus python moduleNew functions
Two new functions based on InfoPipe are added:
ifp_get_groupname(gid)
: given a gid, retrieve the groupname from InfoPipeifp_get_groups()
: use InfoPipe to list all remote groupsAs we also need to activate the
ifp
service in SSSD config, this PR includes a new function to customize the services declared in/etc/sssd/sssd.conf
. We also improve the existingappend_to_line()
helper function to make it slightly more smart by verifying the desired customization is not already present before writing it.As mentioned above, the
ifp
-based logic is implemented only as fail-over mechanism in casegrp
fails to retrieve the required information. This is particularly important asifp
seems to only see remote (AD/LDAP) groups, and requires thesssd
service to be up and running (and therefore the Rockstor machine to have already joined an AD/LDAP server). We thus cannot useifp
as the default mechanism to fetch users/groups information. This PR thus proposes to include these in atry
/except
block:getent passwd
, including its primarygid
.try
to retrieve groupname usinggrp
(pre-PR mechanism).ifp
Similarly, we now retrieve and list all groups (triggered when visiting the Groups page):
grp
try
to fetch groups fromifp
ifp
in step 2 to the list of step 1 if not already presentDemonstration
ifp
service is indeed defined in sssd.conf:# head /etc/sssd/sssd.conf [sssd] config_file_version = 2 services = nss, pam, ifp domains = samdom.example.com (...)
Visit the Groups page and see the AD groups being listed:
Visit the Users page and see all AD users being listed:
The same has been verified after joining an LDAP server.
Important: the
ifp
-based methods have been verified to be triggered only right after joining an AD/LDAP server'; upon restarting the rockstor service, all user and group information was retrieved by the primary mechanisms.Miscellaneous
Although this issue fixes #2240 and #1580, it doesn't fix #1817 as the current PR represents more a workaround than a true fix for the root cause of these issues, which seems to relate to some caching and/or env issue related to
gunicorn
(explaining why agunicorn
restart "fixes" all the problem.Testing
The full suite of tests yields:
Leap 15.2 (ISO install):
Full Testing Outputs
Leap15.2 (ISO install)