Red Hat Bugzilla – Bug 1318890
glibc: nss_db: long group entries are skipped
Last modified: 2017-08-01 14:06:55 EDT
Description of problem: The client discovered this when testing with RHEL7 against a sizable groups.db file. The 'getet groups' list was truncated and was missing most entries. Florian had a look and submitted the following upstream patch which was tested to resolve the issue: https://sourceware.org/bugzilla/show_bug.cgi?id=19837 <snip> nss_db: No retries for some long lines with a larger buffer _nss_db_get*ent_r returns the wrong error code if parse_line fails. As a result, only long lines which are large enough not to fit into the caller-provided buffer result in ERANGE with NSS_STATUS_TRYAGAIN. If parse_line detects that there is not enough room, NSS_STATUS_NOTFOUND is returned, which stops enumeration. Patch for later reference (I will post it to libc-alpha as well): diff --git a/nss/nss_db/db-XXX.c b/nss/nss_db/db-XXX.c index 03c18d7..125a5e9 100644 --- a/nss/nss_db/db-XXX.c +++ b/nss/nss_db/db-XXX.c @@ -288,8 +288,8 @@ CONCAT(_nss_db_get,ENTNAME_r) (struct STRUCTURE *result, char *buffer, } if (err < 0) { - H_ERRNO_SET (HOST_NOT_FOUND); - status = NSS_STATUS_NOTFOUND; + H_ERRNO_SET (NETDB_INTERNAL); + status = NSS_STATUS_TRYAGAIN; break; } </snip> Version-Release number of selected component (if applicable): glibc-2.17-106.el7_2.4 How reproducible: Steps to Reproduce: 1.Have long "group" entries (many users/group) and generate/use NSS_db in nsswitch. 2. List group with "getent group" 3. Note that the listing is truncated I can't include the client's db file unfortunately that we were using for replication, but this patch was tested and corrected the client issue.
Upstream commit: https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=a6033052d08027f745867e5e346852da1959226c Reproducer (needs to run as root): perl -e \ 'print "large:x:999:" . join(",", map {"user$_"} (1 .. 135))."\n"' \ >> /etc/group cd /var/db make getent -s db group After the fix, the last command should list the "large" group. The magic number 135 has been chosen so that the line is shorter than 1024 bytes, but the pointers required to encode the member array will cross the threshold, triggering the bug.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2017:1916