summaryrefslogtreecommitdiffstats
path: root/man3/getpwnam.3
diff options
context:
space:
mode:
Diffstat (limited to 'man3/getpwnam.3')
-rw-r--r--man3/getpwnam.337
1 files changed, 24 insertions, 13 deletions
diff --git a/man3/getpwnam.3 b/man3/getpwnam.3
index 2557f8b31..3e6af831d 100644
--- a/man3/getpwnam.3
+++ b/man3/getpwnam.3
@@ -15,7 +15,7 @@
.\" Modified 2003-11-15 by aeb
.\" 2008-11-07, mtk, Added an example program for getpwnam_r().
.\"
-.TH getpwnam 3 2023-02-05 "Linux man-pages 6.03"
+.TH getpwnam 3 2023-07-20 "Linux man-pages 6.05.01"
.SH NAME
getpwnam, getpwnam_r, getpwuid, getpwuid_r \- get password file entry
.SH LIBRARY
@@ -201,38 +201,49 @@ local password database file
.SH ATTRIBUTES
For an explanation of the terms used in this section, see
.BR attributes (7).
-.ad l
-.nh
.TS
allbox;
lb lb lbx
l l l.
Interface Attribute Value
T{
+.na
+.nh
.BR getpwnam ()
T} Thread safety T{
+.na
+.nh
MT-Unsafe race:pwnam locale
T}
T{
+.na
+.nh
.BR getpwuid ()
T} Thread safety T{
+.na
+.nh
MT-Unsafe race:pwuid locale
T}
T{
+.na
+.nh
.BR getpwnam_r (),
.BR getpwuid_r ()
T} Thread safety T{
+.na
+.nh
MT-Safe locale
T}
.TE
-.hy
-.ad
.sp 1
-.SH STANDARDS
-POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
+.SH VERSIONS
The
.I pw_gecos
field is not specified in POSIX, but is present on most implementations.
+.SH STANDARDS
+POSIX.1-2008.
+.SH HISTORY
+POSIX.1-2001, SVr4, 4.3BSD.
.SH NOTES
The formulation given above under "RETURN VALUE" is from POSIX.1-2001.
It does not call "not found" an error, and hence does not specify what value
@@ -286,7 +297,7 @@ supplied as a command-line argument.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-
+\&
int
main(int argc, char *argv[])
{
@@ -295,22 +306,22 @@ main(int argc, char *argv[])
char *buf;
long bufsize;
int s;
-
+\&
if (argc != 2) {
fprintf(stderr, "Usage: %s username\en", argv[0]);
exit(EXIT_FAILURE);
}
-
+\&
bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
if (bufsize == \-1) /* Value was indeterminate */
bufsize = 16384; /* Should be more than enough */
-
+\&
buf = malloc(bufsize);
if (buf == NULL) {
perror("malloc");
exit(EXIT_FAILURE);
}
-
+\&
s = getpwnam_r(argv[1], &pwd, buf, bufsize, &result);
if (result == NULL) {
if (s == 0)
@@ -321,7 +332,7 @@ main(int argc, char *argv[])
}
exit(EXIT_FAILURE);
}
-
+\&
printf("Name: %s; UID: %jd\en", pwd.pw_gecos,
(intmax_t) pwd.pw_uid);
exit(EXIT_SUCCESS);