grp_.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 !ENABLE_USE_BB_PWD_GRP
  20. #include <grp.h>
  21. #else
  22. #ifndef _GRP_H
  23. #define _GRP_H 1
  24. /* The group structure. */
  25. struct group {
  26. char *gr_name; /* Group name. */
  27. char *gr_passwd; /* Password. */
  28. gid_t gr_gid; /* Group ID. */
  29. char **gr_mem; /* Member list. */
  30. };
  31. /* We don't reimplement this, just supplying prototype */
  32. /* The function itself is in libc */
  33. /* Set the group set for the current user to GROUPS (N of them). */
  34. extern int setgroups(size_t __n, __const gid_t *__groups);
  35. #define setgrent bb_internal_setgrent
  36. #define endgrent bb_internal_endgrent
  37. #define getgrent bb_internal_getgrent
  38. #define fgetgrent bb_internal_fgetgrent
  39. #define putgrent bb_internal_putgrent
  40. #define getgrgid bb_internal_getgrgid
  41. #define getgrnam bb_internal_getgrnam
  42. #define getgrent_r bb_internal_getgrent_r
  43. #define getgrgid_r bb_internal_getgrgid_r
  44. #define getgrnam_r bb_internal_getgrnam_r
  45. #define fgetgrent_r bb_internal_fgetgrent_r
  46. #define getgrouplist bb_internal_getgrouplist
  47. #define initgroups bb_internal_initgroups
  48. /* All function names below should be remapped by #defines above
  49. * in order to not collide with libc names.
  50. * In theory it isn't necessary, but I saw weird interactions at link time.
  51. * Let's play safe */
  52. /* Rewind the group-file stream. */
  53. extern void setgrent(void);
  54. /* Close the group-file stream. */
  55. extern void endgrent(void);
  56. /* Read an entry from the group-file stream, opening it if necessary. */
  57. extern struct group *getgrent(void);
  58. /* Read a group entry from STREAM. */
  59. extern struct group *fgetgrent(FILE *__stream);
  60. /* Write the given entry onto the given stream. */
  61. extern int putgrent(__const struct group *__restrict __p,
  62. FILE *__restrict __f);
  63. /* Search for an entry with a matching group ID. */
  64. extern struct group *getgrgid(gid_t __gid);
  65. /* Search for an entry with a matching group name. */
  66. extern struct group *getgrnam(__const char *__name);
  67. /* Reentrant versions of some of the functions above.
  68. PLEASE NOTE: the `getgrent_r' function is not (yet) standardized.
  69. The interface may change in later versions of this library. But
  70. the interface is designed following the principals used for the
  71. other reentrant functions so the chances are good this is what the
  72. POSIX people would choose. */
  73. extern int getgrent_r(struct group *__restrict __resultbuf,
  74. char *__restrict __buffer, size_t __buflen,
  75. struct group **__restrict __result);
  76. /* Search for an entry with a matching group ID. */
  77. extern int getgrgid_r(gid_t __gid, struct group *__restrict __resultbuf,
  78. char *__restrict __buffer, size_t __buflen,
  79. struct group **__restrict __result);
  80. /* Search for an entry with a matching group name. */
  81. extern int getgrnam_r(__const char *__restrict __name,
  82. struct group *__restrict __resultbuf,
  83. char *__restrict __buffer, size_t __buflen,
  84. struct group **__restrict __result);
  85. /* Read a group entry from STREAM. This function is not standardized
  86. an probably never will. */
  87. extern int fgetgrent_r(FILE *__restrict __stream,
  88. struct group *__restrict __resultbuf,
  89. char *__restrict __buffer, size_t __buflen,
  90. struct group **__restrict __result);
  91. /* Store at most *NGROUPS members of the group set for USER into
  92. *GROUPS. Also include GROUP. The actual number of groups found is
  93. returned in *NGROUPS. Return -1 if the if *NGROUPS is too small. */
  94. extern int getgrouplist(__const char *__user, gid_t __group,
  95. gid_t *__groups, int *__ngroups);
  96. /* Initialize the group set for the current user
  97. by reading the group database and using all groups
  98. of which USER is a member. Also include GROUP. */
  99. extern int initgroups(__const char *__user, gid_t __group);
  100. #endif /* grp.h */
  101. #endif