From 772f31797d22a8ef78e7257bbbd0cb36196af03a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 1 Apr 2005 11:24:52 +0000 Subject: r6165: fixed up the userinfo composite code. Fixes include: - talloc should always be done in the right context. For example, when creating the userinfo_state structure, place it inside the composite structure, not directly on the pipe. If this isn't done then correct cleanup can't happen on errors (as cleanup destroys the top level composite context only) - define private structures like userinfo_state in the userinfo.c code, not in the public header - only keep the parameters we need in the state structure. For example, the domain_handle is only needed in the first call, so we don't need to keep it around in the state structure, but the level is needed in later calls, so we need to keep it - always initialise [out,ref] parameters in RPC calls. The [ref] part means that the call assumes the pointer it has been given is valid. If you don't initialise it then you will get a segv on recv. This is why the code was dying. - don't use internal strucrure elements like the pipe pipe->conn->pending outside of the internal rpc implementation. That is an internal list, trying to use it from external code will cause crashes. - rpc calls assume that rpc call strucrures remain valid for the duration of the call. This means you need to keep the structures (such as "struct samr_Close") in the userinfo_state strucrure, otherwise it will go out of scope during the async processing - need to remember to change c->state to SMBCLI_REQUEST_DONE when the request has finished in the close handler, otherwise it will loop forever trying to close Mimir, please look at the diff carefully for more detailed info on the fixes (This used to be commit 01ea1e7762e214e87e74d6f28d6efeb6cdea9736) --- source4/torture/libnet/userinfo.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source4/torture') diff --git a/source4/torture/libnet/userinfo.c b/source4/torture/libnet/userinfo.c index 911aa086d4..fb54b6a184 100644 --- a/source4/torture/libnet/userinfo.c +++ b/source4/torture/libnet/userinfo.c @@ -25,7 +25,6 @@ #define TEST_USERNAME "libnetuserinfotest" - static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct samr_String *domname, struct dom_sid2 *sid) @@ -51,7 +50,7 @@ static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r2.in.connect_handle = &h; r2.in.domain_name = domname; - printf("domain lookup\n"); + printf("domain lookup on %s\n", domname->string); status = dcerpc_samr_LookupDomain(p, mem_ctx, &r2); if (!NT_STATUS_IS_OK(status)) { @@ -96,7 +95,7 @@ static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r1.in.num_names = 1; r1.in.names = names; - printf("user account lookup\n"); + printf("user account lookup '%s'\n", username); status = dcerpc_samr_LookupNames(p, mem_ctx, &r1); if (!NT_STATUS_IS_OK(status)) { @@ -150,7 +149,7 @@ static BOOL test_create(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.out.user_handle = &user_handle; r.out.rid = rid; - printf("creating user account\n"); + printf("creating user account %s\n", name); status = dcerpc_samr_CreateUser(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -237,7 +236,7 @@ BOOL torture_userinfo(void) ret = False; goto done; } - name.string = b->host; + name.string = lp_workgroup(); if (!test_opendomain(p, mem_ctx, &h, &name, &sid)) { ret = False; -- cgit