blob: db13ce3b42b2673166ed9ceebb35d52779ddfe23 [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
Denis Vlasenkof81e8db2009-04-09 12:35:13 +000018 02111-1307 USA.
19 */
Eric Andersen9615a082004-07-15 12:53:49 +000020/*
Denys Vlasenkofb132e42010-10-29 11:46:52 +020021 * POSIX Standard: 9.2.1 Group Database Access <grp.h>
Eric Andersen9615a082004-07-15 12:53:49 +000022 */
Denis Vlasenkof81e8db2009-04-09 12:35:13 +000023#ifndef BB_GRP_H
24#define BB_GRP_H 1
Eric Andersen9615a082004-07-15 12:53:49 +000025
Denis Vlasenkof81e8db2009-04-09 12:35:13 +000026PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
Denis Vlasenko98636eb2008-05-09 17:59:34 +000027
Denis Vlasenkoee5dce32008-09-26 10:35:55 +000028/* This file is #included after #include <grp.h>
Bernhard Reutner-Fischerfd3552d2008-09-26 11:23:22 +000029 * We will use libc-defined structures, but will #define function names
Denis Vlasenkoee5dce32008-09-26 10:35:55 +000030 * so that function calls are directed to bb_internal_XXX replacements
31 */
Denys Vlasenko6b64a262012-01-06 16:23:18 +010032#undef endgrent
Denis Vlasenkocb04ff52006-12-30 21:11:57 +000033#define endgrent bb_internal_endgrent
Denis Vlasenkocb04ff52006-12-30 21:11:57 +000034#define getgrgid bb_internal_getgrgid
35#define getgrnam bb_internal_getgrnam
Denis Vlasenkocb04ff52006-12-30 21:11:57 +000036#define getgrouplist bb_internal_getgrouplist
37#define initgroups bb_internal_initgroups
38
Denis Vlasenkocb04ff52006-12-30 21:11:57 +000039/* All function names below should be remapped by #defines above
Denis Vlasenkoee5dce32008-09-26 10:35:55 +000040 * in order to not collide with libc names. */
Denis Vlasenkocb04ff52006-12-30 21:11:57 +000041
Eric Andersen9615a082004-07-15 12:53:49 +000042/* Close the group-file stream. */
Denys Vlasenko908b6e52015-01-02 22:31:07 +010043void FAST_FUNC endgrent(void);
Eric Andersenab050f52001-01-27 06:01:43 +000044
Eric Andersen9615a082004-07-15 12:53:49 +000045/* Search for an entry with a matching group ID. */
Denys Vlasenko908b6e52015-01-02 22:31:07 +010046struct group* FAST_FUNC getgrgid(gid_t __gid);
Eric Andersen9615a082004-07-15 12:53:49 +000047
48/* Search for an entry with a matching group name. */
Denys Vlasenko908b6e52015-01-02 22:31:07 +010049struct group* FAST_FUNC getgrnam(const char *__name);
Eric Andersen9615a082004-07-15 12:53:49 +000050
Tito Ragusa1da09cf2015-01-02 21:37:59 +010051/* Reentrant versions of some of the functions above. */
Eric Andersen9615a082004-07-15 12:53:49 +000052
Eric Andersen9615a082004-07-15 12:53:49 +000053/* Store at most *NGROUPS members of the group set for USER into
54 *GROUPS. Also include GROUP. The actual number of groups found is
55 returned in *NGROUPS. Return -1 if the if *NGROUPS is too small. */
Denys Vlasenko908b6e52015-01-02 22:31:07 +010056int FAST_FUNC getgrouplist(const char *__user, gid_t __group,
Denys Vlasenko6830ade2013-01-15 13:58:01 +010057 gid_t *__groups, int *__ngroups);
Eric Andersen9615a082004-07-15 12:53:49 +000058
59/* Initialize the group set for the current user
60 by reading the group database and using all groups
61 of which USER is a member. Also include GROUP. */
Denys Vlasenko908b6e52015-01-02 22:31:07 +010062int FAST_FUNC initgroups(const char *__user, gid_t __group);
Eric Andersen9615a082004-07-15 12:53:49 +000063
Denis Vlasenkof81e8db2009-04-09 12:35:13 +000064POP_SAVED_FUNCTION_VISIBILITY
Eric Andersen9615a082004-07-15 12:53:49 +000065
Eric Andersen9615a082004-07-15 12:53:49 +000066#endif