Bug 739360

Summary: getgrouplist does not return groups with lines longer than 1024 characters.
Product: [Fedora] Fedora Reporter: Eric W. Biederman <ebiederm>
Component: glibcAssignee: Andreas Schwab <schwab>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 15CC: fweimer, jakub, schwab
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: glibc-2.14.90-12.999 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-10-19 04:34:05 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Eric W. Biederman 2011-09-18 05:50:04 UTC
Description of problem:

getgrouplist does not return groups whose lines in /etc/group are longer than 1024 characters.

It appears that _nss_files_parse_grent decides to return 0 after the input buffer has been resized to be large enough.

Version-Release number of selected component (if applicable):


glibc-2.14-5.x86_64

How reproducible:

Add a root  to a group with a line in /etc/groups that is longer than 1024 characters.

Observer the group is not listed with:

#define _BSD_SOURCE 1
#include <stdio.h>
#include <sys/types.h>
#include <grp.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

void *xmalloc(size_t size)
{
        void *ptr;
        ptr = malloc(size);
        if (!ptr) {
                fprintf(stderr, "malloc failed:%s\n",
                        strerror(errno));
                exit(1);
        }
        memset(ptr, '\0', size);
        return ptr;
}

int main(int argc, char **argv)
{
        {
                char *user_name = "root";
                gid_t user_gid = 0;
                gid_t *grouplist, grouptmp;
                int n_groups, i;
                n_groups = 1;
                if (getgrouplist(user_name, user_gid, &grouptmp, &n_groups) == -1) {
                        grouplist = (gid_t *)xmalloc(sizeof(gid_t) * (n_groups + 1));
                        if (getgrouplist(user_name, user_gid, grouplist, &n_groups) > 0) {
                                for (i = 0; i < n_groups; i++) {
                                        printf("%u\n", grouplist[i]);
                                }
                        }
                        free(grouplist);
                }
        }
        return 0;
}

Comment 1 Andreas Schwab 2011-09-26 14:07:23 UTC
I cannot reproduce that.

Comment 2 Fedora Update System 2011-10-07 15:11:02 UTC
glibc-2.14.1-1 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/glibc-2.14.1-1

Comment 3 Fedora Update System 2011-10-09 06:58:24 UTC
Package glibc-2.14.1-1:
* should fix your issue,
* was pushed to the Fedora 15 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing glibc-2.14.1-1'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2011-14053
then log in and leave karma (feedback).

Comment 4 Fedora Update System 2011-10-18 08:10:21 UTC
glibc-2.14.90-12.999 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/FEDORA-2011-14504

Comment 5 Fedora Update System 2011-10-19 04:34:05 UTC
glibc-2.14.90-12.999 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 6 Fedora Update System 2011-12-19 07:51:10 UTC
glibc-2.14.1-4 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/glibc-2.14.1-4

Comment 7 Fedora Update System 2012-01-02 17:05:03 UTC
glibc-2.14.1-5 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/glibc-2.14.1-5

Comment 8 Fedora Update System 2012-01-17 20:24:45 UTC
glibc-2.14.1-5 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.