|
Packit |
6c4009 |
/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/*
|
|
Packit |
6c4009 |
* POSIX Standard: 9.2.1 Group Database Access <grp.h>
|
|
Packit |
6c4009 |
*/
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifndef _GRP_H
|
|
Packit |
6c4009 |
#define _GRP_H 1
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <features.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
__BEGIN_DECLS
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <bits/types.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define __need_size_t
|
|
Packit |
6c4009 |
#include <stddef.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* For the Single Unix specification we must define this type here. */
|
|
Packit |
6c4009 |
#if (defined __USE_XOPEN || defined __USE_XOPEN2K) && !defined __gid_t_defined
|
|
Packit |
6c4009 |
typedef __gid_t gid_t;
|
|
Packit |
6c4009 |
# define __gid_t_defined
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* The group structure. */
|
|
Packit |
6c4009 |
struct group
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
char *gr_name; /* Group name. */
|
|
Packit |
6c4009 |
char *gr_passwd; /* Password. */
|
|
Packit |
6c4009 |
__gid_t gr_gid; /* Group ID. */
|
|
Packit |
6c4009 |
char **gr_mem; /* Member list. */
|
|
Packit |
6c4009 |
};
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifdef __USE_MISC
|
|
Packit |
6c4009 |
# include <bits/types/FILE.h>
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
|
|
Packit |
6c4009 |
/* Rewind the group-file stream.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
This function is a possible cancellation point and therefore not
|
|
Packit |
6c4009 |
marked with __THROW. */
|
|
Packit |
6c4009 |
extern void setgrent (void);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Close the group-file stream.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
This function is a possible cancellation point and therefore not
|
|
Packit |
6c4009 |
marked with __THROW. */
|
|
Packit |
6c4009 |
extern void endgrent (void);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Read an entry from the group-file stream, opening it if necessary.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
This function is a possible cancellation point and therefore not
|
|
Packit |
6c4009 |
marked with __THROW. */
|
|
Packit |
6c4009 |
extern struct group *getgrent (void);
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifdef __USE_MISC
|
|
Packit |
6c4009 |
/* Read a group entry from STREAM.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
This function is not part of POSIX and therefore no official
|
|
Packit |
6c4009 |
cancellation point. But due to similarity with an POSIX interface
|
|
Packit |
6c4009 |
or due to the implementation it is a cancellation point and
|
|
Packit |
6c4009 |
therefore not marked with __THROW. */
|
|
Packit |
6c4009 |
extern struct group *fgetgrent (FILE *__stream);
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifdef __USE_GNU
|
|
Packit |
6c4009 |
/* Write the given entry onto the given stream.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
This function is not part of POSIX and therefore no official
|
|
Packit |
6c4009 |
cancellation point. But due to similarity with an POSIX interface
|
|
Packit |
6c4009 |
or due to the implementation it is a cancellation point and
|
|
Packit |
6c4009 |
therefore not marked with __THROW. */
|
|
Packit |
6c4009 |
extern int putgrent (const struct group *__restrict __p,
|
|
Packit |
6c4009 |
FILE *__restrict __f);
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Search for an entry with a matching group ID.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
This function is a possible cancellation point and therefore not
|
|
Packit |
6c4009 |
marked with __THROW. */
|
|
Packit |
6c4009 |
extern struct group *getgrgid (__gid_t __gid);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Search for an entry with a matching group name.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
This function is a possible cancellation point and therefore not
|
|
Packit |
6c4009 |
marked with __THROW. */
|
|
Packit |
6c4009 |
extern struct group *getgrnam (const char *__name);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifdef __USE_POSIX
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# ifdef __USE_MISC
|
|
Packit |
6c4009 |
/* Reasonable value for the buffer sized used in the reentrant
|
|
Packit |
6c4009 |
functions below. But better use `sysconf'. */
|
|
Packit |
6c4009 |
# define NSS_BUFLEN_GROUP 1024
|
|
Packit |
6c4009 |
# endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Reentrant versions of some of the functions above.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
PLEASE NOTE: the `getgrent_r' function is not (yet) standardized.
|
|
Packit |
6c4009 |
The interface may change in later versions of this library. But
|
|
Packit |
6c4009 |
the interface is designed following the principals used for the
|
|
Packit |
6c4009 |
other reentrant functions so the chances are good this is what the
|
|
Packit |
6c4009 |
POSIX people would choose.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
This function is not part of POSIX and therefore no official
|
|
Packit |
6c4009 |
cancellation point. But due to similarity with an POSIX interface
|
|
Packit |
6c4009 |
or due to the implementation it is a cancellation point and
|
|
Packit |
6c4009 |
therefore not marked with __THROW. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# ifdef __USE_GNU
|
|
Packit |
6c4009 |
extern int getgrent_r (struct group *__restrict __resultbuf,
|
|
Packit |
6c4009 |
char *__restrict __buffer, size_t __buflen,
|
|
Packit |
6c4009 |
struct group **__restrict __result);
|
|
Packit |
6c4009 |
# endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Search for an entry with a matching group ID.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
This function is a possible cancellation point and therefore not
|
|
Packit |
6c4009 |
marked with __THROW. */
|
|
Packit |
6c4009 |
extern int getgrgid_r (__gid_t __gid, struct group *__restrict __resultbuf,
|
|
Packit |
6c4009 |
char *__restrict __buffer, size_t __buflen,
|
|
Packit |
6c4009 |
struct group **__restrict __result);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Search for an entry with a matching group name.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
This function is a possible cancellation point and therefore not
|
|
Packit |
6c4009 |
marked with __THROW. */
|
|
Packit |
6c4009 |
extern int getgrnam_r (const char *__restrict __name,
|
|
Packit |
6c4009 |
struct group *__restrict __resultbuf,
|
|
Packit |
6c4009 |
char *__restrict __buffer, size_t __buflen,
|
|
Packit |
6c4009 |
struct group **__restrict __result);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# ifdef __USE_MISC
|
|
Packit |
6c4009 |
/* Read a group entry from STREAM. This function is not standardized
|
|
Packit |
6c4009 |
an probably never will.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
This function is not part of POSIX and therefore no official
|
|
Packit |
6c4009 |
cancellation point. But due to similarity with an POSIX interface
|
|
Packit |
6c4009 |
or due to the implementation it is a cancellation point and
|
|
Packit |
6c4009 |
therefore not marked with __THROW. */
|
|
Packit |
6c4009 |
extern int fgetgrent_r (FILE *__restrict __stream,
|
|
Packit |
6c4009 |
struct group *__restrict __resultbuf,
|
|
Packit |
6c4009 |
char *__restrict __buffer, size_t __buflen,
|
|
Packit |
6c4009 |
struct group **__restrict __result);
|
|
Packit |
6c4009 |
# endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#endif /* POSIX or reentrant */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifdef __USE_MISC
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# define __need_size_t
|
|
Packit |
6c4009 |
# include <stddef.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Set the group set for the current user to GROUPS (N of them). */
|
|
Packit |
6c4009 |
extern int setgroups (size_t __n, const __gid_t *__groups) __THROW;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Store at most *NGROUPS members of the group set for USER into
|
|
Packit |
6c4009 |
*GROUPS. Also include GROUP. The actual number of groups found is
|
|
Packit |
6c4009 |
returned in *NGROUPS. Return -1 if the if *NGROUPS is too small.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
This function is not part of POSIX and therefore no official
|
|
Packit |
6c4009 |
cancellation point. But due to similarity with an POSIX interface
|
|
Packit |
6c4009 |
or due to the implementation it is a cancellation point and
|
|
Packit |
6c4009 |
therefore not marked with __THROW. */
|
|
Packit |
6c4009 |
extern int getgrouplist (const char *__user, __gid_t __group,
|
|
Packit |
6c4009 |
__gid_t *__groups, int *__ngroups);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Initialize the group set for the current user
|
|
Packit |
6c4009 |
by reading the group database and using all groups
|
|
Packit |
6c4009 |
of which USER is a member. Also include GROUP.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
This function is not part of POSIX and therefore no official
|
|
Packit |
6c4009 |
cancellation point. But due to similarity with an POSIX interface
|
|
Packit |
6c4009 |
or due to the implementation it is a cancellation point and
|
|
Packit |
6c4009 |
therefore not marked with __THROW. */
|
|
Packit |
6c4009 |
extern int initgroups (const char *__user, __gid_t __group);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#endif /* Use misc. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
__END_DECLS
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#endif /* grp.h */
|