Use InfoPipe as fallback mechanism to fetch user/group information #2526 #2532
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 #2526
@phillxnet, ready for review
We currently use the built-ins
pwd
orgrp
to fetch user/group information throughout the project. Unfortunately, this can sometimes fail in systems that have freshly been joined to an Active Directory domain. See #2526 for details on the conditions required for such failures.Proposed fix
To fix this issue, this pull request (PR) proposes to increase the robustness of users/groups fetching by adding InfoPipe as a fallback mechanism during the creation of a Samba export; we already use such fallback to retrieve the groupname information for a domain user (see #2279).
Briefly, we add this InfoPipe-based fallback mechanism in two places and to retrieve:
To simplify and harmonize our user retrieval mechanisms, switch to using the already established
combined_users()
method during_set_admin_users()
to retrieve all users seen bygetent passwd
, complemented by InfoPipe as fallback. See #2526 (comment) for details.This PR also fixes a related bug in retrieving groupname from an AD user: see #2526 (comment) for details.
It also includes the following minor improvements:
ifp_get_groupname()
function to make it more flexible: able to retrieve any given property or several properties of either a user or a groupDemonstration
Testing
No new unit test was added.
Final note
I noticed the following behavior. When we create a Samba export, the user selected as Samba admin user (if any) is added to the Django User table along with its link to the SambaShare table. We thus now have an AD user in the User table. When this Samba export is deleted, however, we do NOT clean this up. This means that if the machine leaves the AD domain, we will still have that AD user listed as user. This is beyond the scope of this PR, but we may need to think about that as cleaning this up may prove tricky.