Home | History | Annotate | Download | only in gen
History log of /src/lib/libc/gen/getgrent.c
RevisionDateAuthorComments
 1.67  29-Aug-2012  dholland Check for NULL *before* using ALIGN().

I don't remember what prompted this, but it's obviously a desirable fix
and I've been carrying it on a heavily-used machine for more than a year.
 1.66  29-Mar-2012  christos PR?40728: W. Stukenbrock: Fix various issues with NIS-netgroups in users
and groups.
 1.65  13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.64  15-Oct-2011  christos branches: 1.64.2;
close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")
 1.63  09-Jun-2011  sjg _gr_copy() can get called with fromgrp->gr_mem == NULL.
 1.62  28-Apr-2008  martin branches: 1.62.6; 1.62.8; 1.62.22;
Remove clause 3 and 4 from TNF licenses
 1.61  03-Feb-2007  christos branches: 1.61.10;
make this compile with DIAGNOSTIC
 1.60  15-Oct-2006  christos fix incomplete initializers
 1.59  19-Mar-2006  christos iCoverity CID 706: Remove dead code.
 1.58  19-Apr-2005  lukem When sequentially parsing a source looking for entries don't fail with
NS_UNAVAIL on an unparseable or too long line; instead try the next entry.
This is more consistent with the behaviour prior to the rework in rev 1.49.
 1.57  19-Apr-2005  lukem getgrent():
Return the correct result. (broken in rev 1.56 -- Hi Christos!)

getgr{ent,nam,uid}_r():
Return 0 "entry not found" and errno for other failures.
("entry not found" still sets *result to NULL).

Various backends:
don't set the retval to errno (or modify errno) for NS_NOTFOUND.

Per discussion with Klaus Klein.
 1.56  02-Apr-2005  christos PR/29849, PR/29850: Add getpwent_r and getgrent_r
 1.55  31-Mar-2005  lukem tweak comment reminding us about lack of reentrancy
 1.54  06-Jan-2005  lukem branches: 1.54.2;
Rename various "internal" variables and functions and make non-static so other
internal libc source files can use these (including getgroupmembership(3)).

Be more consistent in the API that the __grscan_<source>() methods use.

In __grscan_compat() support an optional custom 'search' function used when a
"+" lookup is required. Normally this will be getgrent() from group_compat,
but getgroupmembership(3) will use a tailored compat search routine for
efficiency.
 1.53  10-Nov-2004  lukem Use the common __nsdefaultFOO rather than private defaultFOO duplicates.
 1.52  10-Nov-2004  lukem Use _GETGR_R_SIZE_MAX from <limits.h> rather than defining a private version.
 1.51  29-Oct-2004  lukem #include "reentrant.h" instead of <threadlib.h>
 1.50  24-Oct-2004  lukem Protect access to all public functions via a mutex as some of the backends are
