summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarming Sam <garming@catalyst.net.nz>2016-11-01 16:29:53 +1300
committerKarolin Seeger <kseeger@samba.org>2016-11-30 12:19:34 +0100
commitee07db353f619effa4cb3e789831ae8947aea028 (patch)
tree0874d919fd72973a8931f6d44b636b2ffe8dd855
parent9f9e67ecdeeeb33d233938b32658d7fdde29fd48 (diff)
downloadsamba-ee07db353f619effa4cb3e789831ae8947aea028.tar.gz
samba_tool/fsmo: Allocate RID Set when seizing RID manager
Seizing the role without allocating a RID set for itself is likely prone to cause issues. Pair-programmed-with: Clive Ferreira <cliveferreira@catalyst.net.nz> Signed-off-by: Clive Ferreira <cliveferreira@catalyst.net.nz> Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> BUG: https://bugzilla.samba.org/show_bug.cgi?id=9954 Autobuild-User(master): Garming Sam <garming@samba.org> Autobuild-Date(master): Fri Nov 4 08:37:05 CET 2016 on sn-devel-144 (cherry picked from commit 815658d2db46e4accdd35f5925585ec1f1c3d74f)
-rw-r--r--python/samba/netcmd/fsmo.py29
-rw-r--r--selftest/knownfail1
2 files changed, 27 insertions, 3 deletions
diff --git a/python/samba/netcmd/fsmo.py b/python/samba/netcmd/fsmo.py
index 13516549392..62b3e438e18 100644
--- a/python/samba/netcmd/fsmo.py
+++ b/python/samba/netcmd/fsmo.py
@@ -295,12 +295,37 @@ You must provide an Admin user and password."""),
m["fSMORoleOwner"]= ldb.MessageElement(
serviceName, ldb.FLAG_MOD_REPLACE,
"fSMORoleOwner")
+
+ samdb.transaction_start()
try:
samdb.modify(m)
+ if role == "rid":
+ # We may need to allocate the initial RID Set
+ samdb.create_own_rid_set()
+
except LdbError, (num, msg):
- raise CommandError("Failed to seize '%s' role: %s" %
- (role, msg))
+ if role == "rid" and num == ldb.ERR_ENTRY_ALREADY_EXISTS:
+
+ # Try again without the RID Set allocation
+ # (normal). We have to manage the transaction as
+ # we do not have nested transactions and creating
+ # a RID set touches multiple objects. :-(
+ samdb.transaction_cancel()
+ samdb.transaction_start()
+ try:
+ samdb.modify(m)
+ except LdbError, (num, msg):
+ samdb.transaction_cancel()
+ raise CommandError("Failed to seize '%s' role: %s" %
+ (role, msg))
+
+ else:
+ samdb.transaction_cancel()
+ raise CommandError("Failed to seize '%s' role: %s" %
+ (role, msg))
+ samdb.transaction_commit()
self.outf.write("FSMO seize of '%s' role successful\n" % role)
+
return True
def seize_dns_role(self, role, samdb, credopts, sambaopts,
diff --git a/selftest/knownfail b/selftest/knownfail
index cb309a65c66..7c42777247b 100644
--- a/selftest/knownfail
+++ b/selftest/knownfail
@@ -293,7 +293,6 @@
^samba4.smb2.ioctl.copy_chunk_bad_access
^samba4.drs.getnc_exop.python.*getnc_exop.DrsReplicaPrefixMapTestCase.test_regular_prefix_map_ex_attid.*
^samba4.drs.ridalloc_exop.python.*ridalloc_exop.DrsReplicaSyncTestCase.test_offline_ridalloc
-^samba4.drs.ridalloc_exop.python.*ridalloc_exop.DrsReplicaSyncTestCase.test_offline_samba_tool_seized_ridalloc
^samba4.drs.ridalloc_exop.python.*ridalloc_exop.DrsReplicaSyncTestCase.test_join_time_ridalloc
^samba4.drs.ridalloc_exop.python.*ridalloc_exop.DrsReplicaSyncTestCase.test_rid_set_dbcheck_after_seize
^samba4.drs.ridalloc_exop.python.*ridalloc_exop.DrsReplicaSyncTestCase.test_rid_set_dbcheck