]>
Commit | Line | Data |
---|---|---|
2b778ceb | 1 | /* Copyright (C) 1991-2021 Free Software Foundation, Inc. |
2c6fe0bd | 2 | This file is part of the GNU C Library. |
28f540f4 | 3 | |
2c6fe0bd | 4 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
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. | |
28f540f4 | 8 | |
2c6fe0bd UD |
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 | |
41bdb6e2 | 12 | Lesser General Public License for more details. |
28f540f4 | 13 | |
41bdb6e2 | 14 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 | 15 | License along with the GNU C Library; if not, see |
5a82c748 | 16 | <https://www.gnu.org/licenses/>. */ |
28f540f4 RM |
17 | |
18 | /* | |
19 | * POSIX Standard: 9.2.2 User Database Access <pwd.h> | |
20 | */ | |
21 | ||
22 | #ifndef _PWD_H | |
28f540f4 | 23 | #define _PWD_H 1 |
5107cf1d | 24 | |
28f540f4 RM |
25 | #include <features.h> |
26 | ||
27 | __BEGIN_DECLS | |
28 | ||
5107cf1d | 29 | #include <bits/types.h> |
28f540f4 | 30 | |
0f110f41 TBB |
31 | #define __need_size_t |
32 | #include <stddef.h> | |
28f540f4 | 33 | |
7a80496f | 34 | #if defined __USE_XOPEN || defined __USE_XOPEN2K |
9756dfe1 UD |
35 | /* The Single Unix specification says that some more types are |
36 | available here. */ | |
7df789e0 | 37 | # ifndef __gid_t_defined |
9756dfe1 | 38 | typedef __gid_t gid_t; |
7df789e0 | 39 | # define __gid_t_defined |
9756dfe1 UD |
40 | # endif |
41 | ||
7df789e0 | 42 | # ifndef __uid_t_defined |
9756dfe1 | 43 | typedef __uid_t uid_t; |
7df789e0 | 44 | # define __uid_t_defined |
9756dfe1 UD |
45 | # endif |
46 | #endif | |
47 | ||
841785ba | 48 | /* A record in the user database. */ |
28f540f4 RM |
49 | struct passwd |
50 | { | |
51 | char *pw_name; /* Username. */ | |
841785ba ZW |
52 | char *pw_passwd; /* Hashed passphrase, if shadow database |
53 | not in use (see shadow.h). */ | |
28f540f4 RM |
54 | __uid_t pw_uid; /* User ID. */ |
55 | __gid_t pw_gid; /* Group ID. */ | |
56 | char *pw_gecos; /* Real name. */ | |
57 | char *pw_dir; /* Home directory. */ | |
58 | char *pw_shell; /* Shell program. */ | |
59 | }; | |
60 | ||
61 | ||
acd7f096 | 62 | #ifdef __USE_MISC |
199fc19d | 63 | # include <bits/types/FILE.h> |
28f540f4 RM |
64 | #endif |
65 | ||
28f540f4 | 66 | |
ed9a38e2 | 67 | #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED |
841785ba | 68 | /* Rewind the user database stream. |
28f540f4 | 69 | |
2c008571 UD |
70 | This function is a possible cancellation point and therefore not |
71 | marked with __THROW. */ | |
72 | extern void setpwent (void); | |
28f540f4 | 73 | |
841785ba | 74 | /* Close the user database stream. |
2c008571 UD |
75 | |
76 | This function is a possible cancellation point and therefore not | |
77 | marked with __THROW. */ | |
78 | extern void endpwent (void); | |
79 | ||
841785ba | 80 | /* Read an entry from the user database stream, opening it if necessary. |
2c008571 UD |
81 | |
82 | This function is a possible cancellation point and therefore not | |
83 | marked with __THROW. */ | |
84 | extern struct passwd *getpwent (void); | |
28f540f4 RM |
85 | #endif |
86 | ||
498afc54 | 87 | #ifdef __USE_MISC |
841785ba | 88 | /* Read a user database entry from STREAM. |
2c008571 UD |
89 | |
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. */ | |
61d95397 | 94 | extern struct passwd *fgetpwent (FILE *__stream) __nonnull ((1)); |
2c008571 | 95 | |
841785ba | 96 | /* Write a given user database entry onto the given stream. |
28f540f4 | 97 | |
2c008571 UD |
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. */ | |
a784e502 | 102 | extern int putpwent (const struct passwd *__restrict __p, |
1eb8bf80 | 103 | FILE *__restrict __f); |
28f540f4 RM |
104 | #endif |
105 | ||
841785ba | 106 | /* Retrieve the user database entry for the given user ID. |
28f540f4 | 107 | |
2c008571 UD |
108 | This function is a possible cancellation point and therefore not |
109 | marked with __THROW. */ | |
110 | extern struct passwd *getpwuid (__uid_t __uid); | |
111 | ||
841785ba | 112 | /* Retrieve the user database entry for the given username. |
2c008571 UD |
113 | |
114 | This function is a possible cancellation point and therefore not | |
115 | marked with __THROW. */ | |
61d95397 | 116 | extern struct passwd *getpwnam (const char *__name) __nonnull ((1)); |
28f540f4 | 117 | |
acd7f096 | 118 | #ifdef __USE_POSIX |
19361cb7 | 119 | |
dfd2257a | 120 | # ifdef __USE_MISC |
23396375 UD |
121 | /* Reasonable value for the buffer sized used in the reentrant |
122 | functions below. But better use `sysconf'. */ | |
dfd2257a UD |
123 | # define NSS_BUFLEN_PASSWD 1024 |
124 | # endif | |
23396375 UD |
125 | |
126 | /* Reentrant versions of some of the functions above. | |
127 | ||
84384f5b UD |
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. */ | |
23396375 | 133 | |
ed9a38e2 | 134 | # ifdef __USE_MISC |
2c008571 UD |
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. */ | |
c1422e5b UD |
139 | extern int getpwent_r (struct passwd *__restrict __resultbuf, |
140 | char *__restrict __buffer, size_t __buflen, | |
61d95397 MF |
141 | struct passwd **__restrict __result) |
142 | __nonnull ((1, 2, 4)); | |
dfd2257a | 143 | # endif |
23396375 | 144 | |
c1422e5b UD |
145 | extern int getpwuid_r (__uid_t __uid, |
146 | struct passwd *__restrict __resultbuf, | |
147 | char *__restrict __buffer, size_t __buflen, | |
61d95397 MF |
148 | struct passwd **__restrict __result) |
149 | __nonnull ((2, 3, 5)); | |
23396375 | 150 | |
a784e502 | 151 | extern int getpwnam_r (const char *__restrict __name, |
c1422e5b UD |
152 | struct passwd *__restrict __resultbuf, |
153 | char *__restrict __buffer, size_t __buflen, | |
61d95397 MF |
154 | struct passwd **__restrict __result) |
155 | __nonnull ((1, 2, 3, 5)); | |
23396375 | 156 | |
a8922de8 | 157 | |
498afc54 | 158 | # ifdef __USE_MISC |
841785ba ZW |
159 | /* Read a user database entry from STREAM. This function is not |
160 | standardized and probably never will. | |
2c008571 UD |
161 | |
162 | This function is not part of POSIX and therefore no official | |
163 | cancellation point. But due to similarity with an POSIX interface | |
164 | or due to the implementation it is a cancellation point and | |
165 | therefore not marked with __THROW. */ | |
c1422e5b UD |
166 | extern int fgetpwent_r (FILE *__restrict __stream, |
167 | struct passwd *__restrict __resultbuf, | |
168 | char *__restrict __buffer, size_t __buflen, | |
61d95397 MF |
169 | struct passwd **__restrict __result) |
170 | __nonnull ((1, 2, 3, 5)); | |
dfd2257a | 171 | # endif |
a8922de8 | 172 | |
9d187dd4 | 173 | #endif /* POSIX or reentrant */ |
23396375 | 174 | |
1d863dc0 | 175 | #ifdef __USE_GNU |
841785ba ZW |
176 | /* Write a traditional /etc/passwd line, based on the user database |
177 | entry for the given UID, to BUFFER; space for BUFFER must be | |
178 | allocated by the caller. | |
2c008571 UD |
179 | |
180 | This function is not part of POSIX and therefore no official | |
181 | cancellation point. But due to similarity with an POSIX interface | |
182 | or due to the implementation it is a cancellation point and | |
183 | therefore not marked with __THROW. */ | |
184 | extern int getpw (__uid_t __uid, char *__buffer); | |
1d863dc0 | 185 | #endif |
28f540f4 RM |
186 | |
187 | __END_DECLS | |
188 | ||
189 | #endif /* pwd.h */ |