s3/rpc_client: make map_validation_to_info3() public and move to util_netlogon
authorRalph Boehme <slow@samba.org>
Thu, 30 Nov 2017 22:19:07 +0000 (23:19 +0100)
committerRalph Boehme <slow@samba.org>
Sat, 13 Jan 2018 07:24:08 +0000 (08:24 +0100)
Will be needed in the next commit.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/rpc_client/cli_netlogon.c
source3/rpc_client/util_netlogon.c
source3/rpc_client/util_netlogon.h

index 573ecd70457e034df39d59487d045a843753701a..67c87354e694f3a549b9578ca3fd618dff766090 100644 (file)
@@ -447,83 +447,6 @@ fail:
        return status;
 }
 
-static NTSTATUS map_validation_to_info3(TALLOC_CTX *mem_ctx,
-                                       uint16_t validation_level,
-                                       union netr_Validation *validation,
-                                       struct netr_SamInfo3 **info3_p)
-{
-       struct netr_SamInfo3 *info3;
-       struct netr_SamInfo6 *info6 = NULL;
-       NTSTATUS status;
-
-       if (validation == NULL) {
-               return NT_STATUS_INVALID_PARAMETER;
-       }
-
-       switch (validation_level) {
-       case 3:
-               if (validation->sam3 == NULL) {
-                       return NT_STATUS_INVALID_PARAMETER;
-               }
-
-               info3 = copy_netr_SamInfo3(mem_ctx, validation->sam3);
-               if (info3 == NULL) {
-                       return NT_STATUS_NO_MEMORY;
-               }
-               break;
-       case 6:
-               if (validation->sam6 == NULL) {
-                       return NT_STATUS_INVALID_PARAMETER;
-               }
-               info6 = validation->sam6;
-
-               info3 = talloc_zero(mem_ctx, struct netr_SamInfo3);
-               if (info3 == NULL) {
-                       return NT_STATUS_NO_MEMORY;
-               }
-
-               status = copy_netr_SamBaseInfo(info3,
-                                              &info6->base,
-                                              &info3->base);
-               if (!NT_STATUS_IS_OK(status)) {
-                       TALLOC_FREE(info3);
-                       return status;
-               }
-
-               if (validation->sam6->sidcount > 0) {
-                       int i;
-
-                       info3->sidcount = info6->sidcount;
-
-                       info3->sids = talloc_array(info3,
-                                                  struct netr_SidAttr,
-                                                  info3->sidcount);
-                       if (info3->sids == NULL) {
-                               TALLOC_FREE(info3);
-                               return NT_STATUS_NO_MEMORY;
-                       }
-
-                       for (i = 0; i < info3->sidcount; i++) {
-                               info3->sids[i].sid = dom_sid_dup(
-                                       info3->sids, info6->sids[i].sid);
-                               if (info3->sids[i].sid == NULL) {
-                                       TALLOC_FREE(info3);
-                                       return NT_STATUS_NO_MEMORY;
-                               }
-                               info3->sids[i].attributes =
-                                       info6->sids[i].attributes;
-                       }
-               }
-               break;
-       default:
-               return NT_STATUS_BAD_VALIDATION_CLASS;
-       }
-
-       *info3_p = info3;
-
-       return NT_STATUS_OK;
-}
-
 /* Logon domain user */
 
 NTSTATUS rpccli_netlogon_password_logon(
index ee2b590b7519dfa92d4a942200bf109f91fe7644..0e600d681e942a7aa3c5ce0ccf85247ad4a4363a 100644 (file)
@@ -102,3 +102,80 @@ struct netr_SamInfo3 *copy_netr_SamInfo3(TALLOC_CTX *mem_ctx,
 
        return info3;
 }
+
+NTSTATUS map_validation_to_info3(TALLOC_CTX *mem_ctx,
+                                uint16_t validation_level,
+                                union netr_Validation *validation,
+                                struct netr_SamInfo3 **info3_p)
+{
+       struct netr_SamInfo3 *info3;
+       struct netr_SamInfo6 *info6 = NULL;
+       NTSTATUS status;
+
+       if (validation == NULL) {
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+
+       switch (validation_level) {
+       case 3:
+               if (validation->sam3 == NULL) {
+                       return NT_STATUS_INVALID_PARAMETER;
+               }
+
+               info3 = copy_netr_SamInfo3(mem_ctx, validation->sam3);
+               if (info3 == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+               }
+               break;
+       case 6:
+               if (validation->sam6 == NULL) {
+                       return NT_STATUS_INVALID_PARAMETER;
+               }
+               info6 = validation->sam6;
+
+               info3 = talloc_zero(mem_ctx, struct netr_SamInfo3);
+               if (info3 == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+               }
+
+               status = copy_netr_SamBaseInfo(info3,
+                                              &info6->base,
+                                              &info3->base);
+               if (!NT_STATUS_IS_OK(status)) {
+                       TALLOC_FREE(info3);
+                       return status;
+               }
+
+               if (validation->sam6->sidcount > 0) {
+                       int i;
+
+                       info3->sidcount = info6->sidcount;
+
+                       info3->sids = talloc_array(info3,
+                                                  struct netr_SidAttr,
+                                                  info3->sidcount);
+                       if (info3->sids == NULL) {
+                               TALLOC_FREE(info3);
+                               return NT_STATUS_NO_MEMORY;
+                       }
+
+                       for (i = 0; i < info3->sidcount; i++) {
+                               info3->sids[i].sid = dom_sid_dup(
+                                       info3->sids, info6->sids[i].sid);
+                               if (info3->sids[i].sid == NULL) {
+                                       TALLOC_FREE(info3);
+                                       return NT_STATUS_NO_MEMORY;
+                               }
+                               info3->sids[i].attributes =
+                                       info6->sids[i].attributes;
+                       }
+               }
+               break;
+       default:
+               return NT_STATUS_BAD_VALIDATION_CLASS;
+       }
+
+       *info3_p = info3;
+
+       return NT_STATUS_OK;
+}
index 9e717dfe68955519689c9644d55daf9b563fef62..a89e043d5af1725c3f6d46ad8a41f5100938a197 100644 (file)
@@ -27,5 +27,9 @@ NTSTATUS copy_netr_SamBaseInfo(TALLOC_CTX *mem_ctx,
                               struct netr_SamBaseInfo *out);
 struct netr_SamInfo3 *copy_netr_SamInfo3(TALLOC_CTX *mem_ctx,
                                         const struct netr_SamInfo3 *orig);
+NTSTATUS map_validation_to_info3(TALLOC_CTX *mem_ctx,
+                                uint16_t validation_level,
+                                union netr_Validation *validation,
+                                struct netr_SamInfo3 **info3_p);
 
 #endif /* _RPC_CLIENT_UTIL_NETLOGON_H_ */