s3:winbindd: change wb_getgrsid to use wb_sids2xids instead of wb_sid2gid
authorMichael Adam <obnox@samba.org>
Fri, 23 Nov 2012 15:44:41 +0000 (16:44 +0100)
committerStefan Metzmacher <metze@samba.org>
Mon, 3 Dec 2012 07:48:25 +0000 (08:48 +0100)
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/winbindd/wb_getgrsid.c

index 7d7e56a5ca2da47a08559eb856d8f5a726a59f03..2097539e29cc5d614731daa12e2c0bd0db2c0798 100644 (file)
@@ -97,7 +97,7 @@ static void wb_getgrsid_lookupsid_done(struct tevent_req *subreq)
                return;
        }
 
-       subreq = wb_sid2gid_send(state, state->ev, &state->sid);
+       subreq = wb_sids2xids_send(state, state->ev, &state->sid, 1);
        if (tevent_req_nomem(subreq, req)) {
                return;
        }
@@ -111,12 +111,27 @@ static void wb_getgrsid_sid2gid_done(struct tevent_req *subreq)
        struct wb_getgrsid_state *state = tevent_req_data(
                req, struct wb_getgrsid_state);
        NTSTATUS status;
+       struct unixid xid;
 
-       status = wb_sid2gid_recv(subreq, &state->gid);
+       status = wb_sids2xids_recv(subreq, &xid);
        TALLOC_FREE(subreq);
        if (tevent_req_nterror(req, status)) {
                return;
        }
+
+       /*
+        * We are filtering further down in sids2xids, but that filtering
+        * depends on the actual type of the sid handed in (as determined
+        * by lookupsids). Here we need to filter for the type of object
+        * actually requested, in this case uid.
+        */
+       if (!(xid.type == ID_TYPE_GID || xid.type == ID_TYPE_BOTH)) {
+               tevent_req_nterror(req, NT_STATUS_NONE_MAPPED);
+               return;
+       }
+
+       state->gid = (gid_t)xid.id;
+
        subreq = wb_group_members_send(state, state->ev, &state->sid,
                                       state->type, state->max_nesting);
        if (tevent_req_nomem(subreq, req)) {