diff options
Diffstat (limited to 'source3/winbindd')
-rw-r--r-- | source3/winbindd/wb_getpwsid.c | 52 |
1 files changed, 43 insertions, 9 deletions
diff --git a/source3/winbindd/wb_getpwsid.c b/source3/winbindd/wb_getpwsid.c index ef54ee5f48..df8b0f2dcc 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)) { |