hush/libbb/appletlib.c
Stephen Heumann 7e5a584f0c Use alternative code (also from BusyBox) for checking if the user is in a group, avoiding a call to getgroups(), which isn't supported.
This could actually be further simplified, since GNO doesn't really have group-based file permissions, but I'll leave that until later.
2014-11-04 16:24:41 -06:00

36 lines
815 B
C

/* vi: set sw=4 ts=4: */
/*
* Utility routines.
*
* Copyright (C) tons of folks. Tracking down who wrote what
* isn't something I'm going to worry about... If you wrote something
* here, please feel free to acknowledge your work.
*
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
* Permission has been granted to redistribute this code under GPL.
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
#include "busybox.h"
void FAST_FUNC bb_show_usage(void)
{
xfunc_die();
}
/* check if u is member of group g */
int ingroup(uid_t u, gid_t g)
{
struct group *grp = getgrgid(g);
if (grp) {
char **mem;
for (mem = grp->gr_mem; *mem; mem++) {
struct passwd *pwd = getpwnam(*mem);
if (pwd && (pwd->pw_uid == u))
return 1;
}
}
return 0;
}