From a671885f49638aa18fdeed9fb3f040ffcc0b7a82 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 23 Mar 2011 18:18:13 +0100 Subject: s3: Add wbint_Sids2UnixIDs idl & implementation Signed-off-by: Jeremy Allison --- source3/winbindd/winbindd_dual_srv.c | 92 ++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) (limited to 'source3/winbindd') diff --git a/source3/winbindd/winbindd_dual_srv.c b/source3/winbindd/winbindd_dual_srv.c index e95dac234b..230edae908 100644 --- a/source3/winbindd/winbindd_dual_srv.c +++ b/source3/winbindd/winbindd_dual_srv.c @@ -118,6 +118,98 @@ NTSTATUS _wbint_Sid2Gid(struct pipes_struct *p, struct wbint_Sid2Gid *r) return NT_STATUS_OK; } +NTSTATUS _wbint_Sids2UnixIDs(struct pipes_struct *p, + struct wbint_Sids2UnixIDs *r) +{ + uint32_t i, j; + struct id_map *ids = NULL; + struct id_map **id_ptrs = NULL; + struct dom_sid *sids = NULL; + uint32_t *id_idx = NULL; + NTSTATUS status = NT_STATUS_NO_MEMORY; + + for (i=0; iin.domains->count; i++) { + struct lsa_DomainInfo *d = &r->in.domains->domains[i]; + struct idmap_domain *dom; + uint32_t num_ids; + + dom = idmap_find_domain(d->name.string); + if (dom == NULL) { + DEBUG(10, ("idmap domain %s not found\n", + d->name.string)); + continue; + } + + num_ids = 0; + + for (j=0; jin.ids->num_ids; j++) { + if (r->in.ids->ids[j].domain_index == i) { + num_ids += 1; + } + } + + ids = TALLOC_REALLOC_ARRAY(talloc_tos(), ids, + struct id_map, num_ids); + if (ids == NULL) { + goto nomem; + } + id_ptrs = TALLOC_REALLOC_ARRAY(talloc_tos(), id_ptrs, + struct id_map *, num_ids+1); + if (id_ptrs == NULL) { + goto nomem; + } + id_idx = TALLOC_REALLOC_ARRAY(talloc_tos(), id_idx, + uint32_t, num_ids); + if (id_idx == NULL) { + goto nomem; + } + sids = TALLOC_REALLOC_ARRAY(talloc_tos(), sids, + struct dom_sid, num_ids); + if (sids == NULL) { + goto nomem; + } + + num_ids = 0; + + for (j=0; jin.ids->num_ids; j++) { + struct wbint_TransID *id = &r->in.ids->ids[j]; + + if (id->domain_index != i) { + continue; + } + id_idx[num_ids] = j; + id_ptrs[num_ids] = &ids[num_ids]; + + ids[num_ids].sid = &sids[num_ids]; + sid_compose(ids[num_ids].sid, d->sid, id->rid); + ids[num_ids].xid.type = id->type; + ids[num_ids].status = ID_UNKNOWN; + num_ids += 1; + } + id_ptrs[num_ids] = NULL; + + status = dom->methods->sids_to_unixids(dom, id_ptrs); + DEBUG(10, ("sids_to_unixids returned %s\n", + nt_errstr(status))); + + for (j=0; jin.ids->ids[id_idx[j]]; + + if (ids[j].status != ID_MAPPED) { + continue; + } + id->unix_id = ids[j].xid.id; + } + } + status = NT_STATUS_OK; +nomem: + TALLOC_FREE(ids); + TALLOC_FREE(id_ptrs); + TALLOC_FREE(id_idx); + TALLOC_FREE(sids); + return status; +} + NTSTATUS _wbint_Uid2Sid(struct pipes_struct *p, struct wbint_Uid2Sid *r) { return idmap_uid_to_sid(r->in.dom_name ? r->in.dom_name : "", -- cgit