summaryrefslogtreecommitdiff
path: root/lib/libc/gen
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2009-06-23 18:52:44 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2009-06-23 18:52:44 +0000
commitae760cb4d6f616a71ce773c06a94040c0a8102ec (patch)
tree06a602c00e2031ada2dbde9df5743d8ec6696f2f /lib/libc/gen
parent7258d319d45b4a43db079b89a93a204c2253e218 (diff)
getgrouplist(3) used to and ought to return 0 on success;
fixing a regression introduced in rev. 1.16 spotted by otto@; ok millert@ otto@
Diffstat (limited to 'lib/libc/gen')
-rw-r--r--lib/libc/gen/getgrouplist.38
-rw-r--r--lib/libc/gen/getgrouplist.c18
2 files changed, 17 insertions, 9 deletions
diff --git a/lib/libc/gen/getgrouplist.3 b/lib/libc/gen/getgrouplist.3
index 5f180ec314c..18ec46f98c4 100644
--- a/lib/libc/gen/getgrouplist.3
+++ b/lib/libc/gen/getgrouplist.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: getgrouplist.3,v 1.15 2009/06/03 16:02:44 schwarze Exp $
+.\" $OpenBSD: getgrouplist.3,v 1.16 2009/06/23 18:52:43 schwarze Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -27,7 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd $Mdocdate: June 3 2009 $
+.Dd $Mdocdate: June 23 2009 $
.Dt GETGROUPLIST 3
.Os
.Sh NAME
@@ -70,8 +70,8 @@ the actual number of groups found is returned in
.Sh RETURN VALUES
The
.Fn getgrouplist
-function returns \-1 if the size of the group list is too small to
-hold all the user's groups.
+function returns 0 if successful and \-1 if the size of the group list is
+too small to hold all the user's groups.
Here, the group array will be filled with as many groups as will fit.
.Sh FILES
.Bl -tag -width /etc/group -compact
diff --git a/lib/libc/gen/getgrouplist.c b/lib/libc/gen/getgrouplist.c
index 9b3d5fff649..d8dff264d8a 100644
--- a/lib/libc/gen/getgrouplist.c
+++ b/lib/libc/gen/getgrouplist.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getgrouplist.c,v 1.17 2009/06/03 16:02:44 schwarze Exp $ */
+/* $OpenBSD: getgrouplist.c,v 1.18 2009/06/23 18:52:43 schwarze Exp $ */
/*
* Copyright (c) 2008 Ingo Schwarze <schwarze@usta.de>
* Copyright (c) 1991, 1993
@@ -209,16 +209,24 @@ getgrouplist(const char *uname, gid_t agroup, gid_t *groups, int *grpcnt)
goto out;
/* First scan the static netid file. */
- if (ret = _read_netid(key, pwstore.pw_uid,
- groups, &ngroups, maxgroups))
+ switch (_read_netid(key, pwstore.pw_uid,
+ groups, &ngroups, maxgroups)) {
+ case -1:
+ ret = -1;
+ /* FALLTHROUGH */
+ case 1:
goto out;
+ default:
+ break;
+ }
/* Only access YP when there is no static entry. */
if (!yp_bind(__ypdomain) &&
!yp_match(__ypdomain, "netid.byname", key,
(int)strlen(key), &ypdata, &ypdatalen))
- ret = _parse_netid(ypdata, pwstore.pw_uid,
- groups, &ngroups, maxgroups);
+ if (_parse_netid(ypdata, pwstore.pw_uid,
+ groups, &ngroups, maxgroups) == -1)
+ ret = -1;
free(key);
free(ypdata);