From 3e7f04b70f89d528aacfdc420b635d8aff0f4af6 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 17 Nov 2012 13:10:26 +0100 Subject: [PATCH] s3:winbindd: use wb_sids2xids instead of wb_sid2gid in winbindd_sid_to_gid The main purpose of the change is to hand the sid into the idmap backend and handle responsiblity for handling the sid-type correctly to the idmap backend instead of failing directly when the sid is not of group type. Hence backends like rid who are sid-type agnostic, can return gids also for sids of other types. This is an important fix to make sid_to_gid behave the consistently with and without the presence of cache entries. We need to additionally filter the result for id type GID or more general (BOTH) to keep the behaviour. This is a step towards using only one codepath to id_mapping. Signed-off-by: Michael Adam Reviewed-by: Stefan Metzmacher --- source3/winbindd/winbindd_sid_to_gid.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/source3/winbindd/winbindd_sid_to_gid.c b/source3/winbindd/winbindd_sid_to_gid.c index df44ed8d6b6..46ca903cd30 100644 --- a/source3/winbindd/winbindd_sid_to_gid.c +++ b/source3/winbindd/winbindd_sid_to_gid.c @@ -54,7 +54,7 @@ struct tevent_req *winbindd_sid_to_gid_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } - subreq = wb_sid2gid_send(state, ev, &state->sid); + subreq = wb_sids2xids_send(state, ev, &state->sid, 1); if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); } @@ -69,12 +69,26 @@ static void winbindd_sid_to_gid_done(struct tevent_req *subreq) struct winbindd_sid_to_gid_state *state = tevent_req_data( req, struct winbindd_sid_to_gid_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 gid. + */ + 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; tevent_req_done(req); } -- 2.34.1