s3:winbind: fix gid counting and error handling in the getgroups implementation
authorMichael Adam <obnox@samba.org>
Fri, 26 Jul 2013 09:31:41 +0000 (11:31 +0200)
committerMichael Adam <obnox@samba.org>
Mon, 29 Jul 2013 10:53:54 +0000 (12:53 +0200)
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Michael Adam <obnox@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
source3/winbindd/winbindd_getgroups.c

index 1774901903318a5bd69a7136ec6865632fc8bb71..bed8877cabdc0c67213168ff8c933bbd180685ee 100644 (file)
@@ -156,18 +156,22 @@ static void winbindd_getgroups_sid2gid_done(struct tevent_req *subreq)
 
        status = wb_sids2xids_recv(subreq, &xid);
        TALLOC_FREE(subreq);
+       if (NT_STATUS_EQUAL(status, NT_STATUS_NONE_MAPPED) ||
+           NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED))
+       {
+               status = NT_STATUS_OK;
+       }
+       if (tevent_req_nterror(req, status)) {
+               return;
+       }
+
        if (xid.type == ID_TYPE_GID || xid.type == ID_TYPE_BOTH) {
                state->gids[state->num_gids] = (gid_t)xid.id;
+               state->num_gids += 1;
        } else {
                state->gids[state->num_gids] = (uid_t)-1;
        }
 
-       /*
-        * In case of failure, just continue with the next gid
-        */
-       if (NT_STATUS_IS_OK(status)) {
-               state->num_gids += 1;
-       }
        state->next_sid += 1;
 
        if (state->next_sid >= state->num_sids) {