s4 upgradeprovision: Synchronize the calculated keyversionnumber with the one previou...
authorMatthieu Patou <mat@matws.net>
Sun, 4 Jul 2010 21:00:13 +0000 (01:00 +0400)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 15 Jul 2010 12:08:21 +0000 (22:08 +1000)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
source4/scripting/bin/upgradeprovision

index 888f3a82565f266d13f200946b1514e39fc248b6..f073dbcad7ad2434d52b3499ce675a8fc8910b6c 100755 (executable)
@@ -56,7 +56,9 @@ from samba.upgradehelpers import (dn_sort, get_paths, newprovision,
                                  CHANGEALL, GUESS, CHANGESD, PROVISION,
                                  updateOEMInfo, getOEMInfo, update_gpo,
                                  delta_update_basesamdb, update_policyids,
-                                 update_machine_account_password)
+                                 update_machine_account_password,
+                                 search_constructed_attrs_stored,
+                                 increment_calculated_keyversion_number)
 
 replace=2**FLAG_MOD_REPLACE
 add=2**FLAG_MOD_ADD
@@ -1299,6 +1301,23 @@ def backup_provision(paths, dir):
     else:
         shutil.copytree(samldbdir, os.path.join(dir, "sam.ldb.d"))
 
+
+
+
+def sync_calculated_attributes(samdb, names):
+   """Synchronize attributes used for constructed ones, with the
+      old constructed that were stored in the database.
+
+      This apply for instance to msds-keyversionnumber that was
+      stored and that is now constructed from replpropertymetadata.
+
+      :param samdb: An LDB object attached to the currently upgraded samdb
+      :param names: Various key parameter about current provision.
+   """
+   listAttrs = ["msDs-KeyVersionAttribute"]
+   hash = search_constructed_attrs_stored(samdb, names.rootdn, listAttrs)
+   increment_calculated_keyversion_number(samdb, names.rootdn, hash)
+
 def setup_path(file):
     return os.path.join(setup_dir, file)
 
@@ -1546,6 +1565,8 @@ if __name__ == '__main__':
                 new_ldbs.groupedRollback()
                 shutil.rmtree(provisiondir)
                 sys.exit(1)
+            else:
+                sync_calculated_attributes(ldbs.sam, names)
         # 14)
         update_secrets(new_ldbs.secrets, ldbs.secrets, message)
         # 15)