[SCM] Samba Shared Repository - branch master updated

Matthias Dieter Wallnöfer mdw at samba.org
Fri Jun 11 02:21:20 MDT 2010


The branch, master has been updated
       via  b61fa4b... s4:rootdse LDB module - use LDB result constants
       via  93fe926... s4:passwords.py - set the "dSHeuristics"
       via  61976e4... s4:passwords.py - use "self" before "enable_account" to make really sure which LDB connection should be used
       via  315602f... s4:ldap.py - check how the directory server behaves when the 'distinguishedName' attribute wasn't set correctly
       via  ace9bd6... s4:ldap.py - check if the "name" of an entry was really ignored
       via  4d33627... ldb:ldb_sqlite3 backend - remove a warning which has already been resolved
       via  155a672... ldb:ldb_sqlite3 backend - remove checks which are now done elsewhere
      from  4690ebf... Add missing stub functions.

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


- Log -----------------------------------------------------------------
commit b61fa4b67686aa5df69c28ca86d8d26aaa3ba9d4
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Fri Jun 11 10:19:19 2010 +0200

    s4:rootdse LDB module - use LDB result constants

commit 93fe926842227bb7605503f69e471df765ab87e9
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Fri Jun 11 10:04:50 2010 +0200

    s4:passwords.py - set the "dSHeuristics"
    
    As per Nadia's request and abartlet's suggestion the test now also sets the
    "dSHeuristics" attribute properly to be able to perform the tests also against
    Windows without further configuration.
    
    The code has the neat feature that it undoes the change and resets the
    behaviour as it was before.

commit 61976e4fcf49b340a50487d177dea38321ab0e06
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Fri Jun 11 10:04:19 2010 +0200

    s4:passwords.py - use "self" before "enable_account" to make really sure which LDB connection should be used

commit 315602f8455fd8fa86254585a27cca91f1542201
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Fri Jun 11 09:19:02 2010 +0200

    s4:ldap.py - check how the directory server behaves when the 'distinguishedName' attribute wasn't set correctly
    
    (On add operations the server does completely ignore it and uses the "header"
    DN)

commit ace9bd6560fcbd918ea38e6541137bbfe99da73c
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Fri Jun 11 09:17:08 2010 +0200

    s4:ldap.py - check if the "name" of an entry was really ignored

commit 4d3362776f72407e8609144d2801ba067485a261
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Fri Jun 11 08:52:12 2010 +0200

    ldb:ldb_sqlite3 backend - remove a warning which has already been resolved

commit 155a672567ac95e0a631a82f9273ddec71bcf643
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Fri Jun 11 08:50:36 2010 +0200

    ldb:ldb_sqlite3 backend - remove checks which are now done elsewhere
    
    (In SAMBA LDB modules)

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

Summary of changes:
 source4/dsdb/samdb/ldb_modules/rootdse.c  |    9 ++++---
 source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c |   30 ------------------------
 source4/lib/ldb/tests/python/ldap.py      |   23 +++++++++++++++---
 source4/lib/ldb/tests/python/passwords.py |   35 ++++++++++++++++++++++++++++-
 4 files changed, 58 insertions(+), 39 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c
index 5fffef7..bf56420 100644
--- a/source4/dsdb/samdb/ldb_modules/rootdse.c
+++ b/source4/dsdb/samdb/ldb_modules/rootdse.c
@@ -83,7 +83,7 @@ static int expand_dn_in_message(struct ldb_module *module, struct ldb_message *m
 	v = discard_const_p(struct ldb_val, ldb_msg_find_ldb_val(msg, attrname));
 	if (v == NULL) {
 		talloc_free(tmp_ctx);
-		return 0;
+		return LDB_SUCCESS;
 	}
 
 	dn_string = talloc_strndup(tmp_ctx, (const char *)v->data, v->length);
@@ -152,7 +152,7 @@ static int expand_dn_in_message(struct ldb_module *module, struct ldb_message *m
 
 	talloc_free(tmp_ctx);
 
-	return 0;
+	return LDB_SUCCESS;
 }	
 			
 
@@ -597,7 +597,8 @@ static int rootdse_init(struct ldb_module *module)
 
 	data = talloc_zero(module, struct private_data);
 	if (data == NULL) {
-		return -1;
+		ldb_oom(ldb);
+		return LDB_ERR_OPERATIONS_ERROR;
 	}
 
 	data->num_controls = 0;
@@ -610,7 +611,7 @@ static int rootdse_init(struct ldb_module *module)
 
 	ret = ldb_next_init(module);
 
-	if (ret) {
+	if (ret != LDB_SUCCESS) {
 		return ret;
 	}
 
diff --git a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
index 7dcb1f9..12af9c5 100644
--- a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
+++ b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
@@ -1059,13 +1059,6 @@ static int lsql_add(struct lsql_context *ctx)
 					       el->name, ldb_dn_get_linearized(msg->dn));
 			return LDB_ERR_CONSTRAINT_VIOLATION;
 		}
