]>
Commit | Line | Data |
---|---|---|
688903eb | 1 | /* Copyright (C) 1991-2018 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 PE |
15 | License along with the GNU C Library; if not, see |
16 | <http://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 | ||
28f540f4 RM |
48 | /* The passwd structure. */ |
49 | struct passwd | |
50 | { | |
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. */ | |
58 | }; | |
59 | ||
60 | ||
acd7f096 | 61 | #ifdef __USE_MISC |
199fc19d | 62 | # include <bits/types/FILE.h> |
28f540f4 RM |
63 | #endif |
64 | ||
28f540f4 | 65 | |
ed9a38e2 | 66 | #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED |
2c008571 | 67 | /* Rewind the password-file stream. |
28f540f4 | 68 | |
2c008571 UD |
69 | This function is a possible cancellation point and therefore not |
70 | marked with __THROW. */ | |
71 | extern void setpwent (void); | |
28f540f4 | 72 | |
2c008571 UD |
73 | /* Close the password-file stream. |
74 | ||
75 | This function is a possible cancellation point and therefore not | |
76 | marked with __THROW. */ | |
77 | extern void endpwent (void); | |
78 | ||
79 | /* Read an entry from the password-file stream, opening it if necessary. | |
80 | ||
81 | This function is a possible cancellation point and therefore not | |
82 | marked with __THROW. */ | |
83 | extern struct passwd *getpwent (void); | |
28f540f4 RM |
84 | #endif |
85 | ||
498afc54 | 86 | #ifdef __USE_MISC |
2c008571 UD |
87 | /* Read an entry from STREAM. |
88 | ||
89 | This function is not part of POSIX and therefore no official | |
90 | cancellation point. But due to similarity with an POSIX interface | |
91 | or due to the implementation it is a cancellation point and | |
92 | therefore not marked with __THROW. */ | |
61d95397 | 93 | extern struct passwd *fgetpwent (FILE *__stream) __nonnull ((1)); |
2c008571 UD |
94 | |
95 | /* Write the given entry onto the given stream. | |
28f540f4 | 96 | |
2c008571 UD |
97 | This function is not part of POSIX and therefore no official |
98 | cancellation point. But due to similarity with an POSIX interface | |
99 | or due to the implementation it is a cancellation point and | |
100 | therefore not marked with __THROW. */ | |
a784e502 | 101 | extern int putpwent (const struct passwd *__restrict __p, |
1eb8bf80 | 102 | FILE *__restrict __f); |
28f540f4 RM |
103 | #endif |
104 | ||
2c008571 | 105 | /* Search for an entry with a matching user ID. |
28f540f4 | 106 | |
2c008571 UD |
107 | This function is a possible cancellation point and therefore not |
108 | marked with __THROW. */ | |
109 | extern struct passwd *getpwuid (__uid_t __uid); | |
110 | ||
111 | /* Search for an entry with a matching username. | |
112 | ||
113 | This function is a possible cancellation point and therefore not | |
114 | marked with __THROW. */ | |
61d95397 | 115 | extern struct passwd *getpwnam (const char *__name) __nonnull ((1)); |
28f540f4 | 116 | |
acd7f096 | 117 | #ifdef __USE_POSIX |
19361cb7 | 118 | |
dfd2257a | 119 | # ifdef __USE_MISC |
23396375 UD |
120 | /* Reasonable value for the buffer sized used in the reentrant |
121 | functions below. But better use `sysconf'. */ | |
dfd2257a UD |
122 | # define NSS_BUFLEN_PASSWD 1024 |
123 | # endif | |
23396375 UD |
124 | |
125 | /* Reentrant versions of some of the functions above. | |
126 | ||
84384f5b UD |
127 | PLEASE NOTE: the `getpwent_r' function is not (yet) standardized. |
128 | The interface may change in later versions of this library. But | |
129 | the interface is designed following the principals used for the | |
130 | other reentrant functions so the chances are good this is what the | |
131 | POSIX people would choose. */ | |
23396375 | 132 | |
ed9a38e2 | 133 | # ifdef __USE_MISC |
2c008571 UD |
134 | /* This function is not part of POSIX and therefore no official |
135 | cancellation point. But due to similarity with an POSIX interface | |
136 | or due to the implementation it is a cancellation point and | |
137 | therefore not marked with __THROW. */ | |
c1422e5b UD |
138 | extern int getpwent_r (struct passwd *__restrict __resultbuf, |
139 | char *__restrict __buffer, size_t __buflen, | |
61d95397 MF |
140 | struct passwd **__restrict __result) |
141 | __nonnull ((1, 2, 4)); | |
dfd2257a | 142 | # endif |
23396375 | 143 | |
c1422e5b UD |
144 | extern int getpwuid_r (__uid_t __uid, |
145 | struct passwd *__restrict __resultbuf, | |
146 | char *__restrict __buffer, size_t __buflen, | |
61d95397 MF |
147 | struct passwd **__restrict __result) |
148 | __nonnull ((2, 3, 5)); | |
23396375 | 149 | |
a784e502 | 150 | extern int getpwnam_r (const char *__restrict __name, |
c1422e5b UD |
151 | struct passwd *__restrict __resultbuf, |
152 | char *__restrict __buffer, size_t __buflen, | |
61d95397 MF |
153 | struct passwd **__restrict __result) |
154 | __nonnull ((1, 2, 3, 5)); | |
23396375 | 155 | |
a8922de8 | 156 | |
498afc54 | 157 | # ifdef __USE_MISC |
84384f5b | 158 | /* Read an entry from STREAM. This function is not standardized and |
2c008571 UD |
159 | probably never will. |
160 | ||
161 | This function is not part of POSIX and therefore no official | |
162 | cancellation point. But due to similarity with an POSIX interface | |
163 | or due to the implementation it is a cancellation point and | |
164 | therefore not marked with __THROW. */ | |
c1422e5b UD |
165 | extern int fgetpwent_r (FILE *__restrict __stream, |
166 | struct passwd *__restrict __resultbuf, | |
167 | char *__restrict __buffer, size_t __buflen, | |
61d95397 MF |
168 | struct passwd **__restrict __result) |
169 | __nonnull ((1, 2, 3, 5)); | |
dfd2257a | 170 | # endif |
a8922de8 | 171 | |
9d187dd4 | 172 | #endif /* POSIX or reentrant */ |
23396375 | 173 | |
1d863dc0 UD |
174 | #ifdef __USE_GNU |
175 | /* Re-construct the password-file line for the given uid | |
176 | in the given buffer. This knows the format that the caller | |
2c008571 UD |
177 | will expect, but this need not be the format of the password file. |
178 | ||
179 | This function is not part of POSIX and therefore no official | |
180 | cancellation point. But due to similarity with an POSIX interface | |
181 | or due to the implementation it is a cancellation point and | |
182 | therefore not marked with __THROW. */ | |
183 | extern int getpw (__uid_t __uid, char *__buffer); | |
1d863dc0 | 184 | #endif |
28f540f4 RM |
185 | |
186 | __END_DECLS | |
187 | ||
188 | #endif /* pwd.h */ |