summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAaron Haslett <aaronhaslett@catalyst.net.nz>2019-05-23 20:06:56 +1200
committerAndrew Bartlett <abartlet@samba.org>2019-05-29 04:41:25 +0000
commit0942a65b63cc99f36d3eba99e9c9551e10c5782e (patch)
treeaac5c417ecd90f45ce43069c609239e864dd978e /source4
parent4eee09a2c17d1276b1d0be9f26b23743eec485c2 (diff)
downloadsamba-0942a65b63cc99f36d3eba99e9c9551e10c5782e.tar.gz
downgradedatabase: adding special case for MDB
Though this script was initially written for undoing GUID indexing on TDB databases, we're repurposing it to do a full downgrade of any database. MDB databases can't be DN indexed, but they can have pack format version 2 and ORDERED_INTEGER data types, which must be removed during a downgrade. Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4')
-rwxr-xr-xsource4/scripting/bin/sambadowngradedatabase29
1 files changed, 27 insertions, 2 deletions
diff --git a/source4/scripting/bin/sambadowngradedatabase b/source4/scripting/bin/sambadowngradedatabase
index 0d182820902..9d1e2b8cc76 100755
--- a/source4/scripting/bin/sambadowngradedatabase
+++ b/source4/scripting/bin/sambadowngradedatabase
@@ -27,7 +27,6 @@ if len(args) != 0:
sys.exit(1)
lp_ctx = sambaopts.get_loadparm()
-lp_ctx.set("dsdb:guid index", "false")
if opts.H is None:
url = lp_ctx.private_path("sam.ldb")
@@ -40,7 +39,33 @@ samdb = ldb.Ldb(url=url,
partitions = samdb.search(base="@PARTITION",
scope=ldb.SCOPE_BASE,
- attrs=["partition"])
+ attrs=["backendStore", "partition"])
+
+backend = str(partitions[0].get('backendStore', 'tdb'))
+
+if backend == "mdb":
+ samdb = None
+ options = ["pack_format_override=%d" % ldb.PACKING_FORMAT]
+ # We can't remove GUID indexes from LMDB in case there are very
+ # long DNs, so we just move down the pack format, which also removes
+ # references to ORDERED_INTEGER in @ATTRIBUTES.
+
+ # Reopen the DB with pack_format_override set
+ samdb = SamDB(url=url,
+ flags=ldb.FLG_DONT_CREATE_DB,
+ lp=lp_ctx,
+ options=options)
+ samdb.transaction_start()
+ samdb.transaction_commit()
+ print("Your database has been downgraded to LDB pack format version %0x (v1)." % ldb.PACKING_FORMAT)
+
+ print("NOTE: Any use of a Samba 4.11 tool that modifies the DB will "
+ "auto-upgrade back to pack format version %0x (v2)" %
+ ldb.PACKING_FORMAT_V2)
+ exit(0);
+
+# This is needed to force the @ATTRIBUTES and @INDEXLIST to be correct
+lp_ctx.set("dsdb:guid index", "false")
modmsg = ldb.Message()
modmsg.dn = ldb.Dn(samdb, '@INDEXLIST')