[Patch] fix for bug 11613, samba-tool fsmo throws an error

Uri Simchoni uri at samba.org
Sat Dec 5 19:51:31 UTC 2015


Pushed to autobuild.

However, I do see other uses of "assert(len(something) == 1)" in 
python/samba/netcmd and I have to wonder whether they have to be fixed too.

Thanks,
Uri.

On 12/04/2015 07:54 PM, Jeremy Allison wrote:
> On Mon, Nov 23, 2015 at 06:56:10PM +0000, Rowland Penny wrote:
>> Hi, the attached patch fixes bug 11613. A user on the samba mailing
>> list got an uncaught exception when trying to seize an FSMO role
>> which did not have a 'fSMORoleOwner' attribute. This patch will
>> print an error message if no attribute found and then exit.
>>
>> Rowland
> LGTM (with additional BUG: https://bugzilla.samba.org/show_bug.cgi?id=11613
> line in the commit message).
>
> Can I get a second Team reviewer ?
>
>>  From 77b383be3d4dfb983ebb8ca13436788ca20c8e9a Mon Sep 17 00:00:00 2001
>> From: Rowland Penny <repenny241155 at gmail.com>
>> Date: Mon, 23 Nov 2015 18:40:19 +0000
>> Subject: [PATCH 3/3] samba-tool: fsmo.py throws an uncaught exception if no
>> 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.
>>
>> Signed-off-by: Rowland Penny <repenny241155 at gmail.com>
>> ---
>>   python/samba/netcmd/fsmo.py |    3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/python/samba/netcmd/fsmo.py b/python/samba/netcmd/fsmo.py
>> index 0b4488f..a5c2818 100644
>> --- a/python/samba/netcmd/fsmo.py
>> +++ b/python/samba/netcmd/fsmo.py
>> @@ -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 Exception('"%s" does not have a FSMO roleowner' % roledn)
>>       master_owner = res[0]["fSMORoleOwner"][0]
>>       return master_owner
>>   
>> -- 
>> 1.7.10.4
>>
>




More information about the samba-technical mailing list