Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Feb 2008 20:10:04 GMT
From:      Denis Barov <dindin@yandex-team.ru>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: kern/113398: [libc] initgroups fails rather than truncates if
Message-ID:  <200802272010.m1RKA4lO048535@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/113398; it has been noted by GNATS.

From: Denis Barov <dindin@yandex-team.ru>
To: bug-followup@FreeBSD.org, dean.povey@quest.com
Cc:  
Subject: Re: kern/113398: [libc] initgroups fails rather than truncates if
Date: Wed, 27 Feb 2008 23:06:54 +0300

 number of groups > NGROUPS_MAX meaning the user can no longer login
 Message-ID: <20080227170342.GE1139@sepulca.yandex.ru>
 MIME-Version: 1.0
 Content-Type: text/plain; charset=koi8-r
 Content-Disposition: inline
 X-Operating-System: FreeBSD sepulca.yandex.ru 6.3-STABLE FreeBSD 6.3-STABLE
 User-Agent: mutt-ng/devel-r804 (FreeBSD)
 Status: RO
 
 I'm sorry, previous patch just  increases number of groups to 64, and this
 one fixes problem.
 
 -- 
 Cheers
 Denis Barov
 
 diff -urN src/lib/libc/gen/initgroups.c.orig src/lib/libc/gen/initgroups.c
 --- src/lib/libc/gen/initgroups.c.orig  2003-11-19 18:51:26.000000000 +0300
 +++ src/lib/libc/gen/initgroups.c   2008-02-27 22:59:13.000000000 +0300
 @@ -42,6 +42,7 @@
  #include <stdio.h>
  #include "namespace.h"
  #include <err.h>
 +#include <errno.h>
  #include "un-namespace.h"
  #include <unistd.h>
 
 @@ -51,6 +52,7 @@
     gid_t agroup;
  {
     int ngroups;
 +    int result;
     /*
      * Provide space for one group more than NGROUPS to allow
      * setgroups to fail and set errno.
 @@ -59,5 +61,10 @@
 
     ngroups = NGROUPS + 1;
     getgrouplist(uname, agroup, groups, &ngroups);
 -   return (setgroups(ngroups, groups));
 +
 +    do
 +      result = setgroups (ngroups, groups);
 +    while (result == -1 && errno == EINVAL && --ngroups > 0);
 +
 +   return result;
  }
 
 
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200802272010.m1RKA4lO048535>