summaryrefslogtreecommitdiffstats
path: root/man3/getgrouplist.3
diff options
context:
space:
mode:
Diffstat (limited to 'man3/getgrouplist.3')
-rw-r--r--man3/getgrouplist.336
1 files changed, 17 insertions, 19 deletions
diff --git a/man3/getgrouplist.3 b/man3/getgrouplist.3
index 4b514e0aa..0fe3690b7 100644
--- a/man3/getgrouplist.3
+++ b/man3/getgrouplist.3
@@ -7,7 +7,7 @@
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
-.TH getgrouplist 3 2023-02-05 "Linux man-pages 6.03"
+.TH getgrouplist 3 2023-07-20 "Linux man-pages 6.05.01"
.SH NAME
getgrouplist \- get list of groups to which a user belongs
.SH LIBRARY
@@ -83,27 +83,25 @@ In this case, the value returned in
.I *ngroups
can be used to resize the buffer passed to a further call to
.BR getgrouplist ().
-.SH VERSIONS
-This function is present since glibc 2.2.4.
.SH ATTRIBUTES
For an explanation of the terms used in this section, see
.BR attributes (7).
-.ad l
-.nh
.TS
allbox;
lbx lb lb
l l l.
Interface Attribute Value
T{
+.na
+.nh
.BR getgrouplist ()
T} Thread safety MT-Safe locale
.TE
-.hy
-.ad
.sp 1
.SH STANDARDS
-This function is nonstandard; it appears on most BSDs.
+None.
+.SH HISTORY
+glibc 2.2.4.
.SH BUGS
Before glibc 2.3.3,
the implementation of this function contains a buffer-overrun bug:
@@ -141,7 +139,7 @@ ngroups = 3
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
-
+\&
int
main(int argc, char *argv[])
{
@@ -149,38 +147,38 @@ main(int argc, char *argv[])
struct passwd *pw;
struct group *gr;
gid_t *groups;
-
+\&
if (argc != 3) {
fprintf(stderr, "Usage: %s <user> <ngroups>\en", argv[0]);
exit(EXIT_FAILURE);
}
-
+\&
ngroups = atoi(argv[2]);
-
+\&
groups = malloc(sizeof(*groups) * ngroups);
if (groups == NULL) {
perror("malloc");
exit(EXIT_FAILURE);
}
-
+\&
/* Fetch passwd structure (contains first group ID for user). */
-
+\&
pw = getpwnam(argv[1]);
if (pw == NULL) {
perror("getpwnam");
exit(EXIT_SUCCESS);
}
-
+\&
/* Retrieve group list. */
-
+\&
if (getgrouplist(argv[1], pw\->pw_gid, groups, &ngroups) == \-1) {
fprintf(stderr, "getgrouplist() returned \-1; ngroups = %d\en",
ngroups);
exit(EXIT_FAILURE);
}
-
+\&
/* Display list of retrieved groups, along with group names. */
-
+\&
fprintf(stderr, "ngroups = %d\en", ngroups);
for (size_t j = 0; j < ngroups; j++) {
printf("%d", groups[j]);
@@ -189,7 +187,7 @@ main(int argc, char *argv[])
printf(" (%s)", gr\->gr_name);
printf("\en");
}
-
+\&
exit(EXIT_SUCCESS);
}
.EE