From 80b8bbe48511d764cac4334182c3fb7b47fd54f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Mon, 15 Feb 2021 20:57:04 +0100 Subject: [PATCH] s3-libnet_join: add libnet_odj_find_win7blob to libnet_offline_join Guenther Signed-off-by: Guenther Deschner Reviewed-by: Alexander Bokovoy --- source3/libnet/libnet_join_offline.c | 51 ++++++++++++++++++++++++++++ source3/libnet/libnet_join_offline.h | 2 ++ 2 files changed, 53 insertions(+) diff --git a/source3/libnet/libnet_join_offline.c b/source3/libnet/libnet_join_offline.c index d96d509d0fb..5e08ba46deb 100644 --- a/source3/libnet/libnet_join_offline.c +++ b/source3/libnet/libnet_join_offline.c @@ -322,3 +322,54 @@ WERROR libnet_odj_compose_ODJ_PROVISION_DATA(TALLOC_CTX *mem_ctx, return WERR_OK; } + +WERROR libnet_odj_find_win7blob(const struct ODJ_PROVISION_DATA *r, + struct ODJ_WIN7BLOB *win7blob) +{ + int i; + + if (r == NULL) { + return WERR_INVALID_PARAMETER; + } + + for (i = 0; i < r->ulcBlobs; i++) { + + struct ODJ_BLOB b = r->pBlobs[i]; + + switch (b.ulODJFormat) { + case ODJ_WIN7_FORMAT: + *win7blob = b.pBlob->odj_win7blob; + return WERR_OK; + + case ODJ_WIN8_FORMAT: { + NTSTATUS status; + struct OP_PACKAGE_PART_COLLECTION *col; + struct GUID guid; + int k; + + if (b.pBlob->op_package.p->WrappedPartCollection.w == NULL) { + return WERR_BAD_FORMAT; + } + + col = b.pBlob->op_package.p->WrappedPartCollection.w->s.p; + + status = GUID_from_string(ODJ_GUID_JOIN_PROVIDER, &guid); + if (!NT_STATUS_IS_OK(status)) { + return WERR_NOT_ENOUGH_MEMORY; + } + + for (k = 0; k < col->cParts; k++) { + if (GUID_equal(&guid, &col->pParts[k].PartType)) { + *win7blob = col->pParts[k].Part->win7blob; + return WERR_OK; + } + } + break; + } + default: + return WERR_BAD_FORMAT; + } + } + + return WERR_BAD_FORMAT; +} diff --git a/source3/libnet/libnet_join_offline.h b/source3/libnet/libnet_join_offline.h index 3ef80fa31c4..5abebcf6372 100644 --- a/source3/libnet/libnet_join_offline.h +++ b/source3/libnet/libnet_join_offline.h @@ -20,3 +20,5 @@ WERROR libnet_odj_compose_ODJ_PROVISION_DATA(TALLOC_CTX *mem_ctx, const struct libnet_JoinCtx *r, struct ODJ_PROVISION_DATA **b_p); +WERROR libnet_odj_find_win7blob(const struct ODJ_PROVISION_DATA *r, + struct ODJ_WIN7BLOB *win7blob);