The branch, master has been updated
       via  f66ef5c upgradeprovision: do not hold references to messageElements
       via  f05edc0 pyldb: raise an exception if we can't add the attribute
       via  3213d1e upgradeprovision: treat provision without oem attribute as 
quite recent, it's provision that comes from Windows replication
      from  90f06d6 s4-provision: Fix the problem of DnsProperty values not 
being set correctly

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


- Log -----------------------------------------------------------------
commit f66ef5cfbc932dc03a5bea61e9cb10dd8d948128
Author: Matthieu Patou <[email protected]>
Date:   Mon Jan 2 19:27:48 2012 -0800

    upgradeprovision: do not hold references to messageElements
    
    Autobuild-User: Matthieu Patou <[email protected]>
    Autobuild-Date: Tue Jan  3 08:20:02 CET 2012 on sn-devel-104

commit f05edc0ecb9da2cb00a83b38d0be5812cc4ccf77
Author: Matthieu Patou <[email protected]>
Date:   Mon Jan 2 19:25:56 2012 -0800

    pyldb: raise an exception if we can't add the attribute

commit 3213d1e0b770690b1a964f38fb57ebbcd8ce0746
Author: Matthieu Patou <[email protected]>
Date:   Thu Aug 25 18:05:28 2011 +0200

    upgradeprovision: treat provision without oem attribute as quite recent, 
it's provision that comes from Windows replication

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

Summary of changes:
 lib/ldb/pyldb.c                        |    7 ++++++-
 source4/scripting/bin/upgradeprovision |   29 ++++++++++++++++++-----------
 2 files changed, 24 insertions(+), 12 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c
index b2315e6..b253bcd 100644
--- a/lib/ldb/pyldb.c
+++ b/lib/ldb/pyldb.c
@@ -2668,12 +2668,17 @@ static int py_ldb_msg_setitem(PyLdbMessageObject *self, 
PyObject *name, PyObject
                /* delitem */
                ldb_msg_remove_attr(self->msg, attr_name);
        } else {
+               int ret;
                struct ldb_message_element *el = 
PyObject_AsMessageElement(self->msg,
                                                                           
value, 0, attr_name);
                if (el == NULL)
                        return -1;
                ldb_msg_remove_attr(pyldb_Message_AsMessage(self), attr_name);
-               ldb_msg_add(pyldb_Message_AsMessage(self), el, el->flags);
+               ret = ldb_msg_add(pyldb_Message_AsMessage(self), el, el->flags);
+               if (ret != LDB_SUCCESS) {
+                       PyErr_SetLdbError(PyExc_LdbError, ret, NULL);
+                       return -1;
+               }
        }
        return 0;
 }
diff --git a/source4/scripting/bin/upgradeprovision 
b/source4/scripting/bin/upgradeprovision
index f403120..738d6be 100755
--- a/source4/scripting/bin/upgradeprovision
+++ b/source4/scripting/bin/upgradeprovision
@@ -341,11 +341,11 @@ def handle_special_case(att, delta, new, old, 
useReplMetadata, basedn, aldb):
     :return: True to indicate that the attribute should be kept, False for
              discarding it"""
 
-    flag = delta.get(att).flags()
     # We do most of the special case handle if we do not have the
     # highest usn as otherwise the replPropertyMetaData will guide us more
     # correctly
     if not useReplMetadata:
+        flag = delta.get(att).flags()
         if (att == "sPNMappings" and flag == FLAG_MOD_REPLACE and
             ldb.Dn(aldb, "CN=Directory Service,CN=Windows NT,"
                         "CN=Services,CN=Configuration,%s" % basedn)
@@ -418,7 +418,7 @@ def handle_special_case(att, delta, new, old, 
useReplMetadata, basedn, aldb):
     # This is a bit of special animal as we might have added
     # already SPN entries to the list that has to be modified
     # So we go in detail to try to find out what has to be added ...
-    if (att == "servicePrincipalName" and flag == FLAG_MOD_REPLACE):
+    if (att == "servicePrincipalName" and delta.get(att).flags() == 
FLAG_MOD_REPLACE):
         hash = {}
         newval = []
         changeDelta = 0
@@ -763,8 +763,7 @@ def handle_links(samdb, att, basedn, dn, value, ref_value, 
delta):
     :param delta: The MessageElement object that will be applied for
                    transforming the current provision"""
 
-    res = samdb.search(expression="dn=%s" % dn, base=basedn,
-                        controls=["search_options:1:2", "reveal:1"],
+    res = samdb.search(base=dn, controls=["search_options:1:2", "reveal:1"],
                         attrs=[att])
 
     blacklist = {}
@@ -772,7 +771,8 @@ def handle_links(samdb, att, basedn, dn, value, ref_value, 
delta):
     newlinklist = []
     changed = False
 
-    newlinklist.extend(value)
+    for v in value:
+        newlinklist.append(str(v))
 
     for e in value:
         hash[e] = 1
@@ -797,6 +797,8 @@ def handle_links(samdb, att, basedn, dn, value, ref_value, 
delta):
     else:
         delta.remove(att)
 
+    return delta
+
 
 msg_elt_flag_strs = {
     ldb.FLAG_MOD_ADD: "MOD_ADD",
@@ -895,11 +897,12 @@ def checkKeepAttributeWithMetadata(delta, att, message, 
reference, current,
         if att in forwardlinked:
             curval = current[0].get(att, ())
             refval = reference[0].get(att, ())
-            handle_links(samdb, att, basedn, current[0]["dn"],
+            delta = handle_links(samdb, att, basedn, current[0]["dn"],
                             curval, refval, delta)
             continue
 
-        if isFirst and len(delta.items())>1:
+
+        if isFirst and len(list(delta)) > 1:
             isFirst = False
             txt = "%s\n" % (str(dn))
 
@@ -1048,10 +1051,12 @@ def update_present(ref_samdb, samdb, basedn, 
listPresent, usns):
 
         delta.remove("name")
 
-        if len(delta.items()) == 1:
+        nb_items = len(list(delta))
+
+        if nb_items == 1:
             continue
 
-        if len(delta.items()) > 1 and usns is not None:
+        if nb_items > 1 and usns is not None:
             # Fetch the replPropertyMetaData
             res = samdb.search(expression="dn=%s" % (str(dn)), base=basedn,
                                 scope=SCOPE_SUBTREE, controls=controls,
@@ -1077,7 +1082,9 @@ def update_present(ref_samdb, samdb, basedn, listPresent, 
usns):
             delta =  checkKeepAttributeOldMtd(delta, att, reference, current, 
basedn, samdb)
 
         delta.dn = dn
-        if len(delta.items()) >1:
+
+
+        if len(delta) >1:
             # Skip dn as the value is not really changed ...
             attributes=", ".join(delta.keys()[1:])
             modcontrols = []
@@ -1805,7 +1812,7 @@ if __name__ == '__main__':
             deltaattr = None
         # 11)
             message(GUESS, oem)
-            if hasATProvision(ldbs.sam) or re.match(".*alpha((9)|(\d\d+)).*", 
str(oem)):
+            if oem is None or hasATProvision(ldbs.sam) or 
re.match(".*alpha((9)|(\d\d+)).*", str(oem)):
                 # 11) A
                 # Starting from alpha9 we can consider that the structure is 
quite ok
                 # and that we should do only dela


-- 
Samba Shared Repository

Reply via email to