summaryrefslogtreecommitdiffstats
path: root/upstream/debian-unstable/man3/getgrouplist.3
diff options
context:
space:
mode:
Diffstat (limited to 'upstream/debian-unstable/man3/getgrouplist.3')
-rw-r--r--upstream/debian-unstable/man3/getgrouplist.336
1 files changed, 20 insertions, 16 deletions
diff --git a/upstream/debian-unstable/man3/getgrouplist.3 b/upstream/debian-unstable/man3/getgrouplist.3
index 0fe3690b..8b86cbec 100644
--- a/upstream/debian-unstable/man3/getgrouplist.3
+++ b/upstream/debian-unstable/man3/getgrouplist.3
@@ -7,7 +7,7 @@
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
-.TH getgrouplist 3 2023-07-20 "Linux man-pages 6.05.01"
+.TH getgrouplist 3 2024-05-02 "Linux man-pages 6.8"
.SH NAME
getgrouplist \- get list of groups to which a user belongs
.SH LIBRARY
@@ -16,16 +16,16 @@ Standard C library
.SH SYNOPSIS
.nf
.B #include <grp.h>
-.PP
+.P
.BI "int getgrouplist(const char *" user ", gid_t " group ,
.BI " gid_t *" groups ", int *" ngroups );
.fi
-.PP
+.P
.RS -4
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.RE
-.PP
+.P
.BR getgrouplist ():
.nf
Since glibc 2.19:
@@ -45,7 +45,7 @@ Up to
.I *ngroups
of these groups are returned in the array
.IR groups .
-.PP
+.P
If it was not among the groups defined for
.I user
in the group database, then
@@ -55,7 +55,7 @@ is included in the list of groups returned by
typically this argument is specified as the group ID from
the password record for
.IR user .
-.PP
+.P
The
.I ngroups
argument is a value-result argument:
@@ -73,7 +73,7 @@ is a member is less than or equal to
then the value
.I *ngroups
is returned.
-.PP
+.P
If the user is a member of more than
.I *ngroups
groups, then
@@ -97,7 +97,6 @@ T{
.BR getgrouplist ()
T} Thread safety MT-Safe locale
.TE
-.sp 1
.SH STANDARDS
None.
.SH HISTORY
@@ -119,7 +118,7 @@ The second command-line argument specifies the
value to be supplied to
.BR getgrouplist ().
The following shell session shows examples of the use of this program:
-.PP
+.P
.in +4n
.EX
.RB "$" " ./a.out cecilia 0"
@@ -135,6 +134,7 @@ ngroups = 3
\&
.\" SRC BEGIN (getgrouplist.c)
.EX
+#include <errno.h>
#include <grp.h>
#include <pwd.h>
#include <stdio.h>
@@ -143,10 +143,10 @@ ngroups = 3
int
main(int argc, char *argv[])
{
- int ngroups;
- struct passwd *pw;
- struct group *gr;
- gid_t *groups;
+ int ngroups;
+ gid_t *groups;
+ struct group *gr;
+ struct passwd *pw;
\&
if (argc != 3) {
fprintf(stderr, "Usage: %s <user> <ngroups>\en", argv[0]);
@@ -163,10 +163,14 @@ main(int argc, char *argv[])
\&
/* Fetch passwd structure (contains first group ID for user). */
\&
+ errno = 0;
pw = getpwnam(argv[1]);
if (pw == NULL) {
- perror("getpwnam");
- exit(EXIT_SUCCESS);
+ if (errno)
+ perror("getpwnam");
+ else
+ fprintf(stderr, "no such user\en");
+ exit(EXIT_FAILURE);
}
\&
/* Retrieve group list. */
@@ -180,7 +184,7 @@ main(int argc, char *argv[])
/* Display list of retrieved groups, along with group names. */
\&
fprintf(stderr, "ngroups = %d\en", ngroups);
- for (size_t j = 0; j < ngroups; j++) {
+ for (int j = 0; j < ngroups; j++) {
printf("%d", groups[j]);
gr = getgrgid(groups[j]);
if (gr != NULL)