blob: b34addfa2b951806ed781f9425c88ed766123d4f [file] [log] [blame]
"Robert P. J. Day"63fc1a92006-07-02 19:47:05 +00001/* vi: set sw=4 ts=4: */
Eric Andersen9615a082004-07-15 12:53:49 +00002/* 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 Andersenab050f52001-01-27 06:01:43 +000024
Robert Grieblea1a63a2002-06-04 20:10:23 +000025#if !defined CONFIG_USE_BB_PWD_GRP
Eric Andersen887ca792002-07-03 23:19:26 +000026#include <grp.h>
Robert Grieblea1a63a2002-06-04 20:10:23 +000027
Eric Andersenab050f52001-01-27 06:01:43 +000028#else
29
Eric Andersen9615a082004-07-15 12:53:49 +000030#ifndef _GRP_H
31#define _GRP_H 1
32
Eric Andersenab050f52001-01-27 06:01:43 +000033#include <sys/types.h>
34#include <features.h>
35#include <stdio.h>
36
Eric Andersen9615a082004-07-15 12:53:49 +000037/* The group structure. */
Eric Andersenab050f52001-01-27 06:01:43 +000038struct group
39{
Eric Andersen9615a082004-07-15 12:53:49 +000040 char *gr_name; /* Group name. */
41 char *gr_passwd; /* Password. */
42 gid_t gr_gid; /* Group ID. */
43 char **gr_mem; /* Member list. */
Eric Andersenab050f52001-01-27 06:01:43 +000044};
45
Eric Andersenab050f52001-01-27 06:01:43 +000046
Eric Andersen9615a082004-07-15 12:53:49 +000047/* Rewind the group-file stream. */
48extern void setgrent (void);
Eric Andersenab050f52001-01-27 06:01:43 +000049
Eric Andersen9615a082004-07-15 12:53:49 +000050/* Close the group-file stream. */
51extern void endgrent (void);
Eric Andersenab050f52001-01-27 06:01:43 +000052
Eric Andersen9615a082004-07-15 12:53:49 +000053/* Read an entry from the group-file stream, opening it if necessary. */
54extern struct group *getgrent (void);
Eric Andersenab050f52001-01-27 06:01:43 +000055
Eric Andersen9615a082004-07-15 12:53:49 +000056/* Read a group entry from STREAM. */
57extern struct group *fgetgrent (FILE *__stream);
Eric Andersenab050f52001-01-27 06:01:43 +000058
Eric Andersen9615a082004-07-15 12:53:49 +000059/* Write the given entry onto the given stream. */
60extern int putgrent (__const struct group *__restrict __p,
61 FILE *__restrict __f);
Eric Andersenab050f52001-01-27 06:01:43 +000062
Eric Andersen9615a082004-07-15 12:53:49 +000063/* Search for an entry with a matching group ID. */
64extern struct group *getgrgid (gid_t __gid);
65
66/* Search for an entry with a matching group name. */
67extern 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
77extern 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. */
82extern 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. */
87extern 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. */
94extern 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). */
100extern 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. */
105extern 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. */
111extern int initgroups (__const char *__user, gid_t __group);
112
113
114#endif /* grp.h */
115#endif