Sorting on DN attributes broken ?
Andrew Bartlett
abartlet at samba.org
Tue Aug 25 22:16:08 MDT 2009
On Fri, 2009-08-21 at 00:32 +0400, Matthieu Patou wrote:
> Hi all,
>
> I tried to used python binding for sort DN attibutes and the result
> seems a bit strange.
>
> I have a list of dn: listMissing
> And when I try this
> listMissing.sort()
> for e in listMissing:
> print >>sys.stderr,e
>
> I get first
> :/usr/local/src/samba4/source4/scripting/bin/upgradeschema.py:363:
> RuntimeWarning: tp_compare didn't return -1, 0 or 1
>
> And after the result are like this :
>
> CN=ANR,CN=Schema,CN=Configuration,DC=smb4,DC=tst
> CN=DSA,CN=Schema,CN=Configuration,DC=smb4,DC=tst
> CN=PKT,CN=Schema,CN=Configuration,DC=smb4,DC=tst
> CN=Cost,CN=Schema,CN=Configuration,DC=smb4,DC=tst
> CN=host,CN=Schema,CN=Configuration,DC=smb4,DC=tst
> CN=room,CN=Schema,CN=Configuration,DC=smb4,DC=tst
> CN=drink,CN=Schema,CN=Configuration,DC=smb4,DC=tst
> CN=Gecos,CN=Schema,CN=Configuration,DC=smb4,DC=tst
> CN=Owner,CN=Schema,CN=Configuration,DC=smb4,DC=tst
> CN=Device,CN=Schema,CN=Configuration,DC=smb4,DC=tst
> CN=FT-Dfs,CN=Schema,CN=Configuration,DC=smb4,DC=tst
> CN=IpHost,CN=Schema,CN=Configuration,DC=smb4,DC=tst
> CN=NisMap,CN=Schema,CN=Configuration,DC=smb4,DC=tst
> CN=OncRpc,CN=Schema,CN=Configuration,DC=smb4,DC=tst
>
> Clearly not sorted ...
The problem is, ldb_dn_compare() does a strcmp() internally if possible
(if the linearlised versions are available). It needs to be reworked to
do that strcmp in reverse to get a sensible order. Either that, or we
need to rework the code to do a fast-path 'are these equal' and a
slow-path 'what is the ordering comparison' functions.
Andrew Bartlett
--
Andrew Bartlett
http://samba.org/~abartlet/
Authentication Developer, Samba Team http://samba.org
Samba Developer, Cisco Inc.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20090826/d882b997/attachment.pgp>
More information about the samba-technical
mailing list