Sorting objectClass and krb5Key module

Andrew Bartlett abartlet at
Wed Jan 4 04:39:01 GMT 2006

On Wed, 2006-01-04 at 15:28 +1100, tridge at wrote:
> Andrew,
> Just noticed a problem with the objectclass sorting module. The
> ldb_next_request() interface assumes that the "struct ldb_request *"
> you pass in is a valid talloc pointer, which acts a a request specific
> context for other modules to use. Not many modules rely on this yet,
> which is why you get away with a stack variable, but it will
> definately break with some stacking orders.

I got caught out by looking at ldb_search, uses the stack.  It is the
intermediate layer at ldb_request that puts everything on the talloc'ed

> If you call in at the top level, by calling ldb_request() or
> ldb_search() the it will be fine as ldb_request() always copies the
> request structure to ensure that a valid talloc ptr is passed down,
> but by calling the ldb_next_request() function directly this is not
> done.
> Is there some reason why the objectclass sorting module should not
> call ldb_request() or ldb_search() ? 

My feeling was that as I was going to do a modify at this particular
point in the stack, that I should obtain the data at the same point.  

Imagine there was a module that would add in an extra objectClass,
somewhere in the stack above (perhaps because it was autogenerating some
other attributes as well).  This extra objectClass would then be stored
(and sorted into) the database.  

Perhaps it's a bad example, but it's the logic that lead me down that

> I also think the reason your sorting code gets so complex is that the
> ldb->schema structure is the wrong way up. What you really need is a
> "tell me what the parent is of this class" structure, rather than a
> "tell me what the children of this class are", which is what the
> current structure gives you.

But I had fun writing the code, given such minimal information :-)

> If we had a efficient "give me the parent" call, then you could use
> qsort() and a function that does walks up the parent tree. If you find
> the other class in the parent tree then you know its above you,
> otherwise assume its below. That should be quite efficient.
> Even better if we had a "how many levels to top" integer available in
> ldb->schema. Then the sort would be very fast.

Yep.  That's all we actually sort on.

Andrew Bartlett

Andrew Bartlett                      
Authentication Developer, Samba Team 
Student Network Administrator, Hawker College
-------------- 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 :

More information about the samba-technical mailing list