samba-tool: fsmo.py throws an uncaught exception if no
authorRowland Penny <repenny241155@gmail.com>
Mon, 23 Nov 2015 18:40:19 +0000 (18:40 +0000)
committerUri Simchoni <uri@samba.org>
Sat, 5 Dec 2015 23:33:10 +0000 (00:33 +0100)
fSMORoleOwner attribute

This will fix bug 11613 where a user got the uncaught exception when trying
to seize an FSMO role that didn't have the required attribute.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11613

Signed-off-by: Rowland Penny <repenny241155@gmail.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
Autobuild-User(master): Uri Simchoni <uri@samba.org>
Autobuild-Date(master): Sun Dec  6 00:33:10 CET 2015 on sn-devel-104

python/samba/netcmd/fsmo.py

index 0b4488f7853f4c464725286f2e118f791630f4b7..3904bcb08d6f473db581d76d8b28c437f3cba7ec 100644 (file)
@@ -38,7 +38,8 @@ def get_fsmo_roleowner(samdb, roledn):
     """
     res = samdb.search(roledn,
                        scope=ldb.SCOPE_BASE, attrs=["fSMORoleOwner"])
-    assert len(res) == 1
+    if len(res) == 0:
+        raise CommandError('"%s" does not have a FSMO roleowner' % roledn)
     master_owner = res[0]["fSMORoleOwner"][0]
     return master_owner