summaryrefslogtreecommitdiff
path: root/python/samba
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2023-06-21 12:07:08 +0200
committerAndrew Bartlett <abartlet@samba.org>2023-06-21 19:08:37 +0000
commit205ee77c2fe812b71138bbf72ce5b17f238696f1 (patch)
treed4f66e296cc4d70d3efd6a3a386786023dbd29b9 /python/samba
parent3724ae3e1089136e7d3d3f111ab3420be71a7730 (diff)
downloadsamba-205ee77c2fe812b71138bbf72ce5b17f238696f1.tar.gz
samba-205ee77c2fe812b71138bbf72ce5b17f238696f1.tar.bz2
samba-205ee77c2fe812b71138bbf72ce5b17f238696f1.zip
samba-tool: let 'domain level raise' call check_and_update_fl() in a transaction
This makes it possible to raise the levels without starting 'samba' first, which is very useful for blackbox tests. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python/samba')
-rw-r--r--python/samba/netcmd/domain/level.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/python/samba/netcmd/domain/level.py b/python/samba/netcmd/domain/level.py
index e3c8f35169a..c4361eed342 100644
--- a/python/samba/netcmd/domain/level.py
+++ b/python/samba/netcmd/domain/level.py
@@ -25,7 +25,7 @@
import ldb
import samba.getopt as options
from samba.auth import system_session
-from samba.dsdb import DS_DOMAIN_FUNCTION_2000
+from samba.dsdb import check_and_update_fl, DS_DOMAIN_FUNCTION_2000
from samba.netcmd import Command, CommandError, Option
from samba.samdb import SamDB
@@ -68,6 +68,16 @@ class cmd_domain_level(Command):
domain_dn = samdb.domain_dn()
+ in_transaction = False
+ if subcommand == "raise" and not H.startswith("ldap"):
+ samdb.transaction_start()
+ in_transaction = True
+ try:
+ check_and_update_fl(samdb, lp)
+ except Exception as e:
+ samdb.transaction_cancel()
+ raise e
+
try:
res_forest = samdb.search("CN=Partitions,%s" % samdb.get_config_basedn(),
scope=ldb.SCOPE_BASE, attrs=["msDS-Behavior-Version"])
@@ -117,6 +127,8 @@ class cmd_domain_level(Command):
if level_domain > min_level_dc:
raise CommandError("Domain function level is higher than the lowest function level of a DC. Correct this or reprovision!")
except Exception as e:
+ if in_transaction:
+ samdb.transaction_cancel()
raise e
def do_show():
@@ -222,10 +234,18 @@ class cmd_domain_level(Command):
return
if subcommand == "show":
+ assert not in_transaction
do_show()
return
elif subcommand == "raise":
- do_raise()
+ try:
+ do_raise()
+ except Exception as e:
+ if in_transaction:
+ samdb.transaction_cancel()
+ raise e
+ if in_transaction:
+ samdb.transaction_commit()
return
raise AssertionError("Internal Error subcommand[%s] not handled" % subcommand)