summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-09-28 05:44:59 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:59:25 -0500
commitb2f1a29e4348a5bc34a87d72d526e23e421ed9d5 (patch)
treec69987090647da615193f1361e03986588ac164d
parenta675b09e8d45b9298df8f8c82bbaa7b91a793eb5 (diff)
downloadsamba-b2f1a29e4348a5bc34a87d72d526e23e421ed9d5.tar.gz
samba-b2f1a29e4348a5bc34a87d72d526e23e421ed9d5.tar.bz2
samba-b2f1a29e4348a5bc34a87d72d526e23e421ed9d5.zip
r2710: continue with the new style of providing a parent context whenever
possible to a structure creation routine. This makes for much easier global cleanup. (This used to be commit e14ee428ec357fab76a960387a9820a673786e27)
-rw-r--r--source4/auth/auth_domain.c2
-rw-r--r--source4/client/client.c4
-rw-r--r--source4/client/smbspool.c2
-rw-r--r--source4/libcli/cliconnect.c41
-rw-r--r--source4/libcli/clidfs.c2
-rw-r--r--source4/libcli/raw/clisocket.c4
-rw-r--r--source4/libcli/raw/clitree.c5
-rw-r--r--source4/librpc/rpc/dcerpc_smb.c3
-rw-r--r--source4/librpc/rpc/dcerpc_util.c5
-rw-r--r--source4/ntvfs/cifs/vfs_cifs.c15
-rw-r--r--source4/ntvfs/ipc/vfs_ipc.c26
-rw-r--r--source4/rpc_server/dcerpc_server.c46
-rw-r--r--source4/torture/gentest.c2
-rw-r--r--source4/torture/locktest.c2
-rw-r--r--source4/torture/locktest2.c7
-rw-r--r--source4/torture/masktest.c2
-rw-r--r--source4/torture/raw/context.c4
-rw-r--r--source4/torture/rpc/samr.c40
-rw-r--r--source4/torture/torture.c8
19 files changed, 124 insertions, 96 deletions
diff --git a/source4/auth/auth_domain.c b/source4/auth/auth_domain.c
index b0dd2612b0..831bb4cfe0 100644
--- a/source4/auth/auth_domain.c
+++ b/source4/auth/auth_domain.c
@@ -169,7 +169,7 @@ static NTSTATUS connect_to_domain_password_server(struct smbcli_state **cli,
return NT_STATUS_NO_LOGON_SERVERS;
/* Attempt connection */
- result = smbcli_full_connection(cli, lp_netbios_name(), remote_machine,
+ result = smbcli_full_connection(NULL, cli, lp_netbios_name(), remote_machine,
&dest_ip, 0, "IPC$", "IPC", "", "", "",0, retry);
if (!NT_STATUS_IS_OK(result)) {
diff --git a/source4/client/client.c b/source4/client/client.c
index 68b30acc67..9a70c2e09f 100644
--- a/source4/client/client.c
+++ b/source4/client/client.c
@@ -2727,7 +2727,7 @@ static struct smbcli_state *do_connect(const char *server, const char *share)
again:
/* have to open a new connection */
- if (!(c=smbcli_state_init()) || !smbcli_socket_connect(c, server_n)) {
+ if (!(c=smbcli_state_init(NULL)) || !smbcli_socket_connect(c, server_n)) {
d_printf("Connection to %s failed\n", server_n);
return NULL;
}
@@ -2858,7 +2858,7 @@ static int do_message_op(void)
server_name = dest_ip ? dest_ip : desthost;
- if (!(cli=smbcli_state_init()) || !smbcli_socket_connect(cli, server_name)) {
+ if (!(cli=smbcli_state_init(NULL)) || !smbcli_socket_connect(cli, server_name)) {
d_printf("Connection to %s failed\n", server_name);
return 1;
}
diff --git a/source4/client/smbspool.c b/source4/client/smbspool.c
index 25208ac93a..e81453a23b 100644
--- a/source4/client/smbspool.c
+++ b/source4/client/smbspool.c
@@ -279,7 +279,7 @@ smb_connect(const char *workgroup, /* I - Workgroup */
myname = get_myname();
- nt_status = smbcli_full_connection(&c, myname, server, NULL, 0, share, "?????",
+ nt_status = smbcli_full_connection(NULL, &c, myname, server, NULL, 0, share, "?????",
username, workgroup, password, 0, NULL);
free(myname);
diff --git a/source4/libcli/cliconnect.c b/source4/libcli/cliconnect.c
index aa6aec4a1e..8e7e128a4e 100644
--- a/source4/libcli/cliconnect.c
+++ b/source4/libcli/cliconnect.c
@@ -27,7 +27,7 @@ BOOL smbcli_socket_connect(struct smbcli_state *cli, const char *server)
{
struct smbcli_socket *sock;
- sock = smbcli_sock_init();
+ sock = smbcli_sock_init(cli);
if (!sock) return False;
if (!smbcli_sock_connect_byname(sock, server, 0)) {
@@ -149,17 +149,18 @@ NTSTATUS smbcli_send_tconX(struct smbcli_state *cli, const char *sharename,
/*
easy way to get to a fully connected smbcli_state in one call
*/
-NTSTATUS smbcli_full_connection(struct smbcli_state **ret_cli,
- const char *myname,
- const char *host,
- struct in_addr *ip,
- const char *sharename,
- const char *devtype,
- const char *username,
- const char *domain,
- const char *password,
- uint_t flags,
- BOOL *retry)
+NTSTATUS smbcli_full_connection(TALLOC_CTX *parent_ctx,
+ struct smbcli_state **ret_cli,
+ const char *myname,
+ const char *host,
+ struct in_addr *ip,
+ const char *sharename,
+ const char *devtype,
+ const char *username,
+ const char *domain,
+ const char *password,
+ uint_t flags,
+ BOOL *retry)
{
struct smbcli_tree *tree;
NTSTATUS status;
@@ -177,21 +178,23 @@ NTSTATUS smbcli_full_connection(struct smbcli_state **ret_cli,
username = talloc_strdup(mem_ctx, p+1);
}
- status = smbcli_tree_full_connection(&tree, myname, host, 0, sharename, devtype,
+ status = smbcli_tree_full_connection(parent_ctx,
+ &tree, myname, host, 0, sharename, devtype,
username, domain, password);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
- (*ret_cli) = smbcli_state_init();
+ (*ret_cli) = smbcli_state_init(parent_ctx);
- (*ret_cli)->tree = talloc_reference(*ret_cli, tree);
- talloc_free(tree);
+ (*ret_cli)->tree = tree;
(*ret_cli)->session = tree->session;
(*ret_cli)->transport = tree->session->transport;
-
+ talloc_steal(*ret_cli, tree->session->transport->socket);
+
done:
talloc_free(mem_ctx);
+
return status;
}
@@ -207,11 +210,11 @@ NTSTATUS smbcli_tdis(struct smbcli_state *cli)
/****************************************************************************
Initialise a client state structure.
****************************************************************************/
-struct smbcli_state *smbcli_state_init(void)
+struct smbcli_state *smbcli_state_init(TALLOC_CTX *mem_ctx)
{
struct smbcli_state *cli;
- cli = talloc_p(NULL, struct smbcli_state);
+ cli = talloc_p(mem_ctx, struct smbcli_state);
if (cli) {
ZERO_STRUCTP(cli);
}
diff --git a/source4/libcli/clidfs.c b/source4/libcli/clidfs.c
index 674666a60a..c007d061a9 100644
--- a/source4/libcli/clidfs.c
+++ b/source4/libcli/clidfs.c
@@ -244,7 +244,7 @@ int smbcli_dfs_open_connection(struct smbcli_client* cluster,
return -1;
c = cluster->cli[i];
- if (NT_STATUS_IS_ERR(smbcli_full_connection(&c,
+ if (NT_STATUS_IS_ERR(smbcli_full_connection(NULL, &c,
NULL, host, NULL, 0,
share, "?????",
cluster->username, cluster->workgroup,
diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c
index 37188f4e77..14862a39f0 100644
--- a/source4/libcli/raw/clisocket.c
+++ b/source4/libcli/raw/clisocket.c
@@ -37,11 +37,11 @@ static int sock_destructor(void *ptr)
/*
create a smbcli_socket context
*/
-struct smbcli_socket *smbcli_sock_init(void)
+struct smbcli_socket *smbcli_sock_init(TALLOC_CTX *mem_ctx)
{
struct smbcli_socket *sock;
- sock = talloc_p(NULL, struct smbcli_socket);
+ sock = talloc_p(mem_ctx, struct smbcli_socket);
if (!sock) {
return NULL;
}
diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c
index f19cbf8e28..77fe0ebe2f 100644
--- a/source4/libcli/raw/clitree.c
+++ b/source4/libcli/raw/clitree.c
@@ -151,7 +151,8 @@ NTSTATUS smb_tree_disconnect(struct smbcli_tree *tree)
a convenient function to establish a smbcli_tree from scratch, using reasonable default
parameters
*/
-NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree,
+NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx,
+ struct smbcli_tree **ret_tree,
const char *my_name,
const char *dest_host, int port,
const char *service, const char *service_type,
@@ -172,7 +173,7 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree,
*ret_tree = NULL;
- sock = smbcli_sock_init();
+ sock = smbcli_sock_init(parent_ctx);
if (!sock) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source4/librpc/rpc/dcerpc_smb.c b/source4/librpc/rpc/dcerpc_smb.c
index 893093c050..ffe7e55a85 100644
--- a/source4/librpc/rpc/dcerpc_smb.c
+++ b/source4/librpc/rpc/dcerpc_smb.c
@@ -334,6 +334,7 @@ static NTSTATUS smb_shutdown_pipe(struct dcerpc_pipe *p)
c.close.in.fnum = smb->fnum;
c.close.in.write_time = 0;
smb_raw_close(smb->tree, &c);
+
talloc_free(smb);
return NT_STATUS_OK;
@@ -433,7 +434,7 @@ NTSTATUS dcerpc_pipe_open_smb(struct dcerpc_pipe **p,
}
smb->fnum = io.ntcreatex.out.fnum;
- smb->tree = talloc_reference(smb, tree);
+ smb->tree = tree;
(*p)->transport.private = smb;
diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c
index 71fe2c63e1..bcadd52104 100644
--- a/source4/librpc/rpc/dcerpc_util.c
+++ b/source4/librpc/rpc/dcerpc_util.c
@@ -460,12 +460,12 @@ static NTSTATUS dcerpc_pipe_connect_ncacn_np(struct dcerpc_pipe **p,
}
if (!username || !username[0]) {
- status = smbcli_full_connection(&cli, lp_netbios_name(),
+ status = smbcli_full_connection(NULL, &cli, lp_netbios_name(),
binding->host, NULL,
"ipc$", "?????",
"", "", NULL, 0, &retry);
} else {
- status = smbcli_full_connection(&cli, lp_netbios_name(),
+ status = smbcli_full_connection(NULL, &cli, lp_netbios_name(),
binding->host, NULL,
"ipc$", "?????",
username, domain,
@@ -486,7 +486,6 @@ static NTSTATUS dcerpc_pipe_connect_ncacn_np(struct dcerpc_pipe **p,
/* this ensures that the reference count is decremented so
a pipe close will really close the link */
- talloc_free(cli->tree);
talloc_steal(*p, cli);
(*p)->flags = binding->flags;
diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c
index 3931792ee8..c0160e6852 100644
--- a/source4/ntvfs/cifs/vfs_cifs.c
+++ b/source4/ntvfs/cifs/vfs_cifs.c
@@ -122,13 +122,14 @@ static NTSTATUS cvfs_connect(struct smbsrv_request *req, const char *sharename,
ntvfs_set_private(req->tcon, depth, private);
- status = smbcli_tree_full_connection(&private->tree,
- "vfs_cifs",
- host,
- 0,
- remote_share, "?????",
- user, domain,
- pass);
+ status = smbcli_tree_full_connection(private,
+ &private->tree,
+ "vfs_cifs",
+ host,
+ 0,
+ remote_share, "?????",
+ user, domain,
+ pass);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c
index 33e1287d21..59da6faea5 100644
--- a/source4/ntvfs/ipc/vfs_ipc.c
+++ b/source4/ntvfs/ipc/vfs_ipc.c
@@ -38,7 +38,6 @@ struct ipc_private {
/* a list of open pipes */
struct pipe_state {
struct pipe_state *next, *prev;
- TALLOC_CTX *mem_ctx;
const char *pipe_name;
uint16_t fnum;
struct dcesrv_connection *dce_conn;
@@ -85,10 +84,9 @@ again:
*/
static void pipe_shutdown(struct ipc_private *private, struct pipe_state *p)
{
- TALLOC_CTX *mem_ctx = private->pipe_list->mem_ctx;
- dcesrv_endpoint_disconnect(private->pipe_list->dce_conn);
- DLIST_REMOVE(private->pipe_list, private->pipe_list);
- talloc_destroy(mem_ctx);
+ talloc_free(p->dce_conn);
+ DLIST_REMOVE(private->pipe_list, p);
+ talloc_destroy(p);
}
@@ -199,33 +197,25 @@ static NTSTATUS ipc_open_generic(struct smbsrv_request *req, const char *fname,
struct pipe_state **ps)
{
struct pipe_state *p;
- TALLOC_CTX *mem_ctx;
NTSTATUS status;
struct dcesrv_ep_description ep_description;
struct auth_session_info *session_info = NULL;
NTVFS_GET_PRIVATE(ipc_private, private, req);
- mem_ctx = talloc_init("ipc_open '%s'", fname);
- if (!mem_ctx) {
- return NT_STATUS_NO_MEMORY;
- }
-
- p = talloc(mem_ctx, sizeof(struct pipe_state));
+ p = talloc_p(private, struct pipe_state);
if (!p) {
- talloc_destroy(mem_ctx);
return NT_STATUS_NO_MEMORY;
}
- p->mem_ctx = mem_ctx;
- p->pipe_name = talloc_strdup(mem_ctx, fname);
+ p->pipe_name = talloc_strdup(p, fname);
if (!p->pipe_name) {
- talloc_destroy(mem_ctx);
+ talloc_free(p);
return NT_STATUS_NO_MEMORY;
}
p->fnum = find_next_fnum(private);
if (p->fnum == 0) {
- talloc_destroy(mem_ctx);
+ talloc_free(p);
return NT_STATUS_TOO_MANY_OPENED_FILES;
}
@@ -261,7 +251,7 @@ static NTSTATUS ipc_open_generic(struct smbsrv_request *req, const char *fname,
session_info,
&p->dce_conn);
if (!NT_STATUS_IS_OK(status)) {
- talloc_destroy(mem_ctx);
+ talloc_free(p);
return status;
}
diff --git a/source4/rpc_server/dcerpc_server.c b/source4/rpc_server/dcerpc_server.c
index 9536fd6894..220c730790 100644
--- a/source4/rpc_server/dcerpc_server.c
+++ b/source4/rpc_server/dcerpc_server.c
@@ -269,6 +269,29 @@ NTSTATUS dcesrv_fetch_session_key(struct dcesrv_connection *p,
/*
+ destroy a link to an endpoint
+*/
+static int dcesrv_endpoint_destructor(void *ptr)
+{
+ struct dcesrv_connection *p = ptr;
+ if (p->iface) {
+ p->iface->unbind(p, p->iface);
+ }
+
+ /* destroy any handles */
+ while (p->handles) {
+ dcesrv_handle_destroy(p, p->handles);
+ }
+
+ if (p->auth_state.gensec_security) {
+ gensec_end(&p->auth_state.gensec_security);
+ }
+
+ return 0;
+}
+
+
+/*
connect to a dcerpc endpoint
*/
NTSTATUS dcesrv_endpoint_connect(struct dcesrv_context *dce_ctx,
@@ -294,6 +317,8 @@ NTSTATUS dcesrv_endpoint_connect(struct dcesrv_context *dce_ctx,
(*p)->auth_state.session_key = dcesrv_generic_session_key;
(*p)->srv_conn = NULL;
+ talloc_set_destructor(*p, dcesrv_endpoint_destructor);
+
return NT_STATUS_OK;
}
@@ -332,27 +357,6 @@ NTSTATUS dcesrv_endpoint_search_connect(struct dcesrv_context *dce_ctx,
}
-/*
- disconnect a link to an endpoint
-*/
-void dcesrv_endpoint_disconnect(struct dcesrv_connection *p)
-{
- if (p->iface) {
- p->iface->unbind(p, p->iface);
- }
-
- /* destroy any handles */
- while (p->handles) {
- dcesrv_handle_destroy(p, p->handles);
- }
-
- if (p->auth_state.gensec_security) {
- gensec_end(&p->auth_state.gensec_security);
- }
-
- talloc_free(p);
-}
-
static void dcesrv_init_hdr(struct dcerpc_packet *pkt)
{
pkt->rpc_vers = 5;
diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c
index 71e5a8d8f9..22cbb79769 100644
--- a/source4/torture/gentest.c
+++ b/source4/torture/gentest.c
@@ -171,7 +171,7 @@ static BOOL connect_servers(void)
printf("Connecting to \\\\%s\\%s as %s - instance %d\n",
servers[i].server_name, servers[i].share_name,
servers[i].username, j);
- status = smbcli_full_connection(&servers[i].cli[j],
+ status = smbcli_full_connection(NULL, &servers[i].cli[j],
"gentest",
servers[i].server_name, NULL,
servers[i].share_name, "?????",
diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c
index 494688dfb5..6d5558c6fd 100644
--- a/source4/torture/locktest.c
+++ b/source4/torture/locktest.c
@@ -119,7 +119,7 @@ static struct smbcli_state *connect_one(char *share, int snum)
slprintf(myname,sizeof(myname), "lock-%u-%u", getpid(), snum);
do {
- status = smbcli_full_connection(&c, myname,
+ status = smbcli_full_connection(NULL, &c, myname,
server, NULL,
share, "?????",
servers[snum].username, lp_workgroup(),
diff --git a/source4/torture/locktest2.c b/source4/torture/locktest2.c
index 63f71f2004..f474b3efa9 100644
--- a/source4/torture/locktest2.c
+++ b/source4/torture/locktest2.c
@@ -173,9 +173,10 @@ static struct smbcli_state *connect_one(char *share)
slprintf(myname,sizeof(myname), "lock-%u-%u", getpid(), count++);
- nt_status = smbcli_full_connection(&c, myname, server_n, NULL, 0, share, "?????",
- username, lp_workgroup(), password, 0,
- NULL);
+ nt_status = smbcli_full_connection(NULL,
+ &c, myname, server_n, NULL, 0, share, "?????",
+ username, lp_workgroup(), password, 0,
+ NULL);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("smbcli_full_connection failed with error %s\n", nt_errstr(nt_status)));
diff --git a/source4/torture/masktest.c b/source4/torture/masktest.c
index ee7e25ebbd..74c640d30b 100644
--- a/source4/torture/masktest.c
+++ b/source4/torture/masktest.c
@@ -169,7 +169,7 @@ static struct smbcli_state *connect_one(char *share)
*share = 0;
share++;
- status = smbcli_full_connection(&c, "masktest",
+ status = smbcli_full_connection(NULL, &c, "masktest",
server, NULL,
share, "?????",
username, lp_workgroup(),
diff --git a/source4/torture/raw/context.c b/source4/torture/raw/context.c
index b5f439b5e9..ad8245faaf 100644
--- a/source4/torture/raw/context.c
+++ b/source4/torture/raw/context.c
@@ -173,7 +173,6 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("logoff the new vuid\n");
status = smb_raw_ulogoff(session);
CHECK_STATUS(status, NT_STATUS_OK);
- talloc_free(session);
printf("the new vuid should not now be accessible\n");
status = smb_raw_write(tree, &wr);
@@ -186,9 +185,8 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
status = smb_raw_close(cli->tree, &cl);
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
- /* close down the new tree, which will also close the session
- as the reference count will be 0 */
talloc_free(tree);
+ talloc_free(session);
done:
return ret;
diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c
index 5bc5b3bf49..ac09a346f6 100644
--- a/source4/torture/rpc/samr.c
+++ b/source4/torture/rpc/samr.c
@@ -2887,30 +2887,40 @@ static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct samr_Connect4 r4;
struct samr_Connect5 r5;
union samr_ConnectInfo info;
- BOOL ret = True;
+ struct policy_handle h;
+ BOOL ret = True, got_handle = False;
printf("testing samr_Connect\n");
r.in.system_name = 0;
r.in.access_mask = SEC_RIGHTS_MAXIMUM_ALLOWED;
- r.out.connect_handle = handle;
+ r.out.connect_handle = &h;
status = dcerpc_samr_Connect(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("Connect failed - %s\n", nt_errstr(status));
ret = False;
+ } else {
+ got_handle = True;
+ *handle = h;
}
printf("testing samr_Connect2\n");
r2.in.system_name = NULL;
r2.in.access_mask = SEC_RIGHTS_MAXIMUM_ALLOWED;
- r2.out.connect_handle = handle;
+ r2.out.connect_handle = &h;
status = dcerpc_samr_Connect2(p, mem_ctx, &r2);
if (!NT_STATUS_IS_OK(status)) {
printf("Connect2 failed - %s\n", nt_errstr(status));
ret = False;
+ } else {
+ if (got_handle) {
+ test_Close(p, mem_ctx, handle);
+ }
+ got_handle = True;
+ *handle = h;
}
printf("testing samr_Connect3\n");
@@ -2918,12 +2928,18 @@ static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r3.in.system_name = NULL;
r3.in.unknown = 0;
r3.in.access_mask = SEC_RIGHTS_MAXIMUM_ALLOWED;
- r3.out.connect_handle = handle;
+ r3.out.connect_handle = &h;
status = dcerpc_samr_Connect3(p, mem_ctx, &r3);
if (!NT_STATUS_IS_OK(status)) {
printf("Connect3 failed - %s\n", nt_errstr(status));
ret = False;
+ } else {
+ if (got_handle) {
+ test_Close(p, mem_ctx, handle);
+ }
+ got_handle = True;
+ *handle = h;
}
printf("testing samr_Connect4\n");
@@ -2931,12 +2947,18 @@ static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r4.in.system_name = "";
r4.in.unknown = 0;
r4.in.access_mask = SEC_RIGHTS_MAXIMUM_ALLOWED;
- r4.out.connect_handle = handle;
+ r4.out.connect_handle = &h;
status = dcerpc_samr_Connect4(p, mem_ctx, &r4);
if (!NT_STATUS_IS_OK(status)) {
printf("Connect4 failed - %s\n", nt_errstr(status));
ret = False;
+ } else {
+ if (got_handle) {
+ test_Close(p, mem_ctx, handle);
+ }
+ got_handle = True;
+ *handle = h;
}
printf("testing samr_Connect5\n");
@@ -2949,12 +2971,18 @@ static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r5.in.level = 1;
r5.in.info = &info;
r5.out.info = &info;
- r5.out.connect_handle = handle;
+ r5.out.connect_handle = &h;
status = dcerpc_samr_Connect5(p, mem_ctx, &r5);
if (!NT_STATUS_IS_OK(status)) {
printf("Connect5 failed - %s\n", nt_errstr(status));
ret = False;
+ } else {
+ if (got_handle) {
+ test_Close(p, mem_ctx, handle);
+ }
+ got_handle = True;
+ *handle = h;
}
return ret;
diff --git a/source4/torture/torture.c b/source4/torture/torture.c
index c6af807357..15be6e528b 100644
--- a/source4/torture/torture.c
+++ b/source4/torture/torture.c
@@ -43,7 +43,7 @@ static struct smbcli_state *open_nbt_connection(void)
make_nmb_name(&calling, lp_netbios_name(), 0x0);
choose_called_name(&called, host, 0x20);
- cli = smbcli_state_init();
+ cli = smbcli_state_init(NULL);
if (!cli) {
printf("Failed initialize smbcli_struct to connect with %s\n", host);
return NULL;
@@ -93,7 +93,8 @@ BOOL torture_open_connection_share(struct smbcli_state **c,
if (use_kerberos)
flags |= SMBCLI_FULL_CONNECTION_USE_KERBEROS;
- status = smbcli_full_connection(c, lp_netbios_name(),
+ status = smbcli_full_connection(NULL,
+ c, lp_netbios_name(),
hostname, NULL,
sharename, "?????",
username, username[0]?userdomain:"",
@@ -857,7 +858,8 @@ static BOOL run_tcon_devtype_test(int dummy)
const char *userdomain = lp_parm_string(-1, "torture", "userdomain");
const char *password = lp_parm_string(-1, "torture", "password");
- status = smbcli_full_connection(&cli1, lp_netbios_name(),
+ status = smbcli_full_connection(NULL,
+ &cli1, lp_netbios_name(),
host, NULL,
share, "?????",
username, userdomain,