-		if (a && a->flags & LDB_ATTR_FLAG_SINGLE_VALUE) {
-			if (el->num_values > 1) {
-				ldb_asprintf_errstring(ldb, "SINGLE-VALUED attribute %s on %s specified more than once",
-						       el->name, ldb_dn_get_linearized(msg->dn));
-				return LDB_ERR_CONSTRAINT_VIOLATION;
-			}
-		}
 
 		/* For each value of the specified attribute name... */
 		for (j = 0; j < el->num_values; j++) {
@@ -1139,12 +1132,6 @@ static int lsql_modify(struct lsql_context *ctx)
 		char *mod;
 		unsigned int j;
 
-		if (ldb_attr_cmp(el->name, "distinguishedName") == 0) {
-			ldb_asprintf_errstring(ldb, "it is not permitted to perform a modify on 'distinguishedName' (use rename instead): %s",
-					       ldb_dn_get_linearized(msg->dn));
-			return LDB_ERR_CONSTRAINT_VIOLATION;
-		}
-
 		/* Get a case-folded copy of the attribute name */
 		attr = ldb_attr_casefold(ctx, el->name);
 		if (attr == NULL) {
@@ -1157,14 +1144,6 @@ static int lsql_modify(struct lsql_context *ctx)
 
 		case LDB_FLAG_MOD_REPLACE:
 
-			if (a && a->flags & LDB_ATTR_FLAG_SINGLE_VALUE) {
-				if (el->num_values > 1) {
-					ldb_asprintf_errstring(ldb, "SINGLE-VALUE attribute %s on %s specified more than once",
-						               el->name, ldb_dn_get_linearized(msg->dn));
-					return LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
-				}
-			}
-
 			for (j=0; j<el->num_values; j++) {
 				if (ldb_msg_find_val(el, &el->values[j]) != &el->values[j]) {
 					ldb_asprintf_errstring(ldb, "%s: value #%d provided more than once", el->name, j);
@@ -1201,15 +1180,6 @@ static int lsql_modify(struct lsql_context *ctx)
 				return LDB_ERR_CONSTRAINT_VIOLATION;
 			}
 
-			if (a && a->flags & LDB_ATTR_FLAG_SINGLE_VALUE) {
-				if (el->num_values > 1) {
-					ldb_asprintf_errstring(ldb, "SINGLE-VALUE attribute %s on %s specified more than once",
-						               el->name, ldb_dn_get_linearized(msg->dn));
-					return LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
-				}
-			}
-
-#warning "We should throw an error if no value is provided!"
 			/* For each value of the specified attribute name... */
 			for (j = 0; j < el->num_values; j++) {
 				struct ldb_val value;
diff --git a/source4/lib/ldb/tests/python/ldap.py b/source4/lib/ldb/tests/python/ldap.py
index db69b47..ddf0254 100755
--- a/source4/lib/ldb/tests/python/ldap.py
+++ b/source4/lib/ldb/tests/python/ldap.py
@@ -691,9 +691,19 @@ class BasicTests(unittest.TestCase):
         """Tests the 'distinguishedName' attribute"""
         print "Tests the 'distinguishedName' attribute"""
 
+        # a wrong "distinguishedName" attribute is obviously tolerated
         self.ldb.add({
-             "dn": "cn=ldaptestgroup,cn=users," + self.base_dn,
-             "objectclass": "group"})
+              "dn": "cn=ldaptestgroup,cn=users," + self.base_dn,
+              "objectclass": "group",
+              "distinguishedName": "cn=ldaptest,cn=users," + self.base_dn})
+
+        # proof if the DN has been set correctly
+        res = ldb.search("cn=ldaptestgroup,cn=users," + self.base_dn,
+                         scope=SCOPE_BASE, attrs=["distinguishedName"])
+        self.assertTrue(len(res) == 1)
+        self.assertTrue("distinguishedName" in res[0])
+        self.assertTrue(Dn(ldb, res[0]["distinguishedName"][0])
+           == Dn(ldb, "cn=ldaptestgroup, cn=users," + self.base_dn))
 
         m = Message()
         m.dn = Dn(ldb, "cn=ldaptestgroup,cn=users," + self.base_dn)
@@ -753,11 +763,17 @@ class BasicTests(unittest.TestCase):
              "objectclass": "group",
              "name": "ldaptestgroupx"})
 
