]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3-passdb: Fix pdb_samba4 setting of plaintext passwords
authorAndrew Bartlett <abartlet@samba.org>
Tue, 24 Jan 2012 07:38:09 +0000 (18:38 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 24 Jan 2012 07:38:09 +0000 (18:38 +1100)
We were setting a UTF8 password into the UTF16 clearTextPassword.

Converting from CH_UNIX to CH_UTF16 should fix this.

Andrew Bartlett

source3/passdb/pdb_samba4.c

index f336b8a9c61c0fe019cfecc4094f3426203d6e9b..bc3b1238c163c210ffcaa20798ed498fa698cb9c 100644 (file)
@@ -368,11 +368,19 @@ static int pdb_samba4_replace_by_sam(struct pdb_samba4_state *state,
 
        pw = pdb_get_plaintext_passwd(sam);
        if (need_update(sam, PDB_PLAINTEXT_PW)) {
+               struct ldb_val pw_utf16;
                if (pw == NULL) {
                        return LDB_ERR_OPERATIONS_ERROR;
                }
                
-               ret |= ldb_msg_add_string(msg, "clearTextPassword", pw);
+               if (!convert_string_talloc(msg,
+                                          CH_UNIX, CH_UTF16,
+                                          pw, strlen(pw),
+                                          (void *)&pw_utf16.data,
+                                          &pw_utf16.length)) {
+                       return LDB_ERR_OPERATIONS_ERROR;
+               }
+               ret |= ldb_msg_add_value(msg, "clearTextPassword", &pw_utf16, NULL);
        } else {
                bool changed_lm_pw = false;
                bool changed_nt_pw = false;