summaryrefslogtreecommitdiff
path: root/lib/libc/gen/getpwent.3
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2008-06-24 14:27:27 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2008-06-24 14:27:27 +0000
commit3c00af7e9ff7ae6d3fd059414ddfacb8b93b6254 (patch)
tree6351c162a7187ca965cd914033181351c0ea1b76 /lib/libc/gen/getpwent.3
parent53ad4afa4c64d3779defb74205750e18bc153077 (diff)
implement getpwnam_r() and getpwuid_r() -- very nearly a rewrite of the
entire file. much help from kurt, and tested by many
Diffstat (limited to 'lib/libc/gen/getpwent.3')
-rw-r--r--lib/libc/gen/getpwent.334
1 files changed, 32 insertions, 2 deletions
diff --git a/lib/libc/gen/getpwent.3 b/lib/libc/gen/getpwent.3
index 86d2565607a..c2a1d733743 100644
--- a/lib/libc/gen/getpwent.3
+++ b/lib/libc/gen/getpwent.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: getpwent.3,v 1.21 2007/05/31 19:19:28 jmc Exp $
+.\" $OpenBSD: getpwent.3,v 1.22 2008/06/24 14:27:24 deraadt Exp $
.\"
.\" Copyright (c) 1988, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -27,13 +27,15 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd $Mdocdate: May 31 2007 $
+.Dd $Mdocdate: June 24 2008 $
.Dt GETPWENT 3
.Os
.Sh NAME
.Nm getpwent ,
.Nm getpwnam ,
.Nm getpwuid ,
+.Nm getpwnam_r ,
+.Nm getpwuid_r ,
.Nm setpassent ,
.Nm setpwent ,
.Nm endpwent
@@ -48,6 +50,10 @@
.Ft struct passwd *
.Fn getpwuid "uid_t uid"
.Ft int
+.Fn getpwnam_r "const char *login" "struct passwd *pwstore" "char *buf" "size_t buflen" "struct passwd **result"
+.Ft int
+.Fn getpwuid_r "uid_t uid" "struct passwd *pwstore" "char *buf" "size_t buflen" "struct passwd **result"
+.Ft int
.Fn setpassent "int stayopen"
.Ft void
.Fn setpwent void
@@ -82,6 +88,18 @@ and
search the password database for the given login name or user ID,
respectively, always returning the first one encountered.
.Pp
+The re-entrant functions
+.Fn getpwnam_r
+and
+.Fn getpwuid_r
+search the password database for the given login name or user ID,
+respectively, always returning the first one encountered.
+The various strings associated with the result are stored in
+.Va buf ,
+and
+.Va pwstore
+is updated to point at those strings.
+.Pp
.Fn getpwent
sequentially reads the password database and is intended for programs
that wish to process the complete list of users.
@@ -131,6 +149,17 @@ and
.Fn getpwuid
return a valid pointer to a passwd structure on success
or a null pointer if end-of-file is reached or an error occurs.
+.Pp
+The functions
+.Fn getpwnam_r
+and
+.Fn getpwuid_r
+update
+.Va result
+to point to
+.Va pwstore
+and then return 0 on success.
+.Pp
The
.Fn setpassent
function returns 0 on failure or 1 on success.
@@ -153,6 +182,7 @@ a Version 7 format password file
.Sh SEE ALSO
.Xr getlogin 2 ,
.Xr getgrent 3 ,
+.Xr getgrouplist 3 ,
.Xr pw_dup 3 ,
.Xr passwd 5 ,
.Xr pwd_mkdb 8 ,