On Thu, Aug 25, 2016 at 01:03:19PM -0400, Simo Sorce wrote:
On Thu, 2016-08-25 at 14:24 +0300, Nikolai Kondrashov wrote:
Hi Simo,
Thanks for looking at the patches and for the feedback! I'm replying below.
On 08/24/2016 11:24 PM, Simo Sorce wrote:
On Tue, 2016-08-23 at 17:24 +0300, Nikolai Kondrashov wrote:
Hi everyone,
Attached is the third version of work-in-progress SSSD/tlog integration patches. I'm sending them in the hope that somebody takes a look and perhaps points out some wrong bits I can fix before I'm too dependent on them.
The changes from the last version is some refactoring of the NSS and the common parts, plus start of the PAM part of the implementation.
Also, at this point, I think I could contribute some general fixes and prerequisite refactoring patches separately.
So I have been going through the patchset and I have concerns about how you are determining if the shell needs to be substituted with the session recording shell. It seem you do this work every single time a getpwname/uis/etc request is run. this is very expensive as you do a full group search on each of those requests, to find data that arguably rarely changes.
I think in general this should be done at "write" time not at "read" time. Ie whenever the the session recording configuration changes or when a new user is written in the cache, then you should check if session recording apply to this user and write an attribute in the user entry.
On getpwnam/uid/ent calls you would look for those calls and replace the shell entry accordingly.
Unless there is some very good reason to do it always at query time this is, I am afraid, a nack on the approach.
I'm not sure I fully understand your suggestion, but I like it so far. I wanted to do something like this from the start, but Sumit had some concerns which I can't quite remember now.
Sumit, maybe you can take a look at this?
Sorry for the delay, I wanted to test the patches first. And the good news is that imo the NSS part works quite smoothly (nevertheless there might be one or two ares for improvement :-).
First a general comment about the refactoring patches for the NSS responder. Pavel is working on replacing the current code with a cache_req_* based one which I think would simplify a lot of things for you as well. Please try to coordinate with him, maybe he has a WIP branch which you can you as a base for your patches.
About Simo's concern. If there are groups defined in the session_recording configuration you look up those groups with cache_req_group_by_name_send(). As long as the groups are in the cache and not expired they are returned directly from the cache. I think this lookup cannot be avoided because in theory the groups name, be it the original name or an override name, might change. And you want to be sure that the name listed in the configuration is still a valid group name.
Then you do a normal user lookup but if there are groups configured in the session_recording section you always do a SSS_DP_INITGROUPS instead of a SSS_DP_USER if the entry is expired. I think here you can add some improvement to reduce the number of SSS_DP_INITGROUPS calls which are more expensive than SSS_DP_USER. User entries in the cache have two timeout values SYSDB_CACHE_EXPIRE and SYSDB_INITGR_EXPIRE. The first is the expiration time for the general user data (name, home directory, shell etc) and is checked during the normal user lookup. The second is the expiration time of the group-membership data. To make sure that SSS_DP_INITGROUPS is only used when needed I would recommend to additionally check if SYSDB_INITGR_EXPIRE is expired and only do a SSS_DP_INITGROUPS in this case and a SSS_DP_USER in all other cases. Currently both timestamps might not differ often but future enhancements to the backends might change this.
Finally you call sysdb_initgroups_with_views() to get the list of groups the user is a member of and compare them with the groups form the session_recording configuration. Since you compare the DNs I think this can be improved a bit. sysdb_initgroups_with_views() does a dereference search based on the memberOf attribute of the user which holds the DNs of all the groups the user is a member of. But since you only need the DNs of the groups for the comparison you can just add the memberOf attribute to the attribute list in nss_cmd_getpwnam_search() and friends to make the DNs of the groups available in session_recording_is_enabled().
Based in the result of session_recording_is_enabled() it would be possible to add a new attribute indicating if session recording is required for the user or not. But since we have the memory cache I wonder if the comparison of the DNs will hurt that much. Additionally I would like to wait with such kind of optimizations until we have a good understanding how the solution we plan for IPA will be implemented and what kind of optimizations might be needed here to hopefully find a solution which can give good performance in both cases.
HTH
bye, Sumit
I'll try to describe what I think you mean. So, we can modify the user cache-filling machinery to look at the session recording configuration upon adding a new user, and if session recording is enabled for the user (in whatever way), add an attribute signifying that. Then NSS could just check that attribute and substitute the shell when needed. I assume PAM would also be able to do that. Although it would still need the shell override logic, currently residing in NSS (I started another thread on this). Is that what you mean?
Yes
Still, I have a bunch of concerns about this, which perhaps you can help me resolve.
Would it be OK for the cache machinery to also pull groups into the cache, for which session recording is enabled, so that it can check if the user belongs to them? It would need to fetch them by names that the administrator would put into the configuration. I.e. with all the overrides, whitespace, and other changes.
I am a bit concerned that this list is based on group names in general, how do you deal with local groups that list a remote user as member ?
Similarly, would the cache machinery be in a good position to understand the names of the users listed in the session recording configuration? I.e. I expect the administrators would like to put there names as they see them. Also with overrides, whitespace and other tweaks NSS does.
You have access to the same configuration rules that the frontend has access to if you need, so you can do whatever mapping is needed at store time.
Then, I expect we need to check whether a user should be recorded also on cache refresh, not only on initial addition and configuration change. Because groups can go away, or their names might change due to overrides.
The check needs to be performed any time that:
- a user is added or refreshed
- a group is added or refreshed (memberships changed)
- the session recording configuration is changed
Lastly, user names might change due to overrides. Can this approach handle it?
afaik overrides are also store in cache so it can be taken in account.
I am curious about what are Sumit concerns though.
Simo.
-- Simo Sorce * Red Hat, Inc * New York