diff options
-rw-r--r-- | source3/lib/username.c | 30 |
1 files 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; } |