[PATCH] add lookup_domain_name() WAS: Re: Another showstopper for 3.2.2.

simo idra at samba.org
Mon Aug 18 00:02:39 GMT 2008


On Sun, 2008-08-17 at 13:53 -0700, Jeremy Allison wrote:
> On Sun, Aug 17, 2008 at 11:28:17AM -0400, simo wrote:
> > 
> > It seem such a waste to have to make 3 memory allocation with mem copies
> > going around just to fit an interface that can be easily split.
> > 
> > I'll attach a patch to the thread later.
> > If people like it I can commit it, otherwise I will just forget it.
> 
> I don't want to change the interface for 3.2.2 - too scary and
> possible to get it wrong for all the callers.

Definitely not for 3.2.2, I was considering v3-devel.

> If you do change the interface make sure you have
> two versions - one that can take an "any" string
> containing a "DOMAIN\name" or just "name" (ie.
> the one we have) and one that expects the DOMAIN
> and name to be split. Make the first one call the
> second. But if the DOMAIN portion is NULL or ""
> you still have to do the guesswork.

I created a new patch that have a lookup_domain_name() and lookup_name()
functions that differ only by the domain + name vs fullname variables
being passed in.

Patch attached.

> lookup_name is a *complicated* piece of code,
> but it's right. I originally thought about
> changing it too but when I analysed it I
> realized it was already doing the right
> thing and I just needed to tell it what
> domain to use :-).

I did not change any logic, I just got the first part that splits the
string and make it an optional part. This way we do not see ugly things
like building a dom\name string just to see it split out back in dom and
name as the first thing inside lookup_name().

As a bonus, in this patch you get one less fstring too :-)

Btw in a couple of places it seem it would be useful to pass to
lookup_name() the separator to use, what about adding a 'separator'
parameter to it (can be NULL and defaults to '\\' in that case) ?

Simo.

-- 
Simo Sorce
Samba Team GPL Compliance Officer <simo at samba.org>
Senior Software Engineer at Red Hat Inc. <simo at redhat.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Split-lookup_name-and-create-a-new-functiong-calle.patch
Type: application/mbox
Size: 13354 bytes
Desc: not available
Url : http://lists.samba.org/archive/samba-technical/attachments/20080817/1eb2d33e/0001-Split-lookup_name-and-create-a-new-functiong-calle.bin


More information about the samba-technical mailing list