From 394622ef8c916cf361f8596dba4664dc8d6bfc9e Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 22 Jan 2013 18:08:25 +0100 Subject: [PATCH] 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 Autobuild-User(master): Stefan Metzmacher Autobuild-Date(master): Tue Jan 29 23:46:19 CET 2013 on sn-devel-104 --- source3/winbindd/wb_getpwsid.c | 52 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/source3/winbindd/wb_getpwsid.c b/source3/winbindd/wb_getpwsid.c index ef54ee5f48e..df8b0f2dcc7 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)) { -- 2.11.4.GIT