| 1 |
1325 |
phoenix |
/* Copyright (C) 1991,92,95,96,97,98,99,2000,01 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, write to the Free
|
| 16 |
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
| 17 |
|
|
02111-1307 USA. */
|
| 18 |
|
|
|
| 19 |
|
|
/*
|
| 20 |
|
|
* POSIX Standard: 9.2.1 Group Database Access <grp.h>
|
| 21 |
|
|
*/
|
| 22 |
|
|
|
| 23 |
|
|
#ifndef _GRP_H
|
| 24 |
|
|
#define _GRP_H 1
|
| 25 |
|
|
|
| 26 |
|
|
#include <features.h>
|
| 27 |
|
|
|
| 28 |
|
|
__BEGIN_DECLS
|
| 29 |
|
|
|
| 30 |
|
|
#include <bits/types.h>
|
| 31 |
|
|
|
| 32 |
|
|
#define __need_size_t
|
| 33 |
|
|
#include <stddef.h>
|
| 34 |
|
|
|
| 35 |
|
|
|
| 36 |
|
|
/* For the Single Unix specification we must define this type here. */
|
| 37 |
|
|
#if defined __USE_XOPEN && !defined __gid_t_defined
|
| 38 |
|
|
typedef __gid_t gid_t;
|
| 39 |
|
|
# define __gid_t_defined
|
| 40 |
|
|
#endif
|
| 41 |
|
|
|
| 42 |
|
|
/* The group structure. */
|
| 43 |
|
|
struct group
|
| 44 |
|
|
{
|
| 45 |
|
|
char *gr_name; /* Group name. */
|
| 46 |
|
|
char *gr_passwd; /* Password. */
|
| 47 |
|
|
__gid_t gr_gid; /* Group ID. */
|
| 48 |
|
|
char **gr_mem; /* Member list. */
|
| 49 |
|
|
};
|
| 50 |
|
|
|
| 51 |
|
|
|
| 52 |
|
|
#if defined __USE_SVID || defined __USE_GNU
|
| 53 |
|
|
# define __need_FILE
|
| 54 |
|
|
# include <stdio.h>
|
| 55 |
|
|
#endif
|
| 56 |
|
|
|
| 57 |
|
|
|
| 58 |
|
|
#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
|
| 59 |
|
|
/* Rewind the group-file stream. */
|
| 60 |
|
|
extern void setgrent (void) __THROW;
|
| 61 |
|
|
|
| 62 |
|
|
/* Close the group-file stream. */
|
| 63 |
|
|
extern void endgrent (void) __THROW;
|
| 64 |
|
|
|
| 65 |
|
|
/* Read an entry from the group-file stream, opening it if necessary. */
|
| 66 |
|
|
extern struct group *getgrent (void) __THROW;
|
| 67 |
|
|
#endif
|
| 68 |
|
|
|
| 69 |
|
|
#ifdef __USE_SVID
|
| 70 |
|
|
/* Read a group entry from STREAM. */
|
| 71 |
|
|
extern struct group *fgetgrent (FILE *__stream) __THROW;
|
| 72 |
|
|
#endif
|
| 73 |
|
|
|
| 74 |
|
|
#ifdef __USE_GNU
|
| 75 |
|
|
/* Write the given entry onto the given stream. */
|
| 76 |
|
|
extern int putgrent (__const struct group *__restrict __p,
|
| 77 |
|
|
FILE *__restrict __f) __THROW;
|
| 78 |
|
|
#endif
|
| 79 |
|
|
|
| 80 |
|
|
/* Search for an entry with a matching group ID. */
|
| 81 |
|
|
extern struct group *getgrgid (__gid_t __gid) __THROW;
|
| 82 |
|
|
|
| 83 |
|
|
/* Search for an entry with a matching group name. */
|
| 84 |
|
|
extern struct group *getgrnam (__const char *__name) __THROW;
|
| 85 |
|
|
|
| 86 |
|
|
#if defined __USE_POSIX || defined __USE_MISC
|
| 87 |
|
|
|
| 88 |
|
|
# ifdef __USE_MISC
|
| 89 |
|
|
/* Reasonable value for the buffer sized used in the reentrant
|
| 90 |
|
|
functions below. But better use `sysconf'. */
|
| 91 |
|
|
# define NSS_BUFLEN_GROUP 1024
|
| 92 |
|
|
# endif
|
| 93 |
|
|
|
| 94 |
|
|
/* Reentrant versions of some of the functions above.
|
| 95 |
|
|
|
| 96 |
|
|
PLEASE NOTE: the `getgrent_r' function is not (yet) standardized.
|
| 97 |
|
|
The interface may change in later versions of this library. But
|
| 98 |
|
|
the interface is designed following the principals used for the
|
| 99 |
|
|
other reentrant functions so the chances are good this is what the
|
| 100 |
|
|
POSIX people would choose. */
|
| 101 |
|
|
|
| 102 |
|
|
# ifdef __USE_GNU
|
| 103 |
|
|
extern int getgrent_r (struct group *__restrict __resultbuf,
|
| 104 |
|
|
char *__restrict __buffer, size_t __buflen,
|
| 105 |
|
|
struct group **__restrict __result) __THROW;
|
| 106 |
|
|
# endif
|
| 107 |
|
|
|
| 108 |
|
|
/* Search for an entry with a matching group ID. */
|
| 109 |
|
|
extern int getgrgid_r (__gid_t __gid, struct group *__restrict __resultbuf,
|
| 110 |
|
|
char *__restrict __buffer, size_t __buflen,
|
| 111 |
|
|
struct group **__restrict __result) __THROW;
|
| 112 |
|
|
|
| 113 |
|
|
/* Search for an entry with a matching group name. */
|
| 114 |
|
|
extern int getgrnam_r (__const char *__restrict __name,
|
| 115 |
|
|
struct group *__restrict __resultbuf,
|
| 116 |
|
|
char *__restrict __buffer, size_t __buflen,
|
| 117 |
|
|
struct group **__restrict __result) __THROW;
|
| 118 |
|
|
|
| 119 |
|
|
# ifdef __USE_SVID
|
| 120 |
|
|
/* Read a group entry from STREAM. This function is not standardized
|
| 121 |
|
|
an probably never will. */
|
| 122 |
|
|
extern int fgetgrent_r (FILE *__restrict __stream,
|
| 123 |
|
|
struct group *__restrict __resultbuf,
|
| 124 |
|
|
char *__restrict __buffer, size_t __buflen,
|
| 125 |
|
|
struct group **__restrict __result) __THROW;
|
| 126 |
|
|
# endif
|
| 127 |
|
|
|
| 128 |
|
|
#endif /* POSIX or reentrant */
|
| 129 |
|
|
|
| 130 |
|
|
|
| 131 |
|
|
#ifdef __USE_BSD
|
| 132 |
|
|
|
| 133 |
|
|
# define __need_size_t
|
| 134 |
|
|
# include <stddef.h>
|
| 135 |
|
|
|
| 136 |
|
|
/* Set the group set for the current user to GROUPS (N of them). */
|
| 137 |
|
|
extern int setgroups (size_t __n, __const __gid_t *__groups) __THROW;
|
| 138 |
|
|
|
| 139 |
|
|
/* Store at most *NGROUPS members of the group set for USER into
|
| 140 |
|
|
*GROUPS. Also include GROUP. The actual number of groups found is
|
| 141 |
|
|
returned in *NGROUPS. Return -1 if the if *NGROUPS is too small. */
|
| 142 |
|
|
extern int getgrouplist (__const char *__user, __gid_t __group,
|
| 143 |
|
|
__gid_t *__groups, int *__ngroups) __THROW;
|
| 144 |
|
|
|
| 145 |
|
|
/* Initialize the group set for the current user
|
| 146 |
|
|
by reading the group database and using all groups
|
| 147 |
|
|
of which USER is a member. Also include GROUP. */
|
| 148 |
|
|
extern int initgroups (__const char *__user, __gid_t __group) __THROW;
|
| 149 |
|
|
|
| 150 |
|
|
#endif /* Use BSD. */
|
| 151 |
|
|
|
| 152 |
|
|
__END_DECLS
|
| 153 |
|
|
|
| 154 |
|
|
#endif /* grp.h */
|