1 /* Copyright (C) 1991-2014 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
19 * POSIX Standard: 9.2.2 User Database Access <pwd.h>
29 #include <bits/types.h>
34 #if defined __USE_XOPEN || defined __USE_XOPEN2K
35 /* The Single Unix specification says that some more types are
37 # ifndef __gid_t_defined
38 typedef __gid_t gid_t
;
39 # define __gid_t_defined
42 # ifndef __uid_t_defined
43 typedef __uid_t uid_t
;
44 # define __uid_t_defined
48 /* The passwd structure. */
51 char *pw_name
; /* Username. */
52 char *pw_passwd
; /* Password. */
53 __uid_t pw_uid
; /* User ID. */
54 __gid_t pw_gid
; /* Group ID. */
55 char *pw_gecos
; /* Real name. */
56 char *pw_dir
; /* Home directory. */
57 char *pw_shell
; /* Shell program. */
61 #if defined __USE_MISC || defined __USE_GNU
67 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
68 /* Rewind the password-file stream.
70 This function is a possible cancellation point and therefore not
71 marked with __THROW. */
72 extern void setpwent (void);
74 /* Close the password-file stream.
76 This function is a possible cancellation point and therefore not
77 marked with __THROW. */
78 extern void endpwent (void);
80 /* Read an entry from the password-file stream, opening it if necessary.
82 This function is a possible cancellation point and therefore not
83 marked with __THROW. */
84 extern struct passwd
*getpwent (void);
88 /* Read an entry from STREAM.
90 This function is not part of POSIX and therefore no official
91 cancellation point. But due to similarity with an POSIX interface
92 or due to the implementation it is a cancellation point and
93 therefore not marked with __THROW. */
94 extern struct passwd
*fgetpwent (FILE *__stream
);
96 /* Write the given entry onto the given stream.
98 This function is not part of POSIX and therefore no official
99 cancellation point. But due to similarity with an POSIX interface
100 or due to the implementation it is a cancellation point and
101 therefore not marked with __THROW. */
102 extern int putpwent (const struct passwd
*__restrict __p
,
103 FILE *__restrict __f
);
106 /* Search for an entry with a matching user ID.
108 This function is a possible cancellation point and therefore not
109 marked with __THROW. */
110 extern struct passwd
*getpwuid (__uid_t __uid
);
112 /* Search for an entry with a matching username.
114 This function is a possible cancellation point and therefore not
115 marked with __THROW. */
116 extern struct passwd
*getpwnam (const char *__name
);
118 #if defined __USE_POSIX || defined __USE_MISC
121 /* Reasonable value for the buffer sized used in the reentrant
122 functions below. But better use `sysconf'. */
123 # define NSS_BUFLEN_PASSWD 1024
126 /* Reentrant versions of some of the functions above.
128 PLEASE NOTE: the `getpwent_r' function is not (yet) standardized.
129 The interface may change in later versions of this library. But
130 the interface is designed following the principals used for the
131 other reentrant functions so the chances are good this is what the
132 POSIX people would choose. */
135 /* This function is not part of POSIX and therefore no official
136 cancellation point. But due to similarity with an POSIX interface
137 or due to the implementation it is a cancellation point and
138 therefore not marked with __THROW. */
139 extern int getpwent_r (struct passwd
*__restrict __resultbuf
,
140 char *__restrict __buffer
, size_t __buflen
,
141 struct passwd
**__restrict __result
);
144 extern int getpwuid_r (__uid_t __uid
,
145 struct passwd
*__restrict __resultbuf
,
146 char *__restrict __buffer
, size_t __buflen
,
147 struct passwd
**__restrict __result
);
149 extern int getpwnam_r (const char *__restrict __name
,
150 struct passwd
*__restrict __resultbuf
,
151 char *__restrict __buffer
, size_t __buflen
,
152 struct passwd
**__restrict __result
);
156 /* Read an entry from STREAM. This function is not standardized and
159 This function is not part of POSIX and therefore no official
160 cancellation point. But due to similarity with an POSIX interface
161 or due to the implementation it is a cancellation point and
162 therefore not marked with __THROW. */
163 extern int fgetpwent_r (FILE *__restrict __stream
,
164 struct passwd
*__restrict __resultbuf
,
165 char *__restrict __buffer
, size_t __buflen
,
166 struct passwd
**__restrict __result
);
169 #endif /* POSIX or reentrant */
172 /* Re-construct the password-file line for the given uid
173 in the given buffer. This knows the format that the caller
174 will expect, but this need not be the format of the password file.
176 This function is not part of POSIX and therefore no official
177 cancellation point. But due to similarity with an POSIX interface
178 or due to the implementation it is a cancellation point and
179 therefore not marked with __THROW. */
180 extern int getpw (__uid_t __uid
, char *__buffer
);