s3:libnetapi: Add some comments to document ODJ blob charset conversions
authorSamuel Cabrero <scabrero@samba.org>
Mon, 4 Sep 2023 08:47:06 +0000 (10:47 +0200)
committerJule Anger <janger@samba.org>
Wed, 29 Nov 2023 14:51:11 +0000 (14:51 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13577

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit bdab834dfad55776155915f7ec410b5a192406fa)

source3/lib/netapi/joindomain.c
source3/utils/net_offlinejoin.c

index 7145ce5d6d1a0c1797e54290f05a29e900f8c07b..31e3ac74b1ee0da6405d56356874e6ef192ad4e6 100644 (file)
@@ -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,
index 0cfd5fdfe235fae301ee42cdf6d031a27eb2dad3..6a25d70280eef98eada4e1875dc16878c838105a 100644 (file)
@@ -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;