summaryrefslogtreecommitdiff
path: root/source4/libcli
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 /source4/libcli
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)
Diffstat (limited to 'source4/libcli')
-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
4 files changed, 28 insertions, 24 deletions
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;
}