summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2012-11-23 16:40:48 +0100
committerStefan Metzmacher <metze@samba.org>2012-12-03 08:48:25 +0100
commit55ea9210e9b9cbb5a8b4633f492920af7eda77ab (patch)
tree128c9fe31b18c9c82a75ac0288c016bad6f0660b
parent46f2dfa7a51487e1b21c329dfb2e4cac3e6ada11 (diff)
downloadsamba-55ea9210e9b9cbb5a8b4633f492920af7eda77ab.tar.gz
samba-55ea9210e9b9cbb5a8b4633f492920af7eda77ab.tar.bz2
samba-55ea9210e9b9cbb5a8b4633f492920af7eda77ab.zip
s3:winbindd: change wb_fill_pwent to use wb_sids2xids instead of wb_sid2[ug]id
We can optimize this later and just do one wb_sids2xids_send/recv call. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
-rw-r--r--source3/winbindd/wb_fill_pwent.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/source3/winbindd/wb_fill_pwent.c b/source3/winbindd/wb_fill_pwent.c
index 62b1b4a189..a6a9013419 100644
--- a/source3/winbindd/wb_fill_pwent.c
+++ b/source3/winbindd/wb_fill_pwent.c
@@ -54,7 +54,7 @@ struct tevent_req *wb_fill_pwent_send(TALLOC_CTX *mem_ctx,
state->info = info;
state->pw = pw;
- subreq = wb_sid2uid_send(state, state->ev, &state->info->user_sid);
+ subreq = wb_sids2xids_send(state, state->ev, &state->info->user_sid, 1);
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
}
@@ -69,14 +69,28 @@ static void wb_fill_pwent_sid2uid_done(struct tevent_req *subreq)
struct wb_fill_pwent_state *state = tevent_req_data(
req, struct wb_fill_pwent_state);
NTSTATUS status;
+ struct unixid xid;
- status = wb_sid2uid_recv(subreq, &state->pw->pw_uid);
+ status = wb_sids2xids_recv(subreq, &xid);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
return;
}
- subreq = wb_sid2gid_send(state, state->ev, &state->info->group_sid);
+ /*
+ * 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 uid.
+ */
+ if (!(xid.type == ID_TYPE_UID || xid.type == ID_TYPE_BOTH)) {
+ tevent_req_nterror(req, NT_STATUS_NONE_MAPPED);
+ return;
+ }
+
+ state->pw->pw_uid = (uid_t)xid.id;
+
+ subreq = wb_sids2xids_send(state, state->ev, &state->info->group_sid, 1);
if (tevent_req_nomem(subreq, req)) {
return;
}
@@ -94,13 +108,27 @@ static void wb_fill_pwent_sid2gid_done(struct tevent_req *subreq)
fstring user_name, output_username;
char *mapped_name = NULL;
NTSTATUS status;
+ struct unixid xid;
- status = wb_sid2gid_recv(subreq, &state->pw->pw_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 uid.
+ */
+ if (!(xid.type == ID_TYPE_GID || xid.type == ID_TYPE_BOTH)) {
+ tevent_req_nterror(req, NT_STATUS_NONE_MAPPED);
+ return;
+ }
+
+ state->pw->pw_gid = (gid_t)xid.id;
+
domain = find_domain_from_sid_noinit(&state->info->user_sid);
if (domain == NULL) {
tevent_req_nterror(req, NT_STATUS_NO_SUCH_USER);