not reentrant (such as compat getgr*_r, because it uses the non reentrant
_{dns,nis}_getgrent() backends to implement `+group').
 1.49  04-Oct-2004  lukem Overhaul the use of nsdispatch(3) by public APIs so that the back-end
methods use va_list in a manner that is directly related to the public API.
This makes it much easier to write dynamic nsswitch backends for getgrent(3).
Per my proposal on tech-userlevel.

Implement getgrgid_r() and getgrnam_r() APIs per the POSIX 1003.1, 2004 Ed.
These aren't fully reentrant or threadsafe yet, because the compat stuff
currently uses non-reentrant data sources (getnetgrent(3), getgrent(3)),
and there is probably some locking to be improved in the backends.
This will be fixed in the near future.
We also need to add _SC_GETGR_R_SIZE_MAX to sysconf(3).
 1.48  13-Oct-2003  agc Move Jason Downs's code from a 4-clause to a 3-clause licence by
removing the advertising clause. Diffs provided in PR 22410 by Joel
Baker, confirmed to the board by Jason Downs.

With additional thanks to Jason Thorpe.
 1.47  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.46  17-Feb-2003  simonb Fix a tyop in a comment.
 1.45  16-Feb-2003  elric Reorganise the getting of grouplists for a user so that Hesiod (and
potentially other name services) can directly query for a user's
grouplist rather than needing to iterate over the group map. This
is required for correct operation of Hesiod.

Reviewed by: lukem, christos
Addresses PR lib/20183
 1.44  03-Feb-2003  elric When looking up gids with hesiod, use the gid map and fall back to the
group map.

Addresses PR lib/20145
 1.43  17-Nov-2002  itojun use strlcpy where it is more appropriate.
 1.42  02-Feb-2002  lukem be consistent with internal names: s/start_gr/grstart/ ; s/matchline/gr&/
 1.41  12-Jan-2002  lukem ansi knf
 1.40  17-Dec-2000  lukem branches: 1.40.2;
fix typo in _nis_grscan(). "if (data); free(data);" -> "if (data) free(data);"
noted by Jacques Vidrine <nectar@FreeBSD.org>
 1.39  22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.38  20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.37  16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.36  25-Apr-1999  lukem change getgrent() backends so that a flag (per source) is set once the
source has been exhausted. this allows getgrent() across multiple
sources (e.g, ``group: files nis'') to work correctly. the flags are
reset in setgrent()/endgrent().

(as per similar change in getpwent.c rev 1.42)

XXX: this change means that code that uses getgrent() to obtain a list
of groups will have to do duplicate suppression... getgrouplist()
springs to mind; i'm about to modify that
 1.35  18-Apr-1999  lukem specifically include stdarg/varargs.h
 1.34  26-Jan-1999  lukem branches: 1.34.2;
always compile in support for `compat' backends (even if !YP & !HESIOD),
and make it the responsibility of the backends to fallback to `files'
if !YP & !HESIOD. fixes chsh problem noted by billc@netbsd.org.
 1.33  25-Jan-1999  lukem convert from hes_*() -> hesiod_*()
 1.32  20-Jan-1999  lukem nsdispatch defaults now: "group: compat", "group_compat: nis"
 1.31  19-Jan-1999  lukem * `passwd' defaults to `compat', and `passwd_compat' defaults to `nis'
* constify ns_dtab defs
 1.30  19-Jan-1999  lukem convert to new nsdispatch(3)
 1.29  18-Jan-1999  christos delint
 1.28  16-Jan-1999  lukem fix some gid casts
 1.27  16-Jan-1999  lukem pull nsswitch up to main branch
 1.26  26-Aug-1998  perry fix bcopy->memcpy with memcpy->memmove -- not strictly needed, but...
 1.25  10-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.24  27-Jul-1998  mycroft Make these compile without __AUDIT__.
 1.23  26-Jul-1998  mycroft const poisoning.
 1.22  26-Feb-1998  perry trivial changes to reduce lint complaints
 1.21  21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.20  13-Jul-1997  christos Add missing prototypes
Fix RCSID's
Fix gcc warnings
 1.19  22-May-1997  lukem branches: 1.19.2;
a valid uid/gid *ends* in \0 (i.e, barf if (*ep != '\0'), not if (*ep == '\0'))
 1.18  22-May-1997  lukem * parse gid with strtoul() instead of atoi(), and sanity check a) the parsed
value was just a number, b) it doesn't exceed GID_MAX
* convert gid to a string with %u not %d
* use [gu]id_t instead of int
 1.17  21-May-1997  lukem fix potential memory leaks: before calling yp_next(), reset key to NULL. if
an error occurred, and key != NULL, free(key).
 1.16  20-May-1997  lukem * ensure that "outdata" values to various yp_xxx() functions are set