+        # proof if the name has been set correctly
+        res = ldb.search("cn=ldaptestgroup,cn=users," + self.base_dn,
+                         scope=SCOPE_BASE, attrs=["name"])
+        self.assertTrue(len(res) == 1)
+        self.assertTrue("name" in res[0])
+        self.assertTrue(res[0]["name"][0] == "ldaptestgroup")
+
         m = Message()
         m.dn = Dn(ldb, "cn=ldaptestgroup,cn=users," + self.base_dn)
         m["name"] = MessageElement("cn=ldaptestuser", FLAG_MOD_REPLACE,
           "name")
-
         try:
             ldb.modify(m)
             self.fail()
@@ -768,7 +784,6 @@ class BasicTests(unittest.TestCase):
         m.dn = Dn(ldb, "cn=ldaptestgroup,cn=users," + self.base_dn)
         m["cn"] = MessageElement("ldaptestuser",
           FLAG_MOD_REPLACE, "cn")
-
         try:
             ldb.modify(m)
             self.fail()
diff --git a/source4/lib/ldb/tests/python/passwords.py b/source4/lib/ldb/tests/python/passwords.py
index eb88fc4..c26bbf0 100755
--- a/source4/lib/ldb/tests/python/passwords.py
+++ b/source4/lib/ldb/tests/python/passwords.py
@@ -87,7 +87,7 @@ class PasswordTests(unittest.TestCase):
              "objectclass": ["user", "person"],
              "sAMAccountName": "testuser",
              "userPassword": "thatsAcomplPASS1" })
-        ldb.enable_account("(sAMAccountName=testuser)")
+        self.ldb.enable_account("(sAMAccountName=testuser)")
 
         # Open a second LDB connection with the user credentials. Use the
         # command line credentials for informations like the domain, the realm
@@ -572,8 +572,41 @@ if not "://" in host:
 
 ldb = SamDB(url=host, session_info=system_session(), credentials=creds, lp=lp)
 
+# Gets back the configuration basedn
+res = ldb.search(base="", expression="", scope=SCOPE_BASE,
+                 attrs=["configurationNamingContext"])
+configuration_dn = res[0]["configurationNamingContext"][0]
+
+# Get the old "dSHeuristics" if it was set
+res = ldb.search("CN=Directory Service, CN=Windows NT, CN=Services, "
+                 + configuration_dn, scope=SCOPE_BASE, attrs=["dSHeuristics"])
+if "dSHeuristics" in res[0]:
+  dsheuristics = res[0]["dSHeuristics"][0]
+else:
+  dsheuristics = None
+
+# Set the "dSHeuristics" to have the tests run against Windows Server
+m = Message()
+m.dn = Dn(ldb, "CN=Directory Service, CN=Windows NT, CN=Services, "
+  + configuration_dn)
+m["dSHeuristics"] = MessageElement("000000001", FLAG_MOD_REPLACE,
+  "dSHeuristics")
+ldb.modify(m)
+
 runner = SubunitTestRunner()
 rc = 0
 if not runner.run(unittest.makeSuite(PasswordTests)).wasSuccessful():
     rc = 1
+
+# Reset the "dSHeuristics" as they were before
+m = Message()
+m.dn = Dn(ldb, "CN=Directory Service, CN=Windows NT, CN=Services, "
+  + configuration_dn)
+if dsheuristics is not None:
+    m["dSHeuristics"] = MessageElement(dsheuristics, FLAG_MOD_REPLACE,
+      "dSHeuristics")
+else:
+    m["dSHeuristics"] = MessageElement([], FLAG_MOD_DELETE, "dsHeuristics")
+ldb.modify(m)
+
 sys.exit(rc)


-- 
Samba Shared Repository


More information about the samba-cvs mailing list