1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-26 10:04:02 +03:00

nwrap: Avoid a string comparsion in getgrouplist()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
This commit is contained in:
Andreas Schneider 2015-09-14 14:52:51 +02:00 committed by Michael Adam
parent 1c346a07ff
commit a104389de2

View File

@ -3552,7 +3552,6 @@ static int nwrap_getgrouplist(const char *user, gid_t group,
struct group *grp;
gid_t *groups_tmp;
int count = 1;
const char *name_of_group = "";
NWRAP_LOG(NWRAP_LOG_DEBUG, "getgrouplist called for %s", user);
@ -3565,11 +3564,6 @@ static int nwrap_getgrouplist(const char *user, gid_t group,
memcpy(groups_tmp, &group, sizeof(gid_t));
grp = nwrap_getgrgid(group);
if (grp) {
name_of_group = grp->gr_name;
}
nwrap_setgrent();
while ((grp = nwrap_getgrent()) != NULL) {
int i = 0;
@ -3580,8 +3574,8 @@ static int nwrap_getgrouplist(const char *user, gid_t group,
for (i=0; grp->gr_mem && grp->gr_mem[i] != NULL; i++) {
if ((strcmp(user, grp->gr_mem[i]) == 0) &&
(strcmp(name_of_group, grp->gr_name) != 0)) {
if (group != grp->gr_gid &&
(strcmp(user, grp->gr_mem[i]) == 0)) {
NWRAP_LOG(NWRAP_LOG_DEBUG,
"%s is member of %s",