summaryrefslogtreecommitdiff
path: root/lib/libc/gen
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2008-08-22 00:59:35 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2008-08-22 00:59:35 +0000
commitf52d573667ee6db34dccce1bf649afda6999b69f (patch)
treea3b863866479c140635b8fc77a6743071787f3bd /lib/libc/gen
parentf3d83f194b18eb041dddfc6bc21481dc7b54a543 (diff)
After spotting a + record, continue scanning and pick up later groups
in the file. Problem spotted by drahn. ok millert
Diffstat (limited to 'lib/libc/gen')
-rw-r--r--lib/libc/gen/getgrouplist.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/libc/gen/getgrouplist.c b/lib/libc/gen/getgrouplist.c
index a3952c19055..23ef7d33bd2 100644
--- a/lib/libc/gen/getgrouplist.c
+++ b/lib/libc/gen/getgrouplist.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getgrouplist.c,v 1.13 2008/06/24 14:29:45 deraadt Exp $ */
+/* $OpenBSD: getgrouplist.c,v 1.14 2008/08/22 00:59:34 deraadt Exp $ */
/*
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -46,7 +46,8 @@
int
getgrouplist(const char *uname, gid_t agroup, gid_t *groups, int *grpcnt)
{
- int i, ngroups = 0, ret = 0, maxgroups = *grpcnt, bail, foundyp = 0;
+ int i, ngroups = 0, ret = 0, maxgroups = *grpcnt, bail;
+ int needyp = 0, foundyp = 0;
extern struct group *_getgrent_yp(int *);
struct group *grp;
@@ -63,7 +64,12 @@ getgrouplist(const char *uname, gid_t agroup, gid_t *groups, int *grpcnt)
* Scan the group file to find additional groups.
*/
setgrent();
- while ((grp = _getgrent_yp(&foundyp))) {
+ while ((grp = _getgrent_yp(&foundyp)) || foundyp) {
+ if (foundyp) {
+ needyp = 1;
+ foundyp = 0;
+ continue;
+ }
if (grp->gr_gid == agroup)
continue;
for (bail = 0, i = 0; bail == 0 && i < ngroups; i++)
@@ -87,7 +93,7 @@ getgrouplist(const char *uname, gid_t agroup, gid_t *groups, int *grpcnt)
/*
* If we were told that there is a YP marker, look there now.
*/
- if (foundyp) {
+ if (needyp) {
char buf[1024], *ypdata = NULL, *key, *p;
const char *errstr = NULL;
static char *__ypdomain;