summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/passdb/lookup_sid.c13
-rw-r--r--source3/passdb/pdb_ldap.c35
-rw-r--r--source3/winbindd/idmap_util.c18
-rw-r--r--source3/winbindd/winbindd_sids_to_xids.c41
4 files changed, 52 insertions, 55 deletions
diff --git a/source3/passdb/lookup_sid.c b/source3/passdb/lookup_sid.c
index a72cbd0986..4ceba3cdd2 100644
--- a/source3/passdb/lookup_sid.c
+++ b/source3/passdb/lookup_sid.c
@@ -1284,16 +1284,9 @@ bool sids_to_unixids(const struct dom_sid *sids, uint32_t num_sids,
ids[i].id = rid;
continue;
}
- if (idmap_cache_find_sid2uid(&sids[i], &ids[i].id,
- &expired)
- && !expired) {
- ids[i].type = ID_TYPE_UID;
- continue;
- }
- if (idmap_cache_find_sid2gid(&sids[i], &ids[i].id,
- &expired)
- && !expired) {
- ids[i].type = ID_TYPE_GID;
+ if (idmap_cache_find_sid2unixid(&sids[i], &ids[i], &expired)
+ && !expired)
+ {
continue;
}
ids[i].type = ID_TYPE_NOT_SPECIFIED;
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index 89e05c0169..1ebfa15029 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -1008,6 +1008,7 @@ static bool init_sam_from_ldap(struct ldapsam_privates *ldap_state,
bool have_gid = false;
struct dom_sid mapped_gsid;
const struct dom_sid *primary_gsid;
+ struct unixid id;
ZERO_STRUCT(unix_pw);
@@ -1071,14 +1072,18 @@ static bool init_sam_from_ldap(struct ldapsam_privates *ldap_state,
goto fn_exit;
}
- idmap_cache_set_sid2uid(pdb_get_user_sid(sampass),
- sampass->unix_pw->pw_uid);
+ id.id = sampass->unix_pw->pw_uid;
+ id.type = ID_TYPE_UID;
+
+ idmap_cache_set_sid2unixid(pdb_get_user_sid(sampass), &id);
gid_to_sid(&mapped_gsid, sampass->unix_pw->pw_gid);
primary_gsid = pdb_get_group_sid(sampass);
if (primary_gsid && dom_sid_equal(primary_gsid, &mapped_gsid)) {
- idmap_cache_set_sid2gid(primary_gsid,
- sampass->unix_pw->pw_gid);
+ id.id = sampass->unix_pw->pw_gid;
+ id.type = ID_TYPE_GID;
+
+ idmap_cache_set_sid2unixid(primary_gsid, &id);
}
}
@@ -2476,7 +2481,11 @@ for gidNumber(%lu)\n",(unsigned long)map->gid));
}
if (lp_parm_bool(-1, "ldapsam", "trusted", false)) {
- idmap_cache_set_sid2gid(&map->sid, map->gid);
+ struct unixid id;
+ id.id = map->gid;
+ id.type = ID_TYPE_GID;
+
+ idmap_cache_set_sid2unixid(&map->sid, &id);
}
TALLOC_FREE(ctx);
@@ -5035,7 +5044,7 @@ static bool ldapsam_sid_to_id(struct pdb_methods *methods,
id->id = strtoul(gid_str, NULL, 10);
id->type = ID_TYPE_GID;
- idmap_cache_set_sid2gid(sid, id->id);
+ idmap_cache_set_sid2unixid(sid, id);
ret = True;
goto done;
}
@@ -5052,7 +5061,7 @@ static bool ldapsam_sid_to_id(struct pdb_methods *methods,
id->id = strtoul(value, NULL, 10);
id->type = ID_TYPE_UID;
- idmap_cache_set_sid2uid(sid, id->id);
+ idmap_cache_set_sid2unixid(sid, id);
ret = True;
done:
@@ -5078,6 +5087,7 @@ static bool ldapsam_uid_to_sid(struct pdb_methods *methods, uid_t uid,
struct dom_sid user_sid;
int rc;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
+ struct unixid id;
filter = talloc_asprintf(tmp_ctx,
"(&(uidNumber=%u)"
@@ -5122,7 +5132,10 @@ static bool ldapsam_uid_to_sid(struct pdb_methods *methods, uid_t uid,
sid_copy(sid, &user_sid);
- idmap_cache_set_sid2uid(sid, uid);
+ id.id = uid;
+ id.type = ID_TYPE_UID;
+
+ idmap_cache_set_sid2unixid(sid, &id);
ret = true;
@@ -5149,6 +5162,7 @@ static bool ldapsam_gid_to_sid(struct pdb_methods *methods, gid_t gid,
struct dom_sid group_sid;
int rc;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
+ struct unixid id;
filter = talloc_asprintf(tmp_ctx,
"(&(gidNumber=%u)"
@@ -5191,7 +5205,10 @@ static bool ldapsam_gid_to_sid(struct pdb_methods *methods, gid_t gid,
sid_copy(sid, &group_sid);
- idmap_cache_set_sid2gid(sid, gid);
+ id.id = gid;
+ id.type = ID_TYPE_GID;
+
+ idmap_cache_set_sid2unixid(sid, &id);
ret = true;
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;