]>
Commit | Line | Data |
---|---|---|
b168057a | 1 | /* Copyright (C) 1991-2015 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.1 Group Database Access <grp.h> | |
20 | */ | |
21 | ||
22 | #ifndef _GRP_H | |
28f540f4 | 23 | #define _GRP_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> | |
33 | ||
28f540f4 | 34 | |
9756dfe1 | 35 | /* For the Single Unix specification we must define this type here. */ |
7a80496f | 36 | #if (defined __USE_XOPEN || defined __USE_XOPEN2K) && !defined __gid_t_defined |
9756dfe1 | 37 | typedef __gid_t gid_t; |
7df789e0 | 38 | # define __gid_t_defined |
9756dfe1 UD |
39 | #endif |
40 | ||
28f540f4 RM |
41 | /* The group structure. */ |
42 | struct group | |
43 | { | |
44 | char *gr_name; /* Group name. */ | |
45 | char *gr_passwd; /* Password. */ | |
46 | __gid_t gr_gid; /* Group ID. */ | |
47 | char **gr_mem; /* Member list. */ | |
48 | }; | |
49 | ||
50 | ||
acd7f096 | 51 | #ifdef __USE_MISC |
dfd2257a UD |
52 | # define __need_FILE |
53 | # include <stdio.h> | |
28f540f4 RM |
54 | #endif |
55 | ||
28f540f4 | 56 | |
ed9a38e2 | 57 | #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED |
2c008571 | 58 | /* Rewind the group-file stream. |
28f540f4 | 59 | |
2c008571 UD |
60 | This function is a possible cancellation point and therefore not |
61 | marked with __THROW. */ | |
62 | extern void setgrent (void); | |
dfe11a13 | 63 | #endif |
28f540f4 | 64 | |
acd7f096 | 65 | #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 |
2c008571 UD |
66 | /* Close the group-file stream. |
67 | ||
68 | This function is a possible cancellation point and therefore not | |
69 | marked with __THROW. */ | |
70 | extern void endgrent (void); | |
71 | ||
72 | /* Read an entry from the group-file stream, opening it if necessary. | |
73 | ||
74 | This function is a possible cancellation point and therefore not | |
75 | marked with __THROW. */ | |
76 | extern struct group *getgrent (void); | |
28f540f4 RM |
77 | #endif |
78 | ||
498afc54 | 79 | #ifdef __USE_MISC |
2c008571 UD |
80 | /* Read a group entry from STREAM. |
81 | ||
82 | This function is not part of POSIX and therefore no official | |
83 | cancellation point. But due to similarity with an POSIX interface | |
84 | or due to the implementation it is a cancellation point and | |
85 | therefore not marked with __THROW. */ | |
86 | extern struct group *fgetgrent (FILE *__stream); | |
28f540f4 RM |
87 | #endif |
88 | ||
7ce241a0 | 89 | #ifdef __USE_GNU |
2c008571 UD |
90 | /* Write the given entry onto the given stream. |
91 | ||
92 | This function is not part of POSIX and therefore no official | |
93 | cancellation point. But due to similarity with an POSIX interface | |
94 | or due to the implementation it is a cancellation point and | |
95 | therefore not marked with __THROW. */ | |
a784e502 | 96 | extern int putgrent (const struct group *__restrict __p, |
2c008571 | 97 | FILE *__restrict __f); |
7ce241a0 UD |
98 | #endif |
99 | ||
2c008571 UD |
100 | /* Search for an entry with a matching group ID. |
101 | ||
102 | This function is a possible cancellation point and therefore not | |
103 | marked with __THROW. */ | |
104 | extern struct group *getgrgid (__gid_t __gid); | |
105 | ||
106 | /* Search for an entry with a matching group name. | |
28f540f4 | 107 | |
2c008571 UD |
108 | This function is a possible cancellation point and therefore not |
109 | marked with __THROW. */ | |
a784e502 | 110 | extern struct group *getgrnam (const char *__name); |
28f540f4 | 111 | |
acd7f096 | 112 | #ifdef __USE_POSIX |
19361cb7 | 113 | |
dfd2257a | 114 | # ifdef __USE_MISC |
23396375 UD |
115 | /* Reasonable value for the buffer sized used in the reentrant |
116 | functions below. But better use `sysconf'. */ | |
dfd2257a UD |
117 | # define NSS_BUFLEN_GROUP 1024 |
118 | # endif | |
23396375 UD |
119 | |
120 | /* Reentrant versions of some of the functions above. | |
121 | ||
84384f5b UD |
122 | PLEASE NOTE: the `getgrent_r' function is not (yet) standardized. |
123 | The interface may change in later versions of this library. But | |
124 | the interface is designed following the principals used for the | |
125 | other reentrant functions so the chances are good this is what the | |
2c008571 UD |
126 | POSIX people would choose. |
127 | ||
128 | This function is not part of POSIX and therefore no official | |
129 | cancellation point. But due to similarity with an POSIX interface | |
130 | or due to the implementation it is a cancellation point and | |
131 | therefore not marked with __THROW. */ | |
23396375 | 132 | |
0ed99ce4 | 133 | # ifdef __USE_GNU |
c1422e5b UD |
134 | extern int getgrent_r (struct group *__restrict __resultbuf, |
135 | char *__restrict __buffer, size_t __buflen, | |
2c008571 | 136 | struct group **__restrict __result); |
dfd2257a | 137 | # endif |
23396375 | 138 | |
2c008571 UD |
139 | /* Search for an entry with a matching group ID. |
140 | ||
141 | This function is a possible cancellation point and therefore not | |
142 | marked with __THROW. */ | |
c1422e5b UD |
143 | extern int getgrgid_r (__gid_t __gid, struct group *__restrict __resultbuf, |
144 | char *__restrict __buffer, size_t __buflen, | |
2c008571 UD |
145 | struct group **__restrict __result); |
146 | ||
147 | /* Search for an entry with a matching group name. | |
23396375 | 148 | |
2c008571 UD |
149 | This function is a possible cancellation point and therefore not |
150 | marked with __THROW. */ | |
a784e502 | 151 | extern int getgrnam_r (const char *__restrict __name, |
c1422e5b UD |
152 | struct group *__restrict __resultbuf, |
153 | char *__restrict __buffer, size_t __buflen, | |
2c008571 | 154 | struct group **__restrict __result); |
23396375 | 155 | |
498afc54 | 156 | # ifdef __USE_MISC |
84384f5b | 157 | /* Read a group entry from STREAM. This function is not standardized |
2c008571 UD |
158 | an probably never will. |
159 | ||
160 | This function is not part of POSIX and therefore no official | |
161 | cancellation point. But due to similarity with an POSIX interface | |
162 | or due to the implementation it is a cancellation point and | |
163 | therefore not marked with __THROW. */ | |
c1422e5b UD |
164 | extern int fgetgrent_r (FILE *__restrict __stream, |
165 | struct group *__restrict __resultbuf, | |
166 | char *__restrict __buffer, size_t __buflen, | |
2c008571 | 167 | struct group **__restrict __result); |
dfd2257a | 168 | # endif |
a8922de8 | 169 | |
9d187dd4 | 170 | #endif /* POSIX or reentrant */ |
23396375 | 171 | |
28f540f4 | 172 | |
498afc54 | 173 | #ifdef __USE_MISC |
28f540f4 | 174 | |
dfd2257a UD |
175 | # define __need_size_t |
176 | # include <stddef.h> | |
28f540f4 RM |
177 | |
178 | /* Set the group set for the current user to GROUPS (N of them). */ | |
a784e502 | 179 | extern int setgroups (size_t __n, const __gid_t *__groups) __THROW; |
28f540f4 | 180 | |
8fee1bb0 UD |
181 | /* Store at most *NGROUPS members of the group set for USER into |
182 | *GROUPS. Also include GROUP. The actual number of groups found is | |
2c008571 UD |
183 | returned in *NGROUPS. Return -1 if the if *NGROUPS is too small. |
184 | ||
185 | This function is not part of POSIX and therefore no official | |
186 | cancellation point. But due to similarity with an POSIX interface | |
187 | or due to the implementation it is a cancellation point and | |
188 | therefore not marked with __THROW. */ | |
a784e502 | 189 | extern int getgrouplist (const char *__user, __gid_t __group, |
2c008571 | 190 | __gid_t *__groups, int *__ngroups); |
8fee1bb0 | 191 | |
28f540f4 RM |
192 | /* Initialize the group set for the current user |
193 | by reading the group database and using all groups | |
2c008571 UD |
194 | of which USER is a member. Also include GROUP. |
195 | ||
196 | This function is not part of POSIX and therefore no official | |
197 | cancellation point. But due to similarity with an POSIX interface | |
198 | or due to the implementation it is a cancellation point and | |
199 | therefore not marked with __THROW. */ | |
a784e502 | 200 | extern int initgroups (const char *__user, __gid_t __group); |
28f540f4 | 201 | |
acd7f096 | 202 | #endif /* Use misc. */ |
28f540f4 RM |
203 | |
204 | __END_DECLS | |
205 | ||
206 | #endif /* grp.h */ |