v3-4-test: Correctly calculate the wbinfo -s result
authorVolker Lendecke <vl@samba.org>
Tue, 23 Nov 2010 13:28:45 +0000 (14:28 +0100)
committerVolker Lendecke <vl@samba.org>
Tue, 23 Nov 2010 16:54:15 +0000 (17:54 +0100)
source3/rpc_client/cli_lsarpc.c

index 74fd08276c35e45b67bcff2fe7bdd5d01dbd660e..f02586ac438db8596cd7b4e16996d7a8d6702d90 100644 (file)
@@ -285,6 +285,8 @@ static NTSTATUS rpccli_lsa_lookup_sids_generic(struct rpc_pipe_client *cli,
        char **domains = NULL;
        char **names = NULL;
        enum lsa_SidType *types = NULL;
+       bool have_mapped = false;
+       bool have_unmapped = false;
 
        if (num_sids) {
                if (!(domains = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
@@ -344,14 +346,21 @@ static NTSTATUS rpccli_lsa_lookup_sids_generic(struct rpc_pipe_client *cli,
                        goto fail;
                }
 
-               /* adapt overall result */
-               if (( NT_STATUS_IS_OK(result) &&
-                    !NT_STATUS_IS_OK(hunk_result))
-                   ||
-                   ( NT_STATUS_EQUAL(result, NT_STATUS_NONE_MAPPED) &&
-                    !NT_STATUS_EQUAL(hunk_result, NT_STATUS_NONE_MAPPED)))
-               {
-                       result = STATUS_SOME_UNMAPPED;
+               if (NT_STATUS_IS_OK(hunk_result)) {
+                       have_mapped = true;
+               }
+               if (NT_STATUS_EQUAL(hunk_result, NT_STATUS_NONE_MAPPED)) {
+                       have_unmapped = true;
+               }
+               if (NT_STATUS_EQUAL(hunk_result, STATUS_SOME_UNMAPPED)) {
+                       int i;
+                       for (i=0; i<hunk_num_sids; i++) {
+                               if (hunk_types[i] == SID_NAME_UNKNOWN) {
+                                       have_unmapped = true;
+                               } else {
+                                       have_mapped = true;
+                               }
+                       }
                }
 
                sids_left -= hunk_num_sids;
@@ -365,7 +374,14 @@ static NTSTATUS rpccli_lsa_lookup_sids_generic(struct rpc_pipe_client *cli,
        *pdomains = domains;
        *pnames = names;
        *ptypes = types;
-       return result;
+
+       if (!have_mapped) {
+               return NT_STATUS_NONE_MAPPED;
+       }
+       if (have_unmapped) {
+               return STATUS_SOME_UNMAPPED;
+       }
+       return NT_STATUS_OK;
 
 fail:
        TALLOC_FREE(domains);