Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/gen suppress duplicate gids (e.g, when multiple sou...
details: https://anonhg.NetBSD.org/src/rev/fda080445e4d
branches: trunk
changeset: 472223:fda080445e4d
user: lukem <lukem%NetBSD.org@localhost>
date: Sun Apr 25 14:47:46 1999 +0000
description:
suppress duplicate gids (e.g, when multiple sources are given in
nsswitch.conf and they contain similar information).
XXX: in the case where the given array is too small and -1 is returned,
the returned ngroups will be too large by a factor of the difference
between the given size and the number of matches. this is not considered
to be a major problem, since it's still going to be a smaller figure than
what the previous (non suppressive) behaviour returned.
diffstat:
lib/libc/gen/getgrouplist.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diffs (49 lines):
diff -r e3c32311250b -r fda080445e4d lib/libc/gen/getgrouplist.c
--- a/lib/libc/gen/getgrouplist.c Sun Apr 25 13:47:37 1999 +0000
+++ b/lib/libc/gen/getgrouplist.c Sun Apr 25 14:47:46 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getgrouplist.c,v 1.11 1999/04/08 17:07:02 drochner Exp $ */
+/* $NetBSD: getgrouplist.c,v 1.12 1999/04/25 14:47:46 lukem Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)getgrouplist.c 8.2 (Berkeley) 12/8/94";
#else
-__RCSID("$NetBSD: getgrouplist.c,v 1.11 1999/04/08 17:07:02 drochner Exp $");
+__RCSID("$NetBSD: getgrouplist.c,v 1.12 1999/04/25 14:47:46 lukem Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -46,10 +46,11 @@
* get credential
*/
#include "namespace.h"
-#include <sys/types.h>
+#include <sys/param.h>
+
+#include <grp.h>
#include <string.h>
#include <unistd.h>
-#include <grp.h>
#ifdef __weak_alias
__weak_alias(getgrouplist,_getgrouplist);
@@ -83,11 +84,16 @@
* Scan the group file to find additional groups.
*/
setgrent();
+ nextgroup:
while ((grp = getgrent()) != NULL) {
if (grp->gr_gid == agroup)
continue;
for (i = 0; grp->gr_mem[i]; i++) {
if (!strcmp(grp->gr_mem[i], uname)) {
+ for (i = 0; i < MIN(ngroups, maxgroups); i++) {
+ if (grp->gr_gid == groups[i])
+ goto nextgroup;
+ }
if (ngroups < maxgroups)
groups[ngroups] = grp->gr_gid;
else
Home |
Main Index |
Thread Index |
Old Index