summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2008-08-22 00:59:34 +0000
committerderaadt <deraadt@openbsd.org>2008-08-22 00:59:34 +0000
commitd9c22d3cdd94a2adaf9636f92ff716eff79ba7fe (patch)
tree9bb14f8415d930c8ba64ea7c9399616f5277e89d /lib
parentReplace the old algorithm that included the process id as part of the (diff)
downloadwireguard-openbsd-d9c22d3cdd94a2adaf9636f92ff716eff79ba7fe.tar.xz
wireguard-openbsd-d9c22d3cdd94a2adaf9636f92ff716eff79ba7fe.zip
After spotting a + record, continue scanning and pick up later groups
in the file. Problem spotted by drahn. ok millert
Diffstat (limited to 'lib')
-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;