mirror of
https://github.com/samba-team/samba.git
synced 2025-02-03 13:47:25 +03:00
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>
This commit is contained in:
parent
4eee09a2c1
commit
0942a65b63
@ -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')
|
||||
|
Loading…
x
Reference in New Issue
Block a user