diff options
author | Ralph Boehme <slow@samba.org> | 2017-11-30 23:19:07 +0100 |
---|---|---|
committer | Ralph Boehme <slow@samba.org> | 2018-01-13 08:24:08 +0100 |
commit | 7eed1661f61bdd946457fc1b3a968dbdf827956b (patch) | |
tree | 58c62c1c93d285560440482e6c5a783a38f68ec5 /source3/rpc_client | |
parent | a001f4b5090e391479565e89d16dabe036c54cf0 (diff) | |
download | samba-7eed1661f61bdd946457fc1b3a968dbdf827956b.tar.gz |
s3/rpc_client: make map_validation_to_info3() public and move to util_netlogon
Will be needed in the next commit.
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3/rpc_client')
-rw-r--r-- | source3/rpc_client/cli_netlogon.c | 77 | ||||
-rw-r--r-- | source3/rpc_client/util_netlogon.c | 77 | ||||
-rw-r--r-- | source3/rpc_client/util_netlogon.h | 4 |
3 files changed, 81 insertions, 77 deletions
diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c index 573ecd70457..67c87354e69 100644 --- a/source3/rpc_client/cli_netlogon.c +++ b/source3/rpc_client/cli_netlogon.c @@ -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( diff --git a/source3/rpc_client/util_netlogon.c b/source3/rpc_client/util_netlogon.c index ee2b590b751..0e600d681e9 100644 --- a/source3/rpc_client/util_netlogon.c +++ b/source3/rpc_client/util_netlogon.c @@ -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; +} diff --git a/source3/rpc_client/util_netlogon.h b/source3/rpc_client/util_netlogon.h index 9e717dfe689..a89e043d5af 100644 --- a/source3/rpc_client/util_netlogon.h +++ b/source3/rpc_client/util_netlogon.h @@ -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_ */ |