summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-10-11 03:46:14 +0000
committerJeremy Allison <jra@samba.org>2000-10-11 03:46:14 +0000
commit449821248784129f507bdb048c6721135606c546 (patch)
tree3d61dc001927d312b927ca175d8ecc2235cdb64b
parent26a4a34d36aff371b2b03506b4e7544847dd1d69 (diff)
downloadsamba-449821248784129f507bdb048c6721135606c546.tar.gz
samba-449821248784129f507bdb048c6721135606c546.tar.bz2
samba-449821248784129f507bdb048c6721135606c546.zip
Fix to avoid calling getgrgid for no reason.
Jeremy. (This used to be commit b057a7349b2d6420f96a6ebc31822da66b39fe6c)
-rw-r--r--source3/lib/username.c30
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;
}