From: Michael Adam Date: Tue, 22 Jan 2013 17:08:25 +0000 (+0100) Subject: s3:winbindd: change getpwsid() to return a passwd struct for a group sid id-mapped... X-Git-Url: http://git.samba.org/?p=metze%2Fsamba%2Fwip.git;a=commitdiff_plain;h=40d6e38a9b6698a6e0d6a66bdc8cc016dc1eb4c2 s3:winbindd: change getpwsid() to return a passwd struct for a group sid id-mapped with ID_TYPE_BOTH Signed-off-by: Michael Adam Reviewed-by: Stefan Metzmacher --- diff --git a/source3/winbindd/wb_getpwsid.c b/source3/winbindd/wb_getpwsid.c index ef54ee5f48e9..df8b0f2dcc74 100644 --- a/source3/winbindd/wb_getpwsid.c +++ b/source3/winbindd/wb_getpwsid.c @@ -67,12 +67,10 @@ static void wb_getpwsid_queryuser_done(struct tevent_req *subreq) status = wb_queryuser_recv(subreq, state, &state->userinfo); TALLOC_FREE(subreq); - if (tevent_req_nterror(req, status)) { - return; - } - - if ((state->userinfo->acct_name != NULL) - && (state->userinfo->acct_name[0] != '\0')) { + if (NT_STATUS_IS_OK(status) + && (state->userinfo->acct_name != NULL) + && (state->userinfo->acct_name[0] != '\0')) + { /* * QueryUser got us a name, let's got directly to the * fill_pwent step @@ -87,10 +85,25 @@ static void wb_getpwsid_queryuser_done(struct tevent_req *subreq) } /* - * QueryUser didn't get us a name, do it via LSA. + * Either query_user did not succeed, or it + * succeeded but did not return an acct_name. + * (TODO: Can this happen at all???) + * ==> Try lsa_lookupsids. */ - subreq = wb_lookupsid_send(state, state->ev, - &state->userinfo->user_sid); + if (state->userinfo == NULL) { + state->userinfo = talloc_zero(state, struct wbint_userinfo); + if (tevent_req_nomem(state->userinfo, req)) { + return; + } + + /* a successful query_user call would have filled these */ + sid_copy(&state->userinfo->user_sid, &state->sid); + state->userinfo->homedir = NULL; + state->userinfo->shell = NULL; + state->userinfo->primary_gid = (gid_t)-1; + } + + subreq = wb_lookupsid_send(state, state->ev, &state->sid); if (tevent_req_nomem(subreq, req)) { return; } @@ -113,6 +126,27 @@ static void wb_getpwsid_lookupsid_done(struct tevent_req *subreq) if (tevent_req_nterror(req, status)) { return; } + + switch (type) { + case SID_NAME_USER: + case SID_NAME_COMPUTER: + /* + * user case: we only need the account name from lookup_sids + */ + break; + case SID_NAME_DOM_GRP: + case SID_NAME_ALIAS: + case SID_NAME_WKN_GRP: + /* + * also treat group-type SIDs (they might map to ID_TYPE_BOTH) + */ + sid_copy(&state->userinfo->group_sid, &state->sid); + break; + default: + tevent_req_nterror(req, NT_STATUS_NO_SUCH_USER); + return; + } + subreq = wb_fill_pwent_send(state, state->ev, state->userinfo, state->pw); if (tevent_req_nomem(subreq, req)) {