From 449821248784129f507bdb048c6721135606c546 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 11 Oct 2000 03:46:14 +0000 Subject: Fix to avoid calling getgrgid for no reason. Jeremy. (This used to be commit b057a7349b2d6420f96a6ebc31822da66b39fe6c) --- source3/lib/username.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/source3/lib/username.c b/source3/lib/username.c index 99bee8a217..7baf3618b9 100644 --- a/source3/lib/username.c +++ b/source3/lib/username.c @@ -265,32 +265,20 @@ static BOOL user_in_netgroup_list(char *user,char *ngname) static BOOL user_in_group_list(char *user,char *gname) { -#ifdef HAVE_GETGRENT struct group *gptr; char **member; - struct passwd *pass = Get_Pwnam(user,False); - - if (pass) { - gptr = getgrgid(pass->pw_gid); - if (gptr && strequal(gptr->gr_name,gname)) - return(True); - } - - while ((gptr = (struct group *)getgrent())) { - if (!strequal(gptr->gr_name,gname)) - continue; - member = gptr->gr_mem; - while (member && *member) { - if (strequal(*member,user)) { - endgrent(); - return(True); - } - member++; + + if ((gptr = (struct group *)getgrnam(gname)) == NULL) + return False; + + member = gptr->gr_mem; + while (member && *member) { + if (strequal(*member,user)) { + return(True); } + member++; } - endgrent(); -#endif /* HAVE_GETGRNAM */ return False; } -- cgit