diff options
Diffstat (limited to 'include/grp_.h')
-rw-r--r-- | include/grp_.h | 74 |
1 files changed, 46 insertions, 28 deletions
diff --git a/include/grp_.h b/include/grp_.h index b34addfa2..061b86ef7 100644 --- a/include/grp_.h +++ b/include/grp_.h | |||
@@ -21,50 +21,71 @@ | |||
21 | * POSIX Standard: 9.2.1 Group Database Access <grp.h> | 21 | * POSIX Standard: 9.2.1 Group Database Access <grp.h> |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #if !ENABLE_USE_BB_PWD_GRP | ||
24 | 25 | ||
25 | #if !defined CONFIG_USE_BB_PWD_GRP | ||
26 | #include <grp.h> | 26 | #include <grp.h> |
27 | 27 | ||
28 | #else | 28 | #else |
29 | 29 | ||
30 | #ifndef _GRP_H | 30 | #ifndef _GRP_H |
31 | #define _GRP_H 1 | 31 | #define _GRP_H 1 |
32 | |||
33 | #include <sys/types.h> | ||
34 | #include <features.h> | ||
35 | #include <stdio.h> | ||
36 | 32 | ||
37 | /* The group structure. */ | 33 | /* The group structure. */ |
38 | struct group | 34 | struct group { |
39 | { | 35 | char *gr_name; /* Group name. */ |
40 | char *gr_name; /* Group name. */ | 36 | char *gr_passwd; /* Password. */ |
41 | char *gr_passwd; /* Password. */ | 37 | gid_t gr_gid; /* Group ID. */ |
42 | gid_t gr_gid; /* Group ID. */ | 38 | char **gr_mem; /* Member list. */ |
43 | char **gr_mem; /* Member list. */ | ||
44 | }; | 39 | }; |
45 | 40 | ||
41 | /* We don't reimplement this, just supplying prototype */ | ||
42 | /* The function itself is in libc */ | ||
43 | /* Set the group set for the current user to GROUPS (N of them). */ | ||
44 | extern int setgroups(size_t __n, __const gid_t *__groups); | ||
45 | |||
46 | |||
47 | #define setgrent bb_internal_setgrent | ||
48 | #define endgrent bb_internal_endgrent | ||
49 | #define getgrent bb_internal_getgrent | ||
50 | #define fgetgrent bb_internal_fgetgrent | ||
51 | #define putgrent bb_internal_putgrent | ||
52 | #define getgrgid bb_internal_getgrgid | ||
53 | #define getgrnam bb_internal_getgrnam | ||
54 | #define getgrent_r bb_internal_getgrent_r | ||
55 | #define getgrgid_r bb_internal_getgrgid_r | ||
56 | #define getgrnam_r bb_internal_getgrnam_r | ||
57 | #define fgetgrent_r bb_internal_fgetgrent_r | ||
58 | #define getgrouplist bb_internal_getgrouplist | ||
59 | #define initgroups bb_internal_initgroups | ||
60 | |||
61 | |||
62 | /* All function names below should be remapped by #defines above | ||
63 | * in order to not collide with libc names. | ||
64 | * In theory it isn't necessary, but I saw weird interactions at link time. | ||
65 | * Let's play safe */ | ||
66 | |||
46 | 67 | ||
47 | /* Rewind the group-file stream. */ | 68 | /* Rewind the group-file stream. */ |
48 | extern void setgrent (void); | 69 | extern void setgrent(void); |
49 | 70 | ||
50 | /* Close the group-file stream. */ | 71 | /* Close the group-file stream. */ |
51 | extern void endgrent (void); | 72 | extern void endgrent(void); |
52 | 73 | ||
53 | /* Read an entry from the group-file stream, opening it if necessary. */ | 74 | /* Read an entry from the group-file stream, opening it if necessary. */ |
54 | extern struct group *getgrent (void); | 75 | extern struct group *getgrent(void); |
55 | 76 | ||
56 | /* Read a group entry from STREAM. */ | 77 | /* Read a group entry from STREAM. */ |
57 | extern struct group *fgetgrent (FILE *__stream); | 78 | extern struct group *fgetgrent(FILE *__stream); |
58 | 79 | ||
59 | /* Write the given entry onto the given stream. */ | 80 | /* Write the given entry onto the given stream. */ |
60 | extern int putgrent (__const struct group *__restrict __p, | 81 | extern int putgrent(__const struct group *__restrict __p, |
61 | FILE *__restrict __f); | 82 | FILE *__restrict __f); |
62 | 83 | ||
63 | /* Search for an entry with a matching group ID. */ | 84 | /* Search for an entry with a matching group ID. */ |
64 | extern struct group *getgrgid (gid_t __gid); | 85 | extern struct group *getgrgid(gid_t __gid); |
65 | 86 | ||
66 | /* Search for an entry with a matching group name. */ | 87 | /* Search for an entry with a matching group name. */ |
67 | extern struct group *getgrnam (__const char *__name); | 88 | extern struct group *getgrnam(__const char *__name); |
68 | 89 | ||
69 | /* Reentrant versions of some of the functions above. | 90 | /* Reentrant versions of some of the functions above. |
70 | 91 | ||
@@ -74,41 +95,38 @@ extern struct group *getgrnam (__const char *__name); | |||
74 | other reentrant functions so the chances are good this is what the | 95 | other reentrant functions so the chances are good this is what the |
75 | POSIX people would choose. */ | 96 | POSIX people would choose. */ |
76 | 97 | ||
77 | extern int getgrent_r (struct group *__restrict __resultbuf, | 98 | extern int getgrent_r(struct group *__restrict __resultbuf, |
78 | char *__restrict __buffer, size_t __buflen, | 99 | char *__restrict __buffer, size_t __buflen, |
79 | struct group **__restrict __result); | 100 | struct group **__restrict __result); |
80 | 101 | ||
81 | /* Search for an entry with a matching group ID. */ | 102 | /* Search for an entry with a matching group ID. */ |
82 | extern int getgrgid_r (gid_t __gid, struct group *__restrict __resultbuf, | 103 | extern int getgrgid_r(gid_t __gid, struct group *__restrict __resultbuf, |
83 | char *__restrict __buffer, size_t __buflen, | 104 | char *__restrict __buffer, size_t __buflen, |
84 | struct group **__restrict __result); | 105 | struct group **__restrict __result); |
85 | 106 | ||
86 | /* Search for an entry with a matching group name. */ | 107 | /* Search for an entry with a matching group name. */ |
87 | extern int getgrnam_r (__const char *__restrict __name, | 108 | extern int getgrnam_r(__const char *__restrict __name, |
88 | struct group *__restrict __resultbuf, | 109 | struct group *__restrict __resultbuf, |
89 | char *__restrict __buffer, size_t __buflen, | 110 | char *__restrict __buffer, size_t __buflen, |
90 | struct group **__restrict __result); | 111 | struct group **__restrict __result); |
91 | 112 | ||
92 | /* Read a group entry from STREAM. This function is not standardized | 113 | /* Read a group entry from STREAM. This function is not standardized |
93 | an probably never will. */ | 114 | an probably never will. */ |
94 | extern int fgetgrent_r (FILE *__restrict __stream, | 115 | extern int fgetgrent_r(FILE *__restrict __stream, |
95 | struct group *__restrict __resultbuf, | 116 | struct group *__restrict __resultbuf, |
96 | char *__restrict __buffer, size_t __buflen, | 117 | char *__restrict __buffer, size_t __buflen, |
97 | struct group **__restrict __result); | 118 | struct group **__restrict __result); |
98 | 119 | ||
99 | /* Set the group set for the current user to GROUPS (N of them). */ | ||
100 | extern int setgroups (size_t __n, __const gid_t *__groups); | ||
101 | |||
102 | /* Store at most *NGROUPS members of the group set for USER into | 120 | /* Store at most *NGROUPS members of the group set for USER into |
103 | *GROUPS. Also include GROUP. The actual number of groups found is | 121 | *GROUPS. Also include GROUP. The actual number of groups found is |
104 | returned in *NGROUPS. Return -1 if the if *NGROUPS is too small. */ | 122 | returned in *NGROUPS. Return -1 if the if *NGROUPS is too small. */ |
105 | extern int getgrouplist (__const char *__user, gid_t __group, | 123 | extern int getgrouplist(__const char *__user, gid_t __group, |
106 | gid_t *__groups, int *__ngroups); | 124 | gid_t *__groups, int *__ngroups); |
107 | 125 | ||
108 | /* Initialize the group set for the current user | 126 | /* Initialize the group set for the current user |
109 | by reading the group database and using all groups | 127 | by reading the group database and using all groups |
110 | of which USER is a member. Also include GROUP. */ | 128 | of which USER is a member. Also include GROUP. */ |
111 | extern int initgroups (__const char *__user, gid_t __group); | 129 | extern int initgroups(__const char *__user, gid_t __group); |
112 | 130 | ||
113 | 131 | ||
114 | #endif /* grp.h */ | 132 | #endif /* grp.h */ |