diff options
author | Stefan Metzmacher <metze@samba.org> | 2019-03-21 14:00:16 +0100 |
---|---|---|
committer | Jule Anger <janger@samba.org> | 2023-04-05 10:40:13 +0000 |
commit | 54e872cdf051e718b6ba186ab80b4e7974cd13cf (patch) | |
tree | d6e0fc978bdc4de7130d32eb2d301a58b5524412 | |
parent | 678c66f1327988fe4ad0def6a3a43d789ae42387 (diff) | |
download | samba-54e872cdf051e718b6ba186ab80b4e7974cd13cf.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.c | 36 |
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; } /********************************************************************* |