From c844f657793c0f8df3b2afcf710166b628e8233b Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 23 Mar 2012 21:11:33 +1100 Subject: s3-idmap: convert most idmap_cache callers to unixid API This will eventually allow the struct unixid to be passed all the way up and down the stack. Andrew Bartlett Signed-off-by: Michael Adam --- source3/winbindd/idmap_util.c | 18 +++++++++----- source3/winbindd/winbindd_sids_to_xids.c | 41 +++++++++----------------------- 2 files changed, 23 insertions(+), 36 deletions(-) (limited to 'source3/winbindd') diff --git a/source3/winbindd/idmap_util.c b/source3/winbindd/idmap_util.c index 2ddf576dc8..8e9d468dc5 100644 --- a/source3/winbindd/idmap_util.c +++ b/source3/winbindd/idmap_util.c @@ -74,15 +74,18 @@ backend: if (map.status != ID_MAPPED) { if (winbindd_use_idmap_cache()) { struct dom_sid null_sid; + struct unixid id; + id.type = ID_TYPE_UID; + id.id = uid; ZERO_STRUCT(null_sid); - idmap_cache_set_sid2uid(&null_sid, uid); + idmap_cache_set_sid2unixid(&null_sid, &id); } DEBUG(10, ("uid [%lu] not mapped\n", (unsigned long)uid)); return NT_STATUS_NONE_MAPPED; } if (winbindd_use_idmap_cache()) { - idmap_cache_set_sid2uid(sid, uid); + idmap_cache_set_sid2unixid(sid, &map.xid); } return NT_STATUS_OK; @@ -134,15 +137,18 @@ backend: if (map.status != ID_MAPPED) { if (winbindd_use_idmap_cache()) { struct dom_sid null_sid; + struct unixid id; + id.type = ID_TYPE_GID; + id.id = gid; ZERO_STRUCT(null_sid); - idmap_cache_set_sid2gid(&null_sid, gid); + idmap_cache_set_sid2unixid(&null_sid, &id); } DEBUG(10, ("gid [%lu] not mapped\n", (unsigned long)gid)); return NT_STATUS_NONE_MAPPED; } if (winbindd_use_idmap_cache()) { - idmap_cache_set_sid2gid(sid, gid); + idmap_cache_set_sid2unixid(sid, &map.xid); } return NT_STATUS_OK; @@ -217,7 +223,7 @@ backend: *uid = (uid_t)map.xid.id; if (winbindd_use_idmap_cache()) { - idmap_cache_set_sid2uid(sid, *uid); + idmap_cache_set_sid2unixid(sid, &map.xid); } return NT_STATUS_OK; } @@ -291,7 +297,7 @@ backend: *gid = map.xid.id; if (winbindd_use_idmap_cache()) { - idmap_cache_set_sid2gid(sid, *gid); + idmap_cache_set_sid2unixid(sid, &map.xid); } return NT_STATUS_OK; } diff --git a/source3/winbindd/winbindd_sids_to_xids.c b/source3/winbindd/winbindd_sids_to_xids.c index 2df5f54e75..8201739a96 100644 --- a/source3/winbindd/winbindd_sids_to_xids.c +++ b/source3/winbindd/winbindd_sids_to_xids.c @@ -123,34 +123,18 @@ struct tevent_req *winbindd_sids_to_xids_send(TALLOC_CTX *mem_ctx, static bool winbindd_sids_to_xids_in_cache(struct dom_sid *sid, struct id_map *map) { - uid_t uid; - gid_t gid; + struct unixid id; bool expired; if (!winbindd_use_idmap_cache()) { return false; } - /* - * SIDS_TO_XIDS is primarily used to resolve the user's group - * sids. So we check groups before users. - */ - if (idmap_cache_find_sid2gid(sid, &gid, &expired)) { + if (idmap_cache_find_sid2unixid(sid, &id, &expired)) { if (expired && is_domain_offline(find_our_domain())) { return false; } map->sid = sid; - map->xid.id = gid; - map->xid.type = ID_TYPE_GID; - map->status = ID_MAPPED; - return true; - } - if (idmap_cache_find_sid2uid(sid, &uid, &expired)) { - if (expired && is_domain_online(find_our_domain())) { - return false; - } - map->sid = sid; - map->xid.id = uid; - map->xid.type = ID_TYPE_UID; + map->xid = id; map->status = ID_MAPPED; return true; } @@ -267,30 +251,27 @@ NTSTATUS winbindd_sids_to_xids_recv(struct tevent_req *req, type = 'G'; } } else { - + struct unixid id; unix_id = state->ids.ids[num_non_cached].unix_id; if (unix_id == -1) { found = false; } - switch(state->ids.ids[num_non_cached].type) { + id.id = unix_id; + id.type = state->ids.ids[num_non_cached].type; + idmap_cache_set_sid2unixid( + &state->non_cached[num_non_cached], + &id); + + switch (id.type) { case ID_TYPE_UID: type = 'U'; - idmap_cache_set_sid2uid( - &state->non_cached[num_non_cached], - unix_id); break; case ID_TYPE_GID: type = 'G'; - idmap_cache_set_sid2gid( - &state->non_cached[num_non_cached], - unix_id); break; case ID_TYPE_BOTH: type = 'B'; - idmap_cache_set_sid2both( - &state->non_cached[num_non_cached], - unix_id); break; default: found = false; -- cgit