summaryrefslogtreecommitdiff
path: root/source4/libcli/raw
diff options
context:
space:
mode:
Diffstat (limited to 'source4/libcli/raw')
-rw-r--r--source4/libcli/raw/clisession.c11
-rw-r--r--source4/libcli/raw/clitransport.c13
-rw-r--r--source4/libcli/raw/clitree.c12
3 files changed, 25 insertions, 11 deletions
diff --git a/source4/libcli/raw/clisession.c b/source4/libcli/raw/clisession.c
index ed50601c25..30382e0837 100644
--- a/source4/libcli/raw/clisession.c
+++ b/source4/libcli/raw/clisession.c
@@ -33,18 +33,23 @@
/****************************************************************************
Initialize the session context
****************************************************************************/
-struct smbcli_session *smbcli_session_init(struct smbcli_transport *transport)
+struct smbcli_session *smbcli_session_init(struct smbcli_transport *transport,
+ TALLOC_CTX *parent_ctx, BOOL primary)
{
struct smbcli_session *session;
uint16_t flags2;
uint32_t capabilities;
- session = talloc_zero(transport, struct smbcli_session);
+ session = talloc_zero(parent_ctx, struct smbcli_session);
if (!session) {
return NULL;
}
- session->transport = talloc_reference(session, transport);
+ if (primary) {
+ session->transport = talloc_steal(session, transport);
+ } else {
+ session->transport = talloc_reference(session, transport);
+ }
session->pid = (uint16_t)getpid();
session->vuid = UID_FIELD_INVALID;
diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c
index e3a8281f3f..c993fd7e60 100644
--- a/source4/libcli/raw/clitransport.c
+++ b/source4/libcli/raw/clitransport.c
@@ -61,16 +61,19 @@ static int transport_destructor(void *ptr)
/*
create a transport structure based on an established socket
*/
-struct smbcli_transport *smbcli_transport_init(struct smbcli_socket *sock)
+struct smbcli_transport *smbcli_transport_init(struct smbcli_socket *sock,
+ TALLOC_CTX *parent_ctx, BOOL primary)
{
struct smbcli_transport *transport;
- transport = talloc_p(sock, struct smbcli_transport);
+ transport = talloc_zero(parent_ctx, struct smbcli_transport);
if (!transport) return NULL;
- ZERO_STRUCTP(transport);
-
- transport->socket = talloc_reference(transport, sock);
+ if (primary) {
+ transport->socket = talloc_steal(transport, sock);
+ } else {
+ transport->socket = talloc_reference(transport, sock);
+ }
transport->negotiate.protocol = PROTOCOL_NT1;
transport->options.use_spnego = lp_use_spnego();
transport->options.max_xmit = lp_max_xmit();
diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c
index 06963d5bc4..ce4dafca9f 100644
--- a/source4/libcli/raw/clitree.c
+++ b/source4/libcli/raw/clitree.c
@@ -33,16 +33,22 @@
/****************************************************************************
Initialize the tree context
****************************************************************************/
-struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session)
+struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session,
+ TALLOC_CTX *parent_ctx, BOOL primary)
{
struct smbcli_tree *tree;
- tree = talloc_zero(session, struct smbcli_tree);
+ tree = talloc_zero(parent_ctx, struct smbcli_tree);
if (!tree) {
return NULL;
}
- tree->session = talloc_reference(tree, session);
+ if (primary) {
+ tree->session = talloc_steal(tree, session);
+ } else {
+ tree->session = talloc_reference(tree, session);
+ }
+
return tree;
}