idmap_hash: mirror the NT_STATUS_NONE_MAPPED/STATUS_SOME_UNMAPPED logic from idmap_au...
authorStefan Metzmacher <metze@samba.org>
Thu, 21 Mar 2019 13:00:16 +0000 (14:00 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 15 Oct 2019 07:36:38 +0000 (09:36 +0200)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
source3/winbindd/idmap_hash/idmap_hash.c

index 47e4e12c896da99b3988d733126168c28ea44406..c2f6e43f067d17a63e3e664b12ae41b016517ae4 100644 (file)
@@ -189,10 +189,13 @@ 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;
+       int num_tomap = 0;
+       int 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++) {
@@ -210,9 +213,16 @@ static NTSTATUS unixids_to_sids(struct idmap_domain *dom,
 
                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,10 +232,13 @@ static NTSTATUS sids_to_unixids(struct idmap_domain *dom,
                                struct id_map **ids)
 {
        int i;
+       int num_tomap = 0;
+       int 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++) {
@@ -246,10 +259,17 @@ static NTSTATUS sids_to_unixids(struct idmap_domain *dom,
                if (h_domain && h_rid) {
                        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_mapped == 0) {
+               return NT_STATUS_NONE_MAPPED;
+       }
+
+       return STATUS_SOME_UNMAPPED;
 }
 
 /*********************************************************************