Bug 1436335

Summary: NSCD not properly caching netgroup
Product: Red Hat Enterprise Linux 6 Reporter: Al Heisner <al>
Component: glibcAssignee: DJ Delorie <dj>
Status: CLOSED WONTFIX QA Contact: qe-baseos-tools-bugs
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.8CC: alanm, ashankar, codonell, fweimer, jwright, mnewsome, pfrankli
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1505647 (view as bug list) Environment:
Last Closed: 2017-10-24 04:31:29 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1461138, 1505647    
Attachments:
Description Flags
patch for netgroupcache.c none

Description Al Heisner 2017-03-27 16:53:47 UTC
Created attachment 1266715 [details]
patch for netgroupcache.c

Description of problem:
NSCD netgroup cache failure. Persistent cache inspection and logs show that setnetgrent() and innetgr() cache separate GETNETGRENT records in the cache. When the entry corresponding to innetgr() expires, on reload the netgroup entry has 0 results and further calls to innetgr always return 0 even if it should return 1. Debugging nscd, I found that innetgr adds the GETNETGRENT record to cache with the group string not null-terminated.

Version-Release number of selected component (if applicable):
glibc-2.12-1.192.el6.x86_64

How reproducible:
always

Steps to Reproduce:
1. set up netgroups provided by ldap / nslcd
2. perform innetgr() with triplet that returns 1
3. wait for nscd debug log to show expire and reload of GETNETGRENT from innetgr()
4. perform innetgr() again, it returns 0

Actual results:
innetgr always returns 0 after GETNETGRENT record from previous innetgr() expires

Expected results:
innetgr should return 1 if entry is in netgroup or 0 if it is not

Additional info:
I've tested attached patch and it seems to work. One cache record exists from both setnetgrent() and innetgr(), and when it exires it reloads without issue. This has a side benefit of fewer type 19 records in nscd cache and fewer ldap lookup.

Comment 4 DJ Delorie 2017-10-24 04:31:29 UTC
Red Hat Enterprise Linux 6 is now in production stage 3, and this means that
only urgent priority bug fixes will be considered for release. In this case
there are several workarounds including disabling netgroup caching, disabling
nscd, or using an alternate caching framework like sssd. Your analysis does
look correct, but we need to review this further. We have cloned this issue
for RHEL7 here 1505647 to continue looking at the fix there. Thank you very
much for the bug report. We have also filed an upstream issue here: 
https://sourceware.org/bugzilla/show_bug.cgi?id=22342