[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Thu Nov 11 03:38:01 MST 2010


The branch, master has been updated
       via  ba127f9 heimdal Don't dereference NULL in error verify_checksum error path
       via  a9baabe s4-provision UTF16 encode the password in sam.ldb, not secrets.ldb
       via  78928f5 s4-dsdb Remove incorrectly declared ** variable used as *.
       via  eebbbea s4-dsdb Convert new krbtgt_xxx password into UTF16
       via  01d10c8 s4-dsdb Return an error if we can't convert UTF16MUNGED -> UTF8
      from  bb241f5 s4:pytevent.c - fix a discard const warning

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit ba127f9849a1ac93c9bab3b8377a880264353b16
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Nov 11 20:44:16 2010 +1100

    heimdal Don't dereference NULL in error verify_checksum error path
    
    Autobuild-User: Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date: Thu Nov 11 10:37:03 UTC 2010 on sn-devel-104

commit a9baabed562fb6858bd82ee7312faa908283dde4
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Nov 11 19:55:26 2010 +1100

    s4-provision UTF16 encode the password in sam.ldb, not secrets.ldb
    
    The password in secrets.ldb is UTF8, while clearTextPassword in
    sam.ldb is UTF16.
    
    This corrects commit bd5039546e520b6d6897a658bc0a358f0511f7c7, which
    had these the wrong way around.
    
    Andrew Bartlett

commit 78928f5956d1b593e92875fd46a7071a4c979640
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Nov 11 18:36:06 2010 +1100

    s4-dsdb Remove incorrectly declared ** variable used as *.
    
    The cleartext_utf16_str variable was declared char **, but due to the
    cast on convert_string_talloc() and the lack of type checking here and
    on data_blob_const (due to void *) it was able to be used as if it was
    a char *.
    
    The simple solution seems to be to fill in cleartext_utf16 blob directly.
    
    Andrew Bartlett

commit eebbbeac1489a1a6241b4c15064d8aaeeec810ae
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Nov 11 18:33:14 2010 +1100

    s4-dsdb Convert new krbtgt_xxx password into UTF16
    
    The new stricter test on clearTextPassword values caught out that
    we did not provide a utf16 password here.
    
    Andrew Bartlett

commit 01d10c84134341c17e7b41e42bac8368c26d1201
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Nov 11 17:59:16 2010 +1100

    s4-dsdb Return an error if we can't convert UTF16MUNGED -> UTF8
    
    The UTF16MUNGED helper will map all invalid sequences (except odd
    input length) to valid input sequences, per the rules.  Therefore if
    it fails, we need to bail out, somehing serious is wrong.
    
    Andrew Bartlett

-----------------------------------------------------------------------

Summary of changes:
 source4/dsdb/samdb/ldb_modules/password_hash.c |   15 ++++++++-------
 source4/dsdb/samdb/ldb_modules/samldb.c        |   13 ++++++++++++-
 source4/heimdal/lib/krb5/crypto.c              |    2 +-
 source4/scripting/python/samba/provision.py    |    4 ++--
 4 files changed, 23 insertions(+), 11 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c
index 9b6cf8c..1d09f4d 100644
--- a/source4/dsdb/samdb/ldb_modules/password_hash.c
+++ b/source4/dsdb/samdb/ldb_modules/password_hash.c
@@ -1288,9 +1288,7 @@ static int setup_given_passwords(struct setup_password_fields_io *io,
 	ldb = ldb_module_get_ctx(io->ac->module);
 
 	if (g->cleartext_utf8) {
-		char **cleartext_utf16_str;
 		struct ldb_val *cleartext_utf16_blob;
-		size_t converted_pw_len;
 
 		cleartext_utf16_blob = talloc(io->ac, struct ldb_val);
 		if (!cleartext_utf16_blob) {
@@ -1300,15 +1298,14 @@ static int setup_given_passwords(struct setup_password_fields_io *io,
 					   CH_UTF8, CH_UTF16,
 					   g->cleartext_utf8->data,
 					   g->cleartext_utf8->length,
-					   (void *)&cleartext_utf16_str,
-					   &converted_pw_len, false)) {
+					   (void *)&cleartext_utf16_blob->data,
+					   &cleartext_utf16_blob->length,
+					   false)) {
 			ldb_asprintf_errstring(ldb,
 				"setup_password_fields: "
 				"failed to generate UTF16 password from cleartext UTF8 password");
 			return LDB_ERR_OPERATIONS_ERROR;
 		}
-		*cleartext_utf16_blob = data_blob_const(cleartext_utf16_str,
-							converted_pw_len);
 		g->cleartext_utf16 = cleartext_utf16_blob;
 	} else if (g->cleartext_utf16) {
 		char *cleartext_utf8_str;
@@ -1325,8 +1322,12 @@ static int setup_given_passwords(struct setup_password_fields_io *io,
 					   g->cleartext_utf16->length,
 					   (void *)&cleartext_utf8_str,
 					   &converted_pw_len, false)) {
-			/* We can't bail out entirely, as these unconvertable passwords are frustratingly valid */
+			/* We must bail out here, the input wasn't even a multiple of 2 bytes */
 			talloc_free(cleartext_utf8_blob);
+			ldb_asprintf_errstring(ldb,
+					       "setup_password_fields: "
+					       "UTF16 password for user %s had odd length (length must be a multiple of 2)", io->u.sAMAccountName);
+			return LDB_ERR_OPERATIONS_ERROR;
 		} else {
 			*cleartext_utf8_blob = data_blob_const(cleartext_utf8_str,
 							       converted_pw_len);
diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index 1ac8614..0cd8bc9 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -271,6 +271,7 @@ static int samldb_rodc_add(struct samldb_ctx *ac)
 	uint32_t krbtgt_number, i_start, i;
 	int ret;
 	char *newpass;
+	struct ldb_val newpass_utf16;
 
 	/* find a unused msDC-SecondaryKrbTgtNumber */
 	i_start = generate_random() & 0xFFFF;
@@ -320,7 +321,17 @@ found:
 		return ldb_operr(ldb);
 	}
 
-	ret = ldb_msg_add_steal_string(ac->msg, "clearTextPassword", newpass);
+	if (!convert_string_talloc(ac,
+				   CH_UNIX, CH_UTF16,
+				   newpass, strlen(newpass),
+				   (void *)&newpass_utf16.data,
+				   &newpass_utf16.length, false)) {
+		ldb_asprintf_errstring(ldb,
+				       "samldb_rodc_add: "
+				       "failed to generate UTF16 password from random password");
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
+	ret = ldb_msg_add_steal_value(ac->msg, "clearTextPassword", &newpass_utf16);
 	if (ret != LDB_SUCCESS) {
 		return ldb_operr(ldb);
 	}
diff --git a/source4/heimdal/lib/krb5/crypto.c b/source4/heimdal/lib/krb5/crypto.c
index 006028b..d5d9c1d 100644
--- a/source4/heimdal/lib/krb5/crypto.c
+++ b/source4/heimdal/lib/krb5/crypto.c
@@ -1945,7 +1945,7 @@ verify_checksum(krb5_context context,
 	krb5_set_error_message(context, ret,
 			       N_("Decrypt integrity check failed for checksum "
 				  "type %s, key type %s", ""),
-			       ct->name, crypto->et->name);
+			       ct->name, crypto ? crypto->et->name : "(unkeyed)");
     } else {
 	ret = 0;
     }
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index 42c0345..420dd14 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -830,7 +830,7 @@ def secretsdb_setup_dns(secretsdb, setup_path, names, private_dir,
             "REALM": realm,
             "DNSDOMAIN": dnsdomain,
             "DNS_KEYTAB": dns_keytab_path,
-            "DNSPASS_B64": b64encode(dnspass.encode('utf-16-le')),
+            "DNSPASS_B64": b64encode(dnspass),
             "HOSTNAME": names.hostname,
             "DNSNAME" : '%s.%s' % (names.netbiosname.lower(), names.dnsdomain.lower())
             })
@@ -1015,7 +1015,7 @@ def setup_self_join(samdb, names,
     setup_add_ldif(samdb, setup_path("provision_dns_add.ldif"), {
               "DNSDOMAIN": names.dnsdomain,
               "DOMAINDN": names.domaindn,
-              "DNSPASS_B64": b64encode(dnspass),
+              "DNSPASS_B64": b64encode(dnspass.encode('utf-16-le')),
               "HOSTNAME" : names.hostname,
               "DNSNAME" : '%s.%s' % (names.netbiosname.lower(), names.dnsdomain.lower())
               })


-- 
Samba Shared Repository


More information about the samba-cvs mailing list