"Robert P. J. Day" | 63fc1a9 | 2006-07-02 19:47:05 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 2 | /* Copyright (C) 1991,92,95,96,97,98,99,2000,01 Free Software Foundation, Inc. |
| 3 | This file is part of the GNU C Library. |
| 4 | |
| 5 | The GNU C Library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | The GNU C Library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with the GNU C Library; if not, write to the Free |
| 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 18 | 02111-1307 USA. */ |
| 19 | |
| 20 | /* |
| 21 | * POSIX Standard: 9.2.1 Group Database Access <grp.h> |
| 22 | */ |
| 23 | |
Eric Andersen | ab050f5 | 2001-01-27 06:01:43 +0000 | [diff] [blame] | 24 | |
Robert Griebl | ea1a63a | 2002-06-04 20:10:23 +0000 | [diff] [blame] | 25 | #if !defined CONFIG_USE_BB_PWD_GRP |
Eric Andersen | 887ca79 | 2002-07-03 23:19:26 +0000 | [diff] [blame] | 26 | #include <grp.h> |
Robert Griebl | ea1a63a | 2002-06-04 20:10:23 +0000 | [diff] [blame] | 27 | |
Eric Andersen | ab050f5 | 2001-01-27 06:01:43 +0000 | [diff] [blame] | 28 | #else |
| 29 | |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 30 | #ifndef _GRP_H |
| 31 | #define _GRP_H 1 |
| 32 | |
Eric Andersen | ab050f5 | 2001-01-27 06:01:43 +0000 | [diff] [blame] | 33 | #include <sys/types.h> |
| 34 | #include <features.h> |
| 35 | #include <stdio.h> |
| 36 | |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 37 | /* The group structure. */ |
Eric Andersen | ab050f5 | 2001-01-27 06:01:43 +0000 | [diff] [blame] | 38 | struct group |
| 39 | { |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 40 | char *gr_name; /* Group name. */ |
| 41 | char *gr_passwd; /* Password. */ |
| 42 | gid_t gr_gid; /* Group ID. */ |
| 43 | char **gr_mem; /* Member list. */ |
Eric Andersen | ab050f5 | 2001-01-27 06:01:43 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
Eric Andersen | ab050f5 | 2001-01-27 06:01:43 +0000 | [diff] [blame] | 46 | |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 47 | /* Rewind the group-file stream. */ |
| 48 | extern void setgrent (void); |
Eric Andersen | ab050f5 | 2001-01-27 06:01:43 +0000 | [diff] [blame] | 49 | |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 50 | /* Close the group-file stream. */ |
| 51 | extern void endgrent (void); |
Eric Andersen | ab050f5 | 2001-01-27 06:01:43 +0000 | [diff] [blame] | 52 | |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 53 | /* Read an entry from the group-file stream, opening it if necessary. */ |
| 54 | extern struct group *getgrent (void); |
Eric Andersen | ab050f5 | 2001-01-27 06:01:43 +0000 | [diff] [blame] | 55 | |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 56 | /* Read a group entry from STREAM. */ |
| 57 | extern struct group *fgetgrent (FILE *__stream); |
Eric Andersen | ab050f5 | 2001-01-27 06:01:43 +0000 | [diff] [blame] | 58 | |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 59 | /* Write the given entry onto the given stream. */ |
| 60 | extern int putgrent (__const struct group *__restrict __p, |
| 61 | FILE *__restrict __f); |
Eric Andersen | ab050f5 | 2001-01-27 06:01:43 +0000 | [diff] [blame] | 62 | |
Eric Andersen | 9615a08 | 2004-07-15 12:53:49 +0000 | [diff] [blame] | 63 | /* Search for an entry with a matching group ID. */ |
| 64 | extern struct group *getgrgid (gid_t __gid); |
| 65 | |
| 66 | /* Search for an entry with a matching group name. */ |
| 67 | extern struct group *getgrnam (__const char *__name); |
| 68 | |
| 69 | /* Reentrant versions of some of the functions above. |
| 70 | |
| 71 | PLEASE NOTE: the `getgrent_r' function is not (yet) standardized. |
| 72 | The interface may change in later versions of this library. But |
| 73 | the interface is designed following the principals used for the |
| 74 | other reentrant functions so the chances are good this is what the |
| 75 | POSIX people would choose. */ |
| 76 | |
| 77 | extern int getgrent_r (struct group *__restrict __resultbuf, |
| 78 | char *__restrict __buffer, size_t __buflen, |
| 79 | struct group **__restrict __result); |
| 80 | |
| 81 | /* Search for an entry with a matching group ID. */ |
| 82 | extern int getgrgid_r (gid_t __gid, struct group *__restrict __resultbuf, |
| 83 | char *__restrict __buffer, size_t __buflen, |
| 84 | struct group **__restrict __result); |
| 85 | |
| 86 | /* Search for an entry with a matching group name. */ |
| 87 | extern int getgrnam_r (__const char *__restrict __name, |
| 88 | struct group *__restrict __resultbuf, |
| 89 | char *__restrict __buffer, size_t __buflen, |
| 90 | struct group **__restrict __result); |
| 91 | |
| 92 | /* Read a group entry from STREAM. This function is not standardized |
| 93 | an probably never will. */ |
| 94 | extern int fgetgrent_r (FILE *__restrict __stream, |
| 95 | struct group *__restrict __resultbuf, |
| 96 | char *__restrict __buffer, size_t __buflen, |
| 97 | struct group **__restrict __result); |
| 98 | |
| 99 | /* Set the group set for the current user to GROUPS (N of them). */ |
| 100 | extern int setgroups (size_t __n, __const gid_t *__groups); |
| 101 | |
| 102 | /* Store at most *NGROUPS members of the group set for USER into |
| 103 | *GROUPS. Also include GROUP. The actual number of groups found is |
| 104 | returned in *NGROUPS. Return -1 if the if *NGROUPS is too small. */ |
| 105 | extern int getgrouplist (__const char *__user, gid_t __group, |
| 106 | gid_t *__groups, int *__ngroups); |
| 107 | |
| 108 | /* Initialize the group set for the current user |
| 109 | by reading the group database and using all groups |
| 110 | of which USER is a member. Also include GROUP. */ |
| 111 | extern int initgroups (__const char *__user, gid_t __group); |
| 112 | |
| 113 | |
| 114 | #endif /* grp.h */ |
| 115 | #endif |