to the null pointer before invocation, so that the test in the
error case of "if (outdata != NULL) free(outdata)" won't potentially
try and free memory that wasn't malloc()ed.
* factor some duplicated code out of both parts of an "if {} else {}"
construct.
* remove use of `register' & KNFify.
 1.15  22-Jan-1997  thorpej Don't transfer the entire YP database using yp_{first,next}(); instead
use yp_match(), which is much more efficient.

From Michael.Eriksson@era-t.ericsson.se, PR #3114.
 1.14  20-Dec-1996  cgd grscan()'s last arg has to be a const char *, not just a char *
 1.13  28-Jul-1995  phil branches: 1.13.4; 1.13.8;
Improvements to YP support from Jason Downs.
 1.12  16-Mar-1995  pk Speed up getgrnam() and getgrpid() by using yp_match().
 1.11  27-Feb-1995  cgd update from Lite, with local changes. fix Ids, etc.
 1.10  02-Aug-1994  deraadt be lenient; let a few other forms of + activate YP
 1.9  29-Jul-1994  deraadt avoid core dump
 1.8  07-Mar-1994  deraadt branches: 1.8.2;
better, more forgiving solution to previous problem.
 1.7  06-Mar-1994  deraadt fix small obscure YP buglet, and properly terminate gr_mem
 1.6  24-Nov-1993  jtc Change C library functions to use strchr() and strrchr() instead of index()
and rindex(). This will allow (strict {ANSI, POSIX, XOPEN}) applications
to redefine index() and rindex() without effecting the library internals.
 1.5  25-Oct-1993  jtc Update source and manual pages to match X/Open 1170 specification.
Updated setpassent() to understand YP (a bug), and changed setpwent()
to simply be a call to setpassent(0) (to remove duplicated code).
 1.4  26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.3  30-Jul-1993  mycroft Add even more RCS frobs.
 1.2  04-May-1993  deraadt I was horrified to find these had not been commited with the YP changes.
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2  25-Feb-1995  cgd from lite, with minor name rearrangement to fit.
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.8.2.2  03-Aug-1994  cgd from trunk.
 1.8.2.1  01-Aug-1994  cgd from trunk
 1.13.8.1  06-Nov-1996  lukem initial nsswitch implementation
 1.13.4.1  19-Sep-1996  jtc snapshot namespace cleanup: gen
 1.19.2.5  14-Jan-1999  lukem use new ns_dtab structure
 1.19.2.4  02-Nov-1998  lukem sync with current
 1.19.2.3  02-Jun-1997  lukem * during getgrent(), set _gr_none = 1 and return NS_SUCCESS upon EOF.
this prevents the sources being "merged" by default, which caused
problems with getgrouplist() and NIS
* use gid_t instead of int in the appropriate locations
* minor formatting fixes
 1.19.2.2  26-May-1997  lukem only initialise ns_dtab if it hasn't been done yet
 1.19.2.1  24-May-1997  lukem convert to use nsdispatch()
 1.34.2.1  27-Apr-1999  perry pullup 1.35->1.36 (lukem)
 1.40.2.4  10-Dec-2002  thorpej Sync with HEAD.
 1.40.2.3  22-Mar-2002  nathanw Catch up to -current.
 1.40.2.2  08-Mar-2002  nathanw Catch up to -current.
 1.40.2.1  28-Jan-2002  nathanw Catch up to -current.
 1.54.2.4  11-Jul-2005  tron Pull up revision 1.58 (requested by lukem in ticket #540):
When sequentially parsing a source looking for entries don't fail with
NS_UNAVAIL on an unparseable or too long line; instead try the next entry.
This is more consistent with the behaviour prior to the rework in rev 1.49.
 1.54.2.3  11-Jul-2005  tron Pull up revision 1.57 (requested by lukem in ticket #540):
getgrent():
Return the correct result. (broken in rev 1.56 -- Hi Christos!)
getgr{ent,nam,uid}_r():
Return 0 "entry not found" and errno for other failures.
("entry not found" still sets *result to NULL).
Various backends:
don't set the retval to errno (or modify errno) for NS_NOTFOUND.
Per discussion with Klaus Klein.
 1.54.2.2  11-Jul-2005  tron Pull up revision 1.56 (requested by lukem in ticket #540):
PR/29849, PR/29850: Add getpwent_r and getgrent_r
 1.54.2.1  11-Jul-2005  tron Pull up revision 1.55 (requested by lukem in ticket #540):
tweak comment reminding us about lack of reentrancy
 1.61.10.1  18-May-2008  yamt sync with head.
 1.62.22.1  23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.62.8.2  28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.62.8.1  28-Apr-2008  martin file getgrent.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
 1.62.6.1  18-Jun-2011  bouyer Pull up following revision(s) (requested by sjg in ticket #1636):
lib/libc/gen/getgrent.c: revision 1.63
_gr_copy() can get called with fromgrp->gr_mem == NULL.
 1.64.2.2  30-Oct-2012  yamt sync with head
 1.64.2.1  17-Apr-2012  yamt sync with head

RSS XML Feed