diff options
Diffstat (limited to 'src/daemontools-extras/s6-envuidgid.c')
-rw-r--r-- | src/daemontools-extras/s6-envuidgid.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/daemontools-extras/s6-envuidgid.c b/src/daemontools-extras/s6-envuidgid.c index 360c426..ec809e0 100644 --- a/src/daemontools-extras/s6-envuidgid.c +++ b/src/daemontools-extras/s6-envuidgid.c @@ -3,6 +3,7 @@ #include <string.h> #include <pwd.h> #include <grp.h> +#include <errno.h> #include <limits.h> #include <skalibs/types.h> #include <skalibs/sgetopt.h> @@ -44,6 +45,25 @@ static inline size_t scan_defaults (char const *s, uid_t *uid, gid_t *gid, size_ return 1 ; } +static int prot_readgroups (char const *name, gid_t *tab, unsigned int max) +{ + unsigned int n = 0 ; + for (;;) + { + struct group *gr ; + char **member ; + errno = 0 ; + if (n >= max) break ; + gr = getgrent() ; + if (!gr) break ; + for (member = gr->gr_mem ; *member ; member++) + if (!strcmp(name, *member)) break ; + if (*member) tab[n++] = gr->gr_gid ; + } + endgrent() ; + return errno ? -1 : n ; +} + int main (int argc, char *const *argv, char const *const *envp) { char const *user = 0 ; |