s4-upgradeprovision: Detect recent provision in a more reliable way
[mat/samba.git] / source4 / scripting / bin / upgradeprovision
index 54f3cf1507efedd156678869549ef7961a2520c8..af9796471389693e6b5dc5a97dba95bd2fa33843 100755 (executable)
@@ -1346,6 +1346,16 @@ def rebuild_sd(samdb, names):
             message(ERROR, "On %s bad stuff %s" % (str(delta.dn),badsd.as_sddl(names.domainsid)))
             return
 
+def hasATProvision(samdb):
+        entry = samdb.search(expression="dn=@PROVISION", base = "",
+                                scope=SCOPE_SUBTREE,
+                                attrs=["dn"])
+
+        if entry != None and len(entry) == 1:
+            return True
+        else:
+            return False
+
 def removeProvisionUSN(samdb):
         attrs = [samba.provision.LAST_PROVISION_USN_ATTRIBUTE, "dn"]
         entry = samdb.search(expression="dn=@PROVISION", base = "",
@@ -1793,7 +1803,8 @@ if __name__ == '__main__':
             new_ldbs.groupedCommit()
             deltaattr = None
         # 11)
-            if re.match(".*alpha((9)|(\d\d+)).*", str(oem)):
+            message(GUESS, oem)
+            if 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