| xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 1 | /* Copyright (C) 1991-2016 Free Software Foundation, Inc. | 
|  | 2 | This file is part of the GNU C Library. | 
|  | 3 |  | 
|  | 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. | 
|  | 8 |  | 
|  | 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. | 
|  | 13 |  | 
|  | 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/>.  */ | 
|  | 17 |  | 
|  | 18 | /* | 
|  | 19 | *	POSIX Standard: 9.2.1 Group Database Access	<grp.h> | 
|  | 20 | */ | 
|  | 21 |  | 
|  | 22 | #ifndef	_GRP_H | 
|  | 23 | #define	_GRP_H	1 | 
|  | 24 |  | 
|  | 25 | #include <features.h> | 
|  | 26 |  | 
|  | 27 | __BEGIN_DECLS | 
|  | 28 |  | 
|  | 29 | #include <bits/types.h> | 
|  | 30 |  | 
|  | 31 | #define __need_size_t | 
|  | 32 | #include <stddef.h> | 
|  | 33 |  | 
|  | 34 |  | 
|  | 35 | /* For the Single Unix specification we must define this type here.  */ | 
|  | 36 | #if (defined __USE_XOPEN || defined __USE_XOPEN2K) && !defined __gid_t_defined | 
|  | 37 | typedef __gid_t gid_t; | 
|  | 38 | # define __gid_t_defined | 
|  | 39 | #endif | 
|  | 40 |  | 
|  | 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 |  | 
|  | 51 | #ifdef __USE_MISC | 
|  | 52 | # define __need_FILE | 
|  | 53 | # include <stdio.h> | 
|  | 54 | #endif | 
|  | 55 |  | 
|  | 56 |  | 
|  | 57 | #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED | 
|  | 58 | /* Rewind the group-file stream. | 
|  | 59 |  | 
|  | 60 | This function is a possible cancellation point and therefore not | 
|  | 61 | marked with __THROW.  */ | 
|  | 62 | extern void setgrent (void); | 
|  | 63 |  | 
|  | 64 | /* Close the group-file stream. | 
|  | 65 |  | 
|  | 66 | This function is a possible cancellation point and therefore not | 
|  | 67 | marked with __THROW.  */ | 
|  | 68 | extern void endgrent (void); | 
|  | 69 |  | 
|  | 70 | /* Read an entry from the group-file stream, opening it if necessary. | 
|  | 71 |  | 
|  | 72 | This function is a possible cancellation point and therefore not | 
|  | 73 | marked with __THROW.  */ | 
|  | 74 | extern struct group *getgrent (void); | 
|  | 75 | #endif | 
|  | 76 |  | 
|  | 77 | #ifdef	__USE_MISC | 
|  | 78 | /* Read a group entry from STREAM. | 
|  | 79 |  | 
|  | 80 | This function is not part of POSIX and therefore no official | 
|  | 81 | cancellation point.  But due to similarity with an POSIX interface | 
|  | 82 | or due to the implementation it is a cancellation point and | 
|  | 83 | therefore not marked with __THROW.  */ | 
|  | 84 | extern struct group *fgetgrent (FILE *__stream); | 
|  | 85 | #endif | 
|  | 86 |  | 
|  | 87 | #ifdef __USE_GNU | 
|  | 88 | /* Write the given entry onto the given stream. | 
|  | 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.  */ | 
|  | 94 | extern int putgrent (const struct group *__restrict __p, | 
|  | 95 | FILE *__restrict __f); | 
|  | 96 | #endif | 
|  | 97 |  | 
|  | 98 | /* Search for an entry with a matching group ID. | 
|  | 99 |  | 
|  | 100 | This function is a possible cancellation point and therefore not | 
|  | 101 | marked with __THROW.  */ | 
|  | 102 | extern struct group *getgrgid (__gid_t __gid); | 
|  | 103 |  | 
|  | 104 | /* Search for an entry with a matching group name. | 
|  | 105 |  | 
|  | 106 | This function is a possible cancellation point and therefore not | 
|  | 107 | marked with __THROW.  */ | 
|  | 108 | extern struct group *getgrnam (const char *__name); | 
|  | 109 |  | 
|  | 110 | #ifdef __USE_POSIX | 
|  | 111 |  | 
|  | 112 | # ifdef __USE_MISC | 
|  | 113 | /* Reasonable value for the buffer sized used in the reentrant | 
|  | 114 | functions below.  But better use `sysconf'.  */ | 
|  | 115 | #  define NSS_BUFLEN_GROUP	1024 | 
|  | 116 | # endif | 
|  | 117 |  | 
|  | 118 | /* Reentrant versions of some of the functions above. | 
|  | 119 |  | 
|  | 120 | PLEASE NOTE: the `getgrent_r' function is not (yet) standardized. | 
|  | 121 | The interface may change in later versions of this library.  But | 
|  | 122 | the interface is designed following the principals used for the | 
|  | 123 | other reentrant functions so the chances are good this is what the | 
|  | 124 | POSIX people would choose. | 
|  | 125 |  | 
|  | 126 | This function is not part of POSIX and therefore no official | 
|  | 127 | cancellation point.  But due to similarity with an POSIX interface | 
|  | 128 | or due to the implementation it is a cancellation point and | 
|  | 129 | therefore not marked with __THROW.  */ | 
|  | 130 |  | 
|  | 131 | # ifdef __USE_GNU | 
|  | 132 | extern int getgrent_r (struct group *__restrict __resultbuf, | 
|  | 133 | char *__restrict __buffer, size_t __buflen, | 
|  | 134 | struct group **__restrict __result); | 
|  | 135 | # endif | 
|  | 136 |  | 
|  | 137 | /* Search for an entry with a matching group ID. | 
|  | 138 |  | 
|  | 139 | This function is a possible cancellation point and therefore not | 
|  | 140 | marked with __THROW.  */ | 
|  | 141 | extern int getgrgid_r (__gid_t __gid, struct group *__restrict __resultbuf, | 
|  | 142 | char *__restrict __buffer, size_t __buflen, | 
|  | 143 | struct group **__restrict __result); | 
|  | 144 |  | 
|  | 145 | /* Search for an entry with a matching group name. | 
|  | 146 |  | 
|  | 147 | This function is a possible cancellation point and therefore not | 
|  | 148 | marked with __THROW.  */ | 
|  | 149 | extern int getgrnam_r (const char *__restrict __name, | 
|  | 150 | struct group *__restrict __resultbuf, | 
|  | 151 | char *__restrict __buffer, size_t __buflen, | 
|  | 152 | struct group **__restrict __result); | 
|  | 153 |  | 
|  | 154 | # ifdef	__USE_MISC | 
|  | 155 | /* Read a group entry from STREAM.  This function is not standardized | 
|  | 156 | an probably never will. | 
|  | 157 |  | 
|  | 158 | This function is not part of POSIX and therefore no official | 
|  | 159 | cancellation point.  But due to similarity with an POSIX interface | 
|  | 160 | or due to the implementation it is a cancellation point and | 
|  | 161 | therefore not marked with __THROW.  */ | 
|  | 162 | extern int fgetgrent_r (FILE *__restrict __stream, | 
|  | 163 | struct group *__restrict __resultbuf, | 
|  | 164 | char *__restrict __buffer, size_t __buflen, | 
|  | 165 | struct group **__restrict __result); | 
|  | 166 | # endif | 
|  | 167 |  | 
|  | 168 | #endif	/* POSIX or reentrant */ | 
|  | 169 |  | 
|  | 170 |  | 
|  | 171 | #ifdef	__USE_MISC | 
|  | 172 |  | 
|  | 173 | # define __need_size_t | 
|  | 174 | # include <stddef.h> | 
|  | 175 |  | 
|  | 176 | /* Set the group set for the current user to GROUPS (N of them).  */ | 
|  | 177 | extern int setgroups (size_t __n, const __gid_t *__groups) __THROW; | 
|  | 178 |  | 
|  | 179 | /* Store at most *NGROUPS members of the group set for USER into | 
|  | 180 | *GROUPS.  Also include GROUP.  The actual number of groups found is | 
|  | 181 | returned in *NGROUPS.  Return -1 if the if *NGROUPS is too small. | 
|  | 182 |  | 
|  | 183 | This function is not part of POSIX and therefore no official | 
|  | 184 | cancellation point.  But due to similarity with an POSIX interface | 
|  | 185 | or due to the implementation it is a cancellation point and | 
|  | 186 | therefore not marked with __THROW.  */ | 
|  | 187 | extern int getgrouplist (const char *__user, __gid_t __group, | 
|  | 188 | __gid_t *__groups, int *__ngroups); | 
|  | 189 |  | 
|  | 190 | /* Initialize the group set for the current user | 
|  | 191 | by reading the group database and using all groups | 
|  | 192 | of which USER is a member.  Also include GROUP. | 
|  | 193 |  | 
|  | 194 | This function is not part of POSIX and therefore no official | 
|  | 195 | cancellation point.  But due to similarity with an POSIX interface | 
|  | 196 | or due to the implementation it is a cancellation point and | 
|  | 197 | therefore not marked with __THROW.  */ | 
|  | 198 | extern int initgroups (const char *__user, __gid_t __group); | 
|  | 199 |  | 
|  | 200 | #endif /* Use misc.  */ | 
|  | 201 |  | 
|  | 202 | __END_DECLS | 
|  | 203 |  | 
|  | 204 | #endif /* grp.h  */ |