From: Stefan Metzmacher Date: Tue, 11 Feb 2025 23:49:07 +0000 (+0100) Subject: libcli/lsarpc: add trust_forest_info_lsa_{1to2,2to1}() X-Git-Tag: tevent-0.17.0~699 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8dc11c71b4dee5a103084f4ddce1378e1cdc293c;p=thirdparty%2Fsamba.git libcli/lsarpc: add trust_forest_info_lsa_{1to2,2to1}() Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme --- diff --git a/libcli/lsarpc/util_lsarpc.c b/libcli/lsarpc/util_lsarpc.c index 880b3d9d1d0..e823b6c1cc9 100644 --- a/libcli/lsarpc/util_lsarpc.c +++ b/libcli/lsarpc/util_lsarpc.c @@ -817,6 +817,62 @@ NTSTATUS trust_forest_info_to_lsa2(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } +NTSTATUS trust_forest_info_lsa_1to2(TALLOC_CTX *mem_ctx, + const struct lsa_ForestTrustInformation *lfti, + struct lsa_ForestTrustInformation2 **_lfti2) +{ + TALLOC_CTX *frame = talloc_stackframe(); + struct ForestTrustInfo *fti = NULL; + struct lsa_ForestTrustInformation2 *lfti2 = NULL; + NTSTATUS status; + + status = trust_forest_info_from_lsa(frame, lfti, &fti); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(frame); + return status; + } + + status = trust_forest_info_to_lsa2(mem_ctx, + fti, + &lfti2); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(frame); + return status; + } + + *_lfti2 = lfti2; + TALLOC_FREE(frame); + return NT_STATUS_OK; +} + +NTSTATUS trust_forest_info_lsa_2to1(TALLOC_CTX *mem_ctx, + const struct lsa_ForestTrustInformation2 *lfti2, + struct lsa_ForestTrustInformation **_lfti) +{ + TALLOC_CTX *frame = talloc_stackframe(); + struct ForestTrustInfo *fti = NULL; + struct lsa_ForestTrustInformation *lfti = NULL; + NTSTATUS status; + + status = trust_forest_info_from_lsa2(frame, lfti2, &fti); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(frame); + return status; + } + + status = trust_forest_info_to_lsa(mem_ctx, + fti, + &lfti); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(frame); + return status; + } + + *_lfti = lfti; + TALLOC_FREE(frame); + return NT_STATUS_OK; +} + static int trust_forest_info_tln_match_internal( const struct lsa_ForestTrustInformation *info, enum lsa_ForestTrustRecordType type, diff --git a/libcli/lsarpc/util_lsarpc.h b/libcli/lsarpc/util_lsarpc.h index 97b12ee67e6..b894f9ab23f 100644 --- a/libcli/lsarpc/util_lsarpc.h +++ b/libcli/lsarpc/util_lsarpc.h @@ -52,6 +52,12 @@ NTSTATUS trust_forest_info_from_lsa2(TALLOC_CTX *mem_ctx, NTSTATUS trust_forest_info_to_lsa2(TALLOC_CTX *mem_ctx, const struct ForestTrustInfo *fti, struct lsa_ForestTrustInformation2 **_lfti); +NTSTATUS trust_forest_info_lsa_1to2(TALLOC_CTX *mem_ctx, + const struct lsa_ForestTrustInformation *lfti, + struct lsa_ForestTrustInformation2 **_lfti2); +NTSTATUS trust_forest_info_lsa_2to1(TALLOC_CTX *mem_ctx, + const struct lsa_ForestTrustInformation2 *lfti2, + struct lsa_ForestTrustInformation **_lfti); bool trust_forest_info_tln_match( const struct lsa_ForestTrustInformation *info,