3
0

grp_.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* vi: set sw=4 ts=4: */
  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. 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. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. /*
  17. * POSIX Standard: 9.2.1 Group Database Access <grp.h>
  18. */
  19. #if !defined CONFIG_USE_BB_PWD_GRP
  20. #include <grp.h>
  21. #else
  22. #ifndef _GRP_H
  23. #define _GRP_H 1
  24. #include <sys/types.h>
  25. #include <features.h>
  26. #include <stdio.h>
  27. /* The group structure. */
  28. struct group
  29. {
  30. char *gr_name; /* Group name. */
  31. char *gr_passwd; /* Password. */
  32. gid_t gr_gid; /* Group ID. */
  33. char **gr_mem; /* Member list. */
  34. };
  35. /* Rewind the group-file stream. */
  36. extern void setgrent (void);
  37. /* Close the group-file stream. */
  38. extern void endgrent (void);
  39. /* Read an entry from the group-file stream, opening it if necessary. */
  40. extern struct group *getgrent (void);
  41. /* Read a group entry from STREAM. */
  42. extern struct group *fgetgrent (FILE *__stream);
  43. /* Write the given entry onto the given stream. */
  44. extern int putgrent (__const struct group *__restrict __p,
  45. FILE *__restrict __f);
  46. /* Search for an entry with a matching group ID. */
  47. extern struct group *getgrgid (gid_t __gid);
  48. /* Search for an entry with a matching group name. */
  49. extern struct group *getgrnam (__const char *__name);
  50. /* Reentrant versions of some of the functions above.
  51. PLEASE NOTE: the `getgrent_r' function is not (yet) standardized.
  52. The interface may change in later versions of this library. But
  53. the interface is designed following the principals used for the
  54. other reentrant functions so the chances are good this is what the
  55. POSIX people would choose. */
  56. extern int getgrent_r (struct group *__restrict __resultbuf,
  57. char *__restrict __buffer, size_t __buflen,
  58. struct group **__restrict __result);
  59. /* Search for an entry with a matching group ID. */
  60. extern int getgrgid_r (gid_t __gid, struct group *__restrict __resultbuf,
  61. char *__restrict __buffer, size_t __buflen,
  62. struct group **__restrict __result);
  63. /* Search for an entry with a matching group name. */
  64. extern int getgrnam_r (__const char *__restrict __name,
  65. struct group *__restrict __resultbuf,
  66. char *__restrict __buffer, size_t __buflen,
  67. struct group **__restrict __result);
  68. /* Read a group entry from STREAM. This function is not standardized
  69. an probably never will. */
  70. extern int fgetgrent_r (FILE *__restrict __stream,
  71. struct group *__restrict __resultbuf,
  72. char *__restrict __buffer, size_t __buflen,
  73. struct group **__restrict __result);
  74. /* Set the group set for the current user to GROUPS (N of them). */
  75. extern int setgroups (size_t __n, __const gid_t *__groups);
  76. /* Store at most *NGROUPS members of the group set for USER into
  77. *GROUPS. Also include GROUP. The actual number of groups found is
  78. returned in *NGROUPS. Return -1 if the if *NGROUPS is too small. */
  79. extern int getgrouplist (__const char *__user, gid_t __group,
  80. gid_t *__groups, int *__ngroups);
  81. /* Initialize the group set for the current user
  82. by reading the group database and using all groups
  83. of which USER is a member. Also include GROUP. */
  84. extern int initgroups (__const char *__user, gid_t __group);
  85. #endif /* grp.h */
  86. #endif