diff options
author | Michael Adam <obnox@samba.org> | 2013-01-22 18:08:25 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2013-01-29 23:46:19 +0100 |
commit | 394622ef8c916cf361f8596dba4664dc8d6bfc9e (patch) | |
tree | 12986c9a4eaa2efa75b0d2d0ea6cae7c7929b01c /source3 | |
parent | b7095e9818bba8c43065cc1b1f29551203dc098b (diff) | |
download | samba-394622ef8c916cf361f8596dba4664dc8d6bfc9e.tar.gz samba-394622ef8c916cf361f8596dba4664dc8d6bfc9e.tar.bz2 samba-394622ef8c916cf361f8596dba4664dc8d6bfc9e.zip |
s3:winbindd: change getpwsid() to return a passwd struct for a group sid id-mapped with ID_TYPE_BOTH
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue Jan 29 23:46:19 CET 2013 on sn-devel-104
Diffstat (limited to 'source3')
-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)) { |