From f8021a241e50a20cd009fe2ad58e01133360e4e9 Mon Sep 17 00:00:00 2001 From: Samuel Cabrero Date: Mon, 4 Sep 2023 10:47:06 +0200 Subject: [PATCH] s3:libnetapi: Add some comments to document ODJ blob charset conversions BUG: https://bugzilla.samba.org/show_bug.cgi?id=13577 Signed-off-by: Samuel Cabrero Reviewed-by: Andrew Bartlett (cherry picked from commit bdab834dfad55776155915f7ec410b5a192406fa) --- source3/lib/netapi/joindomain.c | 4 ++++ source3/utils/net_offlinejoin.c | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c index 7145ce5d6d1..31e3ac74b1e 100644 --- a/source3/lib/netapi/joindomain.c +++ b/source3/lib/netapi/joindomain.c @@ -894,6 +894,10 @@ WERROR NetRequestOfflineDomainJoin_l(struct libnetapi_ctx *ctx, return W_ERROR(NERR_BadOfflineJoinInfo); } + /* + * Windows produces and consumes UTF16/UCS2 encoded blobs. Check for the + * unicode BOM mark and convert back to UNIX charset if necessary. + */ if (r->in.provision_bin_data[0] == 0xff && r->in.provision_bin_data[1] == 0xfe) { ok = convert_string_talloc(ctx, CH_UTF16LE, CH_UNIX, diff --git a/source3/utils/net_offlinejoin.c b/source3/utils/net_offlinejoin.c index 0cfd5fdfe23..6a25d70280e 100644 --- a/source3/utils/net_offlinejoin.c +++ b/source3/utils/net_offlinejoin.c @@ -193,11 +193,17 @@ int net_offlinejoin_provision(struct net_context *c, DATA_BLOB ucs2_blob, blob; bool ok; + /* + * Windows produces and consumes UTF16/UCS2 encoded blobs + * so we also do it for compatibility. Someone may provision an + * account for a Windows machine with samba. + */ ok = push_reg_sz(c, &ucs2_blob, provision_text_data); if (!ok) { return -1; } + /* Add the unicode BOM mark */ blob = data_blob_talloc(c, NULL, ucs2_blob.length + 2); blob.data[0] = 0xff; -- 2.47.2