summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-01-24 00:57:14 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:09:09 -0500
commit3e44c4a3ba6acd7d9bc997c012d1863377e9d873 (patch)
tree3d5dc90c700fa4e10f563f318368efd0df85e8c2 /source4/torture
parent46b5a3d7542b5e0960e6ef3ac9cbd7fcf142ac3f (diff)
downloadsamba-3e44c4a3ba6acd7d9bc997c012d1863377e9d873.tar.gz
samba-3e44c4a3ba6acd7d9bc997c012d1863377e9d873.tar.bz2
samba-3e44c4a3ba6acd7d9bc997c012d1863377e9d873.zip
r4951: some of the code dealing with libcli was getting too complex trying to
handle the inverted memory hierarchy that a normal session establishment gave. The inverted hierarchy came from that fact that you first establish a socket, then a transport, then a session and finally a tree. That leads to the socket being at the top of the memory hierarchy and the tree at the bottom, which makes no sense from the users point of view, as they want to be able to free the tree and have everything disappear. The core problem was that the libcli interface didn't distinguish between establishing a primary context and a secondary context. If you establish a 2nd session on a transport then you want the transport to be referenced by the session, whereas if you establish a primary session then you want the transport to be a child of the session. To fix this I have added "parent_ctx" and "primary" arguments to the libcli intialisation functions. This makes using the library much easier, and gives us a memory hierarchy that makes much more sense. I was prompted to do this by a bug in the cifs backend, which was caused by the socket not being properly torn down on a disconnect due to the inverted memory hierarchy. (This used to be commit 5e8fd5f70178992e249805c2e1ddafaf6840739b)
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/basic/secleak.c2
-rw-r--r--source4/torture/raw/context.c10
-rw-r--r--source4/torture/rpc/xplogin.c17
3 files changed, 9 insertions, 20 deletions
diff --git a/source4/torture/basic/secleak.c b/source4/torture/basic/secleak.c
index 4ff34e166f..31c23ff5f7 100644
--- a/source4/torture/basic/secleak.c
+++ b/source4/torture/basic/secleak.c
@@ -31,7 +31,7 @@ static BOOL try_failed_login(struct smbcli_state *cli)
struct smb_composite_sesssetup setup;
struct smbcli_session *session;
- session = smbcli_session_init(cli->transport);
+ session = smbcli_session_init(cli->transport, cli, False);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities;
setup.in.password = "INVALID-PASSWORD";
diff --git a/source4/torture/raw/context.c b/source4/torture/raw/context.c
index 4f1c6337eb..5b6a2dd2ad 100644
--- a/source4/torture/raw/context.c
+++ b/source4/torture/raw/context.c
@@ -81,7 +81,7 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
domain = lp_parm_string(-1, "torture", "userdomain");
printf("create a second security context on the same transport\n");
- session = smbcli_session_init(cli->transport);
+ session = smbcli_session_init(cli->transport, mem_ctx, False);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */
@@ -95,7 +95,7 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
session->vuid = setup.out.vuid;
printf("create a third security context on the same transport, with vuid set\n");
- session2 = smbcli_session_init(cli->transport);
+ session2 = smbcli_session_init(cli->transport, mem_ctx, False);
session2->vuid = session->vuid;
setup.in.sesskey = cli->transport->negotiate.sesskey;
@@ -115,7 +115,7 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
if (cli->transport->negotiate.capabilities & CAP_EXTENDED_SECURITY) {
printf("create a fourth security context on the same transport, without extended security\n");
- session3 = smbcli_session_init(cli->transport);
+ session3 = smbcli_session_init(cli->transport, mem_ctx, False);
session3->vuid = session->vuid;
setup.in.sesskey = cli->transport->negotiate.sesskey;
@@ -131,7 +131,7 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
}
printf("use the same tree as the existing connection\n");
- tree = smbcli_tree_init(session);
+ tree = smbcli_tree_init(session, mem_ctx, False);
tree->tid = cli->tree->tid;
printf("create a file using the new vuid\n");
@@ -217,7 +217,7 @@ static BOOL test_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
share = lp_parm_string(-1, "torture", "share");
printf("create a second tree context on the same session\n");
- tree = smbcli_tree_init(cli->session);
+ tree = smbcli_tree_init(cli->session, mem_ctx, False);
tcon.generic.level = RAW_TCON_TCONX;
tcon.tconx.in.flags = 0;
diff --git a/source4/torture/rpc/xplogin.c b/source4/torture/rpc/xplogin.c
index 25bda40da9..3c4a881d96 100644
--- a/source4/torture/rpc/xplogin.c
+++ b/source4/torture/rpc/xplogin.c
@@ -28,13 +28,6 @@
#include "librpc/gen_ndr/ndr_srvsvc.h"
#include "libcli/composite/composite.h"
-static int destroy_transport(void *ptr)
-{
- struct smbcli_transport *trans = ptr;
- talloc_free(trans->socket);
- return 0;
-}
-
static NTSTATUS after_negprot(struct smbcli_transport **dst_transport,
const char *dest_host, uint16_t port,
const char *my_name)
@@ -54,13 +47,10 @@ static NTSTATUS after_negprot(struct smbcli_transport **dst_transport,
return NT_STATUS_UNSUCCESSFUL;
}
- transport = smbcli_transport_init(sock);
- talloc_free(sock);
+ transport = smbcli_transport_init(sock, NULL, True);
if (transport == NULL)
return NT_STATUS_NO_MEMORY;
- talloc_set_destructor(transport, destroy_transport);
-
{
struct nbt_name calling;
struct nbt_name called;
@@ -115,7 +105,7 @@ static NTSTATUS anon_ipc(struct smbcli_transport *transport,
TALLOC_CTX *mem_ctx;
NTSTATUS status;
- session = smbcli_session_init(transport);
+ session = smbcli_session_init(transport, NULL, True);
if (session == NULL)
return NT_STATUS_NO_MEMORY;
@@ -144,8 +134,7 @@ static NTSTATUS anon_ipc(struct smbcli_transport *transport,
talloc_set_destructor(session, destroy_session);
- tree = smbcli_tree_init(session);
- talloc_free(session);
+ tree = smbcli_tree_init(session, NULL, True);
if (tree == NULL) {
talloc_free(mem_ctx);
return NT_STATUS_NO_MEMORY;