nwrap: Avoid a string comparsion in getgrouplist()
authorAndreas Schneider <asn@samba.org>
Mon, 14 Sep 2015 12:52:51 +0000 (14:52 +0200)
committerMichael Adam <obnox@samba.org>
Mon, 11 Jan 2016 11:25:27 +0000 (12:25 +0100)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
lib/nss_wrapper/nss_wrapper.c

index 2abbc24594fc7cfb7bac813fd4410d0073f66301..252735693886fd8a121a9e615de3b9f9cc4db9f9 100644 (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",