libnet_join

Andrew Bartlett abartlet at samba.org
Sun Sep 4 06:43:39 GMT 2005


On Sat, 2005-09-03 at 15:43 -0600, Brad Henry wrote:
> Hello,
> 
> Here is are two patches for libnet_join.c and libnet_join.h against the 
> SOC/SAMBA_4_0 branch (rev 9988) that fix the remaining libnet_join.c 
> problems. The biggest issue I was having was realizing that I had to use 
> mem_ctx rather than tmp_ctx for the libnet_RpcConnect() call. Without 
> that, even though I was successfully keeping the samr_pipe and 
> user_handle available across calls, the samr_pipe wasn't open.

It is worth watching the typical pattern in this area.  Currently, the
preferred way to do this kind of thing is to allocate everything on the
tmp_ctx, then steal it to the final returned context when done.  If
filling in a structure, they should be stolen to that structure (and a
requirement put on that the structure itself must be allocated with
talloc(), and not on the stack).  Where we don't get that far, we
talloc_steal to the passed in parent context, as the 'last thing' before
success.  This ensures partial failures are not kept around too long.

Use talloc_report_full() to see what is on each context, at various
parts of the function.  Now, I'm a bad boy and don't do that very often,
but that's what the tool is for.  It may also be used in gdb:

talloc_report_full(ptr, stdout)

while stepping though the function is supported.

> The only thing that libnet_join.c doesn't do at this moment is the 
> DsAddEntry() to create the CN=NTDS Settings container. I'm pretty 
> confident that it won't be too hard to add, using the code that used to 
> be in dssync.c.
> 
> I've made some other changes locally towards integrating it into the 
> RPC-NETLOGON torture test to make sure that the code gets thoroughly 
> tested, but I wanted to know your thoughts on this before I went too far.

That sounds like a good plan.  We should be testing this a lot by
calling all joins via it.  

We also need to ensure we can join ourselves, or work on the server-side
functionality so that we do.  Having a seperate RPC-JOIN test would be a
good thing (follow up with a single test samlogon) as it would be fast
enough to be put in the quicktest, but stresses a large area of code.

On to the patch itself:

-       ZERO_STRUCT(u_handle);
+       ZERO_STRUCT(*u_handle);

The correct macro here is ZERO_STUCTP.

Finally, I assume you run things under valgrind?

Andrew Bartlett

-- 
Andrew Bartlett                                http://samba.org/~abartlet/
Samba Developer, SuSE Labs, Novell Inc.        http://suse.de
Authentication Developer, Samba Team           http://samba.org
Student Network Administrator, Hawker College  http://hawkerc.net
-------------- 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/archive/samba-technical/attachments/20050904/401b3d90/attachment.bin


More information about the samba-technical mailing list