summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2019-03-21 14:00:16 +0100
committerJule Anger <janger@samba.org>2023-03-30 15:10:10 +0000
commit61f3e6740765c92cd84c28ee69fe410c18b548fc (patch)
treec9f2e1c809278b501d334d40dc91b8f888222d3b
parenta19fe9301999a0ce308f06643ff3be1bbac7beb7 (diff)
downloadsamba-61f3e6740765c92cd84c28ee69fe410c18b548fc.tar.gz
idmap_hash: mirror the NT_STATUS_NONE_MAPPED/STATUS_SOME_UNMAPPED logic from idmap_autorid
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 14102b05f3744c67178bd719d41e67fc3e049ee4)
-rw-r--r--source3/winbindd/idmap_hash/idmap_hash.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/source3/winbindd/idmap_hash/idmap_hash.c b/source3/winbindd/idmap_hash/idmap_hash.c
index 7b849aa0259..ff9f86b6676 100644
--- a/source3/winbindd/idmap_hash/idmap_hash.c
+++ b/source3/winbindd/idmap_hash/idmap_hash.c
@@ -188,11 +188,14 @@ static NTSTATUS unixids_to_sids(struct idmap_domain *dom,
{
struct sid_hash_table *hashed_domains = talloc_get_type_abort(
dom->private_data, struct sid_hash_table);
- int i;
+ size_t i;
+ size_t num_tomap = 0;
+ size_t num_mapped = 0;
- /* initialize the status to avoid suprise */
+ /* initialize the status to avoid surprise */
for (i = 0; ids[i]; i++) {
ids[i]->status = ID_UNKNOWN;
+ num_tomap++;
}
for (i=0; ids[i]; i++) {
@@ -211,9 +214,16 @@ static NTSTATUS unixids_to_sids(struct idmap_domain *dom,
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++;
}
- return NT_STATUS_OK;
+ if (num_tomap == num_mapped) {
+ return NT_STATUS_OK;
+ } else if (num_mapped == 0) {
+ return NT_STATUS_NONE_MAPPED;
+ }
+
+ return STATUS_SOME_UNMAPPED;
}
/*********************************************************************
@@ -222,11 +232,15 @@ static NTSTATUS unixids_to_sids(struct idmap_domain *dom,
static NTSTATUS sids_to_unixids(struct idmap_domain *dom,
struct id_map **ids)
{
- int i;
+ size_t i;
+ size_t num_tomap = 0;
+ size_t num_mapped = 0;
+ size_t num_required = 0;
- /* initialize the status to avoid suprise */
+ /* initialize the status to avoid surprise */
for (i = 0; ids[i]; i++) {
ids[i]->status = ID_UNKNOWN;
+ num_tomap++;
}
for (i=0; ids[i]; i++) {
@@ -252,6 +266,7 @@ static NTSTATUS sids_to_unixids(struct idmap_domain *dom,
* if the domain is not known yet.
*/
ids[i]->status = ID_REQUIRE_TYPE;
+ num_required++;
continue;
}
@@ -282,10 +297,19 @@ static NTSTATUS sids_to_unixids(struct idmap_domain *dom,
ids[i]->xid.type = ID_TYPE_BOTH;
ids[i]->xid.id = combine_hashes(h_domain, h_rid);
ids[i]->status = ID_MAPPED;
+ num_mapped++;
}
}
- return NT_STATUS_OK;
+ if (num_tomap == num_mapped) {
+ return NT_STATUS_OK;
+ } else if (num_required > 0) {
+ return STATUS_SOME_UNMAPPED;
+ } else if (num_mapped == 0) {
+ return NT_STATUS_NONE_MAPPED;
+ }
+
+ return STATUS_SOME_UNMAPPED;
}
/*********************************************************************