unit test not passing on my computer

Lukasz Zalewski lukas at dcs.qmul.ac.uk
Tue Jun 22 17:30:38 MDT 2010


Hi Jelmer,
On 22/06/2010 23:30, Jelmer Vernooij wrote:
> Hi Lukasz, Matthias,
>
> On Tue, 2010-06-22 at 09:15 +0100, Lukasz Zalewski wrote:
>> On 22/06/2010 07:26, Matthias Dieter Wallnöfer wrote:
>>> Hi Lukasz,
>>>
>>> if grouptype is not None:
>>>
>>> - ldbmessage["groupType"] = "%d" % ((grouptype)-2**32)
>>>
>>> + ldbmessage["groupType"] = "%d" % ((grouptype + 2**31) % 2**32 - 2**31
>>>
>>> ^^^ isn't this "groupType" alignment easier to do? Shouldn't "groupType
>>> % 2**32" alone fit ?
>> just using
>> "%d" % ((grouptype) % 2**32)
>> seems to break on both 32 and 64bit:
>> On 32:
>> groupType= -2147483644
>> groupType (grouptype % 2**32)= 2147483652
>>
>> on 64bit:
>> groupType= 2147483652
>> groupType (grouptype % 2**32)= 2147483652
>>
>> Note: on 32bit the value is correct to start with so no conversion would
>> be necessary
>>
>> Maybe Jelmer can shed some light on this
> This is definitely not the right fix, as the user in Python shouldn't
> have to care about the endianness of the machine on which the code is
> running.
>
> I don't really understand what the problem is that you're trying to
> solve though - what test is failing and in what way ?
>
> Cheers,
>
> Jelmer
The problem is as follows:
The possible values for groupType are imported from samba.dsdb
from samba.dsdb import (
     GTYPE_SECURITY_DOMAIN_LOCAL_GROUP,
     GTYPE_SECURITY_GLOBAL_GROUP,
     GTYPE_SECURITY_UNIVERSAL_GROUP,
     GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP,
     GTYPE_DISTRIBUTION_GLOBAL_GROUP,
     GTYPE_DISTRIBUTION_UNIVERSAL_GROUP,
)
Then the appropriate value is assingned through
ldbmessage["groupType"] = "%d" % ...

given GTYPE_SECURITY_DOMAIN_LOCAL_GROUP
on 32bit
the following statement
ldbmessage["groupType"] = "%d" % groupType
produces correct value of -2147483644

however on 64bit
the value is 2147483652

now to fix this problem on 64bit
ldbmessage["groupType"] = ((grouptype)-2**32)
hack was used - but as Matthieu noticed this breaks tests on 32 bit 
builds as it produces ivalid value and ldbadd bails out

I do agree its a nasty hack (to fix another, broken hack) - i'm just not 
sure what the solution is - as you say python should take care of this 
automatically, but it doesn't for some reason

Regards

Luk

>
>>> Matthias
>>>
>>> Lukasz Zalewski wrote:
>>>> Matthieu,
>>>> Attached is the patch that fixes the problems when assigning
>>>> (converting) grouptype value on 64 and 32 bit architectures. I have
>>>> tested this on both architectures and both produce exactly the same
>>>> values. Please let me know if this works for you
>>>>
>>>> Luk
>>>
>>
>
>



More information about the samba-technical mailing list