You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Ben Laurie <be...@gonzo.ben.algroup.co.uk> on 1995/12/11 18:24:28 UTC

Bug in initgroups()

While I was having a lovely time playing with CVS today, I had to steal a bit
of code from Apache, namely initgroups() from util.c. When I did, I noticed
it had a bug. So, here is a patch for it. Whether this goes in 1.1b1 or 1.0.1
is up to you, but note, it could interact (unpatched) with third party modules.
It isn't clear to me whether it actually works in its current form, anyway!

BTW, CVS is looking very plausible to me. Has anyone else any opinions? We
still need to address the thorny question of where we run the repository, too.

CVS (as of 1.6.3) even has an OS/2 version, so the OS/2 port would fit in
nicely.

Cheers,

Ben.

From: ben@algroup.co.uk (Ben Laurie)
Subject: initgroups() stand in did not initialise or clean up
Affects: util.c
Changelog: The replacement for initgroups() did not call {set,end}grent(). This
	had two implications: if anything else used getgrent(), then
	initgroups() would fail, and it was consuming a file descriptor.

*** util.c.old	Mon Dec 11 17:09:45 1995
--- util.c	Mon Dec 11 17:10:24 1995
***************
*** 709,714 ****
--- 709,716 ----
    struct group *g;
    int index = 0;
  
+   setgrent();
+ 
    groups[index++] = basegid;
  
    while (index < NGROUPS_MAX && ((g = getgrent()) != NULL))
***************
*** 720,725 ****
--- 722,729 ----
          if (!strcmp(*names, name))
            groups[index++] = g->gr_gid;
      }
+ 
+   endgrent();
  
    return setgroups(index, groups);
  #endif /* def QNX */

-- 
Ben Laurie                  Phone: +44 (181) 994 6435
Freelance Consultant        Fax:   +44 (181) 994 6472
and Technical Director      Email: ben@algroup.co.uk
A.L. Digital Ltd,           URL: http://www.algroup.co.uk
London, England.