[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha8-1263-g77e2403

Andrew Bartlett abartlet at samba.org
Fri Aug 28 06:42:15 MDT 2009


The branch, master has been updated
       via  77e2403f1314a28722f0fb21f6682320b2e9935d (commit)
       via  72fb26e9a4047174c32ffb18ddfd6c6dc046e82b (commit)
      from  e3c7e9e81edf05f6946cac6f07a8bd8d6729adcb (commit)

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


- Log -----------------------------------------------------------------
commit 77e2403f1314a28722f0fb21f6682320b2e9935d
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Aug 28 19:26:53 2009 +1000

    s4:ldb Don't sleep(100) in this error case, but debug the LDIF

commit 72fb26e9a4047174c32ffb18ddfd6c6dc046e82b
Author: Matthieu Patou <mat at matws.net>
Date:   Wed Aug 26 20:30:15 2009 +0400

    s4: Create helpers functions related to provision
    
    One for getting attributes with DN syntax, one for getting forward
    linked attributes and one for getting the list of partition

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

Summary of changes:
 source4/lib/ldb/ldb_tdb/ldb_index.c         |   12 +++---
 source4/scripting/python/samba/provision.py |   51 ++++++++++++++++++---------
 2 files changed, 40 insertions(+), 23 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c
index 1daa450..7db22de 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_index.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_index.c
@@ -1407,14 +1407,14 @@ int ltdb_index_del_value(struct ldb_module *module, const char *dn,
 	i = ldb_msg_find_idx(msg, dn, &j, LTDB_IDX);
 	if (i == -1) {
 		struct ldb_ldif ldif;
-
-		ldb_debug(ldb, LDB_DEBUG_ERROR,
-				"ERROR: dn %s not found in %s", dn,
-				ldb_dn_get_linearized(dn_key));
+		char *ldif_string;
 		ldif.changetype = LDB_CHANGETYPE_NONE;
 		ldif.msg = msg;
-		ldb_ldif_write_file(ldb, stdout, &ldif);
-		sleep(100);
+		ldif_string = ldb_ldif_write_string(ldb, NULL, &ldif);
+		ldb_debug(ldb, LDB_DEBUG_ERROR,
+			  "ERROR: dn %s not found in %s", dn,
+			  ldif_string);
+		talloc_free(ldif_string);
 		/* it ain't there. hmmm */
 		talloc_free(dn_key);
 		return LDB_SUCCESS;
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index 0a3a44f..bb95f38 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -167,6 +167,32 @@ class Schema(object):
         prefixmap_ldif = "dn: cn=schema\nprefixMap:: %s\n\n" % prefixmap
         self.ldb.set_schema_from_ldif(prefixmap_ldif, self.schema_data)
 
+
+# Return a hash with the forward attribute as a key and the back as the value 
+def get_linked_attributes(schemadn,schemaldb):
+    attrs = ["linkID", "lDAPDisplayName"]
+    res = schemaldb.search(expression="(&(linkID=*)(!(linkID:1.2.840.113556.1.4.803:=1))(objectclass=attributeSchema)(attributeSyntax=2.5.5.1))", base=schemadn, scope=SCOPE_ONELEVEL, attrs=attrs)
+    attributes = {}
+    for i in range (0, len(res)):
+        expression = "(&(objectclass=attributeSchema)(linkID=%d)(attributeSyntax=2.5.5.1))" % (int(res[i]["linkID"][0])+1)
+        target = schemaldb.searchone(basedn=schemadn, 
+                                     expression=expression, 
+                                     attribute="lDAPDisplayName", 
+                                     scope=SCOPE_SUBTREE)
+        if target is not None:
+            attributes[str(res[i]["lDAPDisplayName"])]=str(target)
+            
+    return attributes
+
+def get_dnsyntax_attributes(schemadn,schemaldb):
+    attrs = ["linkID", "lDAPDisplayName"]
+    res = schemaldb.search(expression="(&(!(linkID=*))(objectclass=attributeSchema)(attributeSyntax=2.5.5.1))", base=schemadn, scope=SCOPE_ONELEVEL, attrs=attrs)
+    attributes = []
+    for i in range (0, len(res)):
+        attributes.append(str(res[i]["lDAPDisplayName"]))
+        
+    return attributes
+    
     
 def check_install(lp, session_info, credentials):
     """Check whether the current install seems ok.
@@ -1431,28 +1457,21 @@ def provision_openldap_backend(result, paths=None, setup_path=None, names=None,
     if nosync:
         nosync_config = "dbnosync"
         
-        
-    attrs = ["linkID", "lDAPDisplayName"]
-    res = schema.ldb.search(expression="(&(linkID=*)(!(linkID:1.2.840.113556.1.4.803:=1))(objectclass=attributeSchema)(attributeSyntax=2.5.5.1))", base=names.schemadn, scope=SCOPE_ONELEVEL, attrs=attrs)
-
-    memberof_config = "# Generated from Samba4 schema\n"
+    lnkattr = get_linked_attributes(names.schemadn,schema.ldb)
     refint_attributes = ""
-    for i in range (0, len(res)):
-        expression = "(&(objectclass=attributeSchema)(linkID=%d)(attributeSyntax=2.5.5.1))" % (int(res[i]["linkID"][0])+1)
-        target = schema.ldb.searchone(basedn=names.schemadn, 
-                                      expression=expression, 
-                                      attribute="lDAPDisplayName", 
-                                      scope=SCOPE_SUBTREE)
-        if target is not None:
-            refint_attributes = refint_attributes + " " + res[i]["lDAPDisplayName"][0]
+    memberof_config = "# Generated from Samba4 schema\n"
+    for att in  lnkattr.keys():
+        if lnkattr[att] is not None:
+            refint_attributes = refint_attributes + " " + att 
             
             memberof_config += read_and_sub_file(setup_path("memberof.conf"),
-                                                 { "MEMBER_ATTR" : str(res[i]["lDAPDisplayName"][0]),
-                                                   "MEMBEROF_ATTR" : str(target) })
+                                                 { "MEMBER_ATTR" : att ,
+                                                   "MEMBEROF_ATTR" : lnkattr[att] })
             
     refint_config = read_and_sub_file(setup_path("refint.conf"),
                                       { "LINK_ATTRS" : refint_attributes})
     
+    attrs = ["linkID", "lDAPDisplayName"]
     res = schema.ldb.search(expression="(&(objectclass=attributeSchema)(searchFlags:1.2.840.113556.1.4.803:=1))", base=names.schemadn, scope=SCOPE_ONELEVEL, attrs=attrs)
     index_config = ""
     for i in range (0, len(res)):
@@ -1838,5 +1857,3 @@ def create_krb5_conf(path, setup_path, dnsdomain, hostname, realm):
 
 
 
- 
-


-- 
Samba Shared Repository


More information about the samba-cvs mailing list