From 60943b52f237aedeca5b2945d49872fc4e4dc8ec Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 13 Feb 2025 15:05:02 +0100 Subject: [PATCH] libcli/lsarpc: add trust_forest_info_lsa_2to2() This normalizes LSA_FOREST_TRUST_BINARY_DATA in LSA_FOREST_TRUST_SCANNER_INFO. Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme --- libcli/lsarpc/util_lsarpc.c | 28 ++++++++++++++++++++++++++++ libcli/lsarpc/util_lsarpc.h | 3 +++ 2 files changed, 31 insertions(+) diff --git a/libcli/lsarpc/util_lsarpc.c b/libcli/lsarpc/util_lsarpc.c index ab5406004dd..a9c6cbd9823 100644 --- a/libcli/lsarpc/util_lsarpc.c +++ b/libcli/lsarpc/util_lsarpc.c @@ -1106,6 +1106,34 @@ NTSTATUS trust_forest_info_lsa_2to1(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } +NTSTATUS trust_forest_info_lsa_2to2(TALLOC_CTX *mem_ctx, + const struct lsa_ForestTrustInformation2 *in, + struct lsa_ForestTrustInformation2 **_out) +{ + TALLOC_CTX *frame = talloc_stackframe(); + struct ForestTrustInfo *fti = NULL; + struct lsa_ForestTrustInformation2 *out = NULL; + NTSTATUS status; + + status = trust_forest_info_from_lsa2(frame, in, &fti); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(frame); + return status; + } + + status = trust_forest_info_to_lsa2(mem_ctx, + fti, + &out); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(frame); + return status; + } + + *_out = out; + TALLOC_FREE(frame); + return NT_STATUS_OK; +} + static int trust_forest_info_tln_match_internal( const struct lsa_ForestTrustInformation2 *info, enum lsa_ForestTrustRecordType type, diff --git a/libcli/lsarpc/util_lsarpc.h b/libcli/lsarpc/util_lsarpc.h index 152fa52e389..8b075f04f24 100644 --- a/libcli/lsarpc/util_lsarpc.h +++ b/libcli/lsarpc/util_lsarpc.h @@ -58,6 +58,9 @@ NTSTATUS trust_forest_info_lsa_1to2(TALLOC_CTX *mem_ctx, NTSTATUS trust_forest_info_lsa_2to1(TALLOC_CTX *mem_ctx, const struct lsa_ForestTrustInformation2 *lfti2, struct lsa_ForestTrustInformation **_lfti); +NTSTATUS trust_forest_info_lsa_2to2(TALLOC_CTX *mem_ctx, + const struct lsa_ForestTrustInformation2 *in, + struct lsa_ForestTrustInformation2 **_out); bool trust_forest_info_tln_match( const struct lsa_ForestTrustInformation2 *info, -- 2.47.2