summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2019-03-21 14:05:13 +0100
committerJule Anger <janger@samba.org>2023-03-30 15:10:10 +0000
commitda2706429185ec6724d91f409f78ffbf10f7208c (patch)
tree422cd3d406a68d8a25787833e444c30e173d9004
parent61f3e6740765c92cd84c28ee69fe410c18b548fc (diff)
downloadsamba-da2706429185ec6724d91f409f78ffbf10f7208c.tar.gz
idmap_hash: split out a idmap_hash_id_to_sid() helper function
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15319 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> (cherry picked from commit 57150b463fb8e27c048670f7b4902bd091ee3ae9)
-rw-r--r--source3/winbindd/idmap_hash/idmap_hash.c54
1 files changed, 39 insertions, 15 deletions
diff --git a/source3/winbindd/idmap_hash/idmap_hash.c b/source3/winbindd/idmap_hash/idmap_hash.c
index ff9f86b6676..1f353c331d5 100644
--- a/source3/winbindd/idmap_hash/idmap_hash.c
+++ b/source3/winbindd/idmap_hash/idmap_hash.c
@@ -183,6 +183,32 @@ done:
/*********************************************************************
********************************************************************/
+static NTSTATUS idmap_hash_id_to_sid(struct sid_hash_table *hashed_domains,
+ struct idmap_domain *dom,
+ struct id_map *id)
+{
+ uint32_t h_domain = 0, h_rid = 0;
+
+ id->status = ID_UNMAPPED;
+
+ separate_hashes(id->xid.id, &h_domain, &h_rid);
+
+ /*
+ * If the domain hash doesn't find a SID in the table,
+ * skip it
+ */
+ if (hashed_domains[h_domain].sid == NULL) {
+ /* keep ID_UNMAPPED */
+ return NT_STATUS_OK;
+ }
+
+ id->xid.type = ID_TYPE_BOTH;
+ sid_compose(id->sid, hashed_domains[h_domain].sid, h_rid);
+ id->status = ID_MAPPED;
+
+ return NT_STATUS_OK;
+}
+
static NTSTATUS unixids_to_sids(struct idmap_domain *dom,
struct id_map **ids)
{
@@ -199,22 +225,20 @@ static NTSTATUS unixids_to_sids(struct idmap_domain *dom,
}
for (i=0; ids[i]; i++) {
- uint32_t h_domain, h_rid;
-
- ids[i]->status = ID_UNMAPPED;
-
- separate_hashes(ids[i]->xid.id, &h_domain, &h_rid);
-
- /* If the domain hash doesn't find a SID in the table,
- skip it */
-
- if (!hashed_domains[h_domain].sid)
- continue;
+ NTSTATUS ret;
+
+ ret = idmap_hash_id_to_sid(hashed_domains, dom, ids[i]);
+ if (!NT_STATUS_IS_OK(ret)) {
+ /* some fatal error occurred, log it */
+ DBG_NOTICE("Unexpected error resolving an ID "
+ "(%d): %s\n", ids[i]->xid.id,
+ nt_errstr(ret));
+ return ret;
+ }
- ids[i]->xid.type = ID_TYPE_BOTH;
- sid_compose(ids[i]->sid, hashed_domains[h_domain].sid, h_rid);
- ids[i]->status = ID_MAPPED;
- num_mapped++;
+ if (ids[i]->status == ID_MAPPED) {
+ num_mapped++;
+ }
}
if (num_tomap == num_mapped) {