summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/cldap/cldap.c6
-rw-r--r--source4/libcli/cliconnect.c5
-rw-r--r--source4/libcli/composite/composite.c6
-rw-r--r--source4/libcli/dgram/dgramsocket.c6
-rw-r--r--source4/libcli/ldap/ldap_bind.c5
-rw-r--r--source4/libcli/ldap/ldap_client.c12
-rw-r--r--source4/libcli/nbt/nbtsocket.c6
-rw-r--r--source4/libcli/raw/clisocket.c22
-rw-r--r--source4/libcli/resolve/host.c1
-rw-r--r--source4/libcli/resolve/nbtlist.c3
-rw-r--r--source4/libcli/resolve/resolve.c13
-rw-r--r--source4/libcli/smb_composite/connect.c8
-rw-r--r--source4/libcli/smb_composite/fetchfile.c2
-rw-r--r--source4/libcli/smb_composite/fsinfo.c2
-rw-r--r--source4/libcli/wrepl/winsrepl.c6
15 files changed, 33 insertions, 70 deletions
diff --git a/source4/libcli/cldap/cldap.c b/source4/libcli/cldap/cldap.c
index d9910285d9..614bd51d2a 100644
--- a/source4/libcli/cldap/cldap.c
+++ b/source4/libcli/cldap/cldap.c
@@ -250,11 +250,7 @@ struct cldap_socket *cldap_socket_init(TALLOC_CTX *mem_ctx,
cldap = talloc(mem_ctx, struct cldap_socket);
if (cldap == NULL) goto failed;
- if (event_ctx == NULL) {
- cldap->event_ctx = event_context_init(cldap);
- } else {
- cldap->event_ctx = talloc_reference(cldap, event_ctx);
- }
+ cldap->event_ctx = talloc_reference(cldap, event_ctx);
if (cldap->event_ctx == NULL) goto failed;
cldap->idr = idr_init(cldap);
diff --git a/source4/libcli/cliconnect.c b/source4/libcli/cliconnect.c
index 4858a96110..c20a7fd935 100644
--- a/source4/libcli/cliconnect.c
+++ b/source4/libcli/cliconnect.c
@@ -33,13 +33,14 @@
*/
bool smbcli_socket_connect(struct smbcli_state *cli, const char *server,
const char **ports,
+ struct event_context *ev_ctx,
struct resolve_context *resolve_ctx,
struct smbcli_options *options)
{
struct smbcli_socket *sock;
- sock = smbcli_sock_connect_byname(server, ports, NULL, resolve_ctx,
- NULL);
+ sock = smbcli_sock_connect_byname(server, ports, NULL,
+ resolve_ctx, ev_ctx);
if (sock == NULL) return false;
diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c
index 26169e7838..966f56cba8 100644
--- a/source4/libcli/composite/composite.c
+++ b/source4/libcli/composite/composite.c
@@ -42,7 +42,11 @@ _PUBLIC_ struct composite_context *composite_create(TALLOC_CTX *mem_ctx,
c = talloc_zero(mem_ctx, struct composite_context);
if (!c) return NULL;
c->state = COMPOSITE_STATE_IN_PROGRESS;
- c->event_ctx = ev;
+ c->event_ctx = talloc_reference(c, ev);
+ if (!c->event_ctx) {
+ talloc_free(c);
+ return NULL;
+ }
return c;
}
diff --git a/source4/libcli/dgram/dgramsocket.c b/source4/libcli/dgram/dgramsocket.c
index 130d8ae870..06b7bd5771 100644
--- a/source4/libcli/dgram/dgramsocket.c
+++ b/source4/libcli/dgram/dgramsocket.c
@@ -167,11 +167,7 @@ struct nbt_dgram_socket *nbt_dgram_socket_init(TALLOC_CTX *mem_ctx,
dgmsock = talloc(mem_ctx, struct nbt_dgram_socket);
if (dgmsock == NULL) goto failed;
- if (event_ctx == NULL) {
- dgmsock->event_ctx = event_context_init(dgmsock);
- } else {
- dgmsock->event_ctx = talloc_reference(dgmsock, event_ctx);
- }
+ dgmsock->event_ctx = talloc_reference(dgmsock, event_ctx);
if (dgmsock->event_ctx == NULL) goto failed;
status = socket_create("ip", SOCKET_TYPE_DGRAM, &dgmsock->sock, 0);
diff --git a/source4/libcli/ldap/ldap_bind.c b/source4/libcli/ldap/ldap_bind.c
index 2c04edf950..e1569e7296 100644
--- a/source4/libcli/ldap/ldap_bind.c
+++ b/source4/libcli/ldap/ldap_bind.c
@@ -200,7 +200,7 @@ static struct ldap_message *new_ldap_sasl_bind_msg(struct ldap_connection *conn,
/*
perform a sasl bind using the given credentials
*/
-_PUBLIC_ NTSTATUS ldap_bind_sasl(struct ldap_connection *conn,
+_PUBLIC_ NTSTATUS ldap_bind_sasl(struct ldap_connection *conn,
struct cli_credentials *creds,
struct loadparm_context *lp_ctx)
{
@@ -223,7 +223,8 @@ _PUBLIC_ NTSTATUS ldap_bind_sasl(struct ldap_connection *conn,
gensec_init(lp_ctx);
- status = gensec_client_start(conn, &conn->gensec, NULL, lp_ctx);
+ status = gensec_client_start(conn, &conn->gensec,
+ conn->event.event_ctx, lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Failed to start GENSEC engine (%s)\n", nt_errstr(status)));
goto failed;
diff --git a/source4/libcli/ldap/ldap_client.c b/source4/libcli/ldap/ldap_client.c
index 296a7b11f2..bca867b033 100644
--- a/source4/libcli/ldap/ldap_client.c
+++ b/source4/libcli/ldap/ldap_client.c
@@ -48,17 +48,13 @@ _PUBLIC_ struct ldap_connection *ldap4_new_connection(TALLOC_CTX *mem_ctx,
{
struct ldap_connection *conn;
- conn = talloc_zero(mem_ctx, struct ldap_connection);
- if (conn == NULL) {
+ if (ev == NULL) {
return NULL;
}
- if (ev == NULL) {
- ev = event_context_init(conn);
- if (ev == NULL) {
- talloc_free(conn);
- return NULL;
- }
+ conn = talloc_zero(mem_ctx, struct ldap_connection);
+ if (conn == NULL) {
+ return NULL;
}
conn->next_messageid = 1;
diff --git a/source4/libcli/nbt/nbtsocket.c b/source4/libcli/nbt/nbtsocket.c
index 747127980a..5d4611e2d9 100644
--- a/source4/libcli/nbt/nbtsocket.c
+++ b/source4/libcli/nbt/nbtsocket.c
@@ -318,11 +318,7 @@ _PUBLIC_ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
nbtsock = talloc(mem_ctx, struct nbt_name_socket);
if (nbtsock == NULL) goto failed;
- if (event_ctx == NULL) {
- nbtsock->event_ctx = event_context_init(nbtsock);
- } else {
- nbtsock->event_ctx = talloc_reference(nbtsock, event_ctx);
- }
+ nbtsock->event_ctx = talloc_reference(nbtsock, event_ctx);
if (nbtsock->event_ctx == NULL) goto failed;
status = socket_create("ip", SOCKET_TYPE_DGRAM, &nbtsock->sock, 0);
diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c
index 1dcf2d1c53..49838e8a1c 100644
--- a/source4/libcli/raw/clisocket.c
+++ b/source4/libcli/raw/clisocket.c
@@ -59,12 +59,7 @@ struct composite_context *smbcli_sock_connect_send(TALLOC_CTX *mem_ctx,
if (result == NULL) goto failed;
result->state = COMPOSITE_STATE_IN_PROGRESS;
- if (event_ctx != NULL) {
- result->event_ctx = talloc_reference(result, event_ctx);
- } else {
- result->event_ctx = event_context_init(result);
- }
-
+ result->event_ctx = talloc_reference(result, event_ctx);
if (result->event_ctx == NULL) goto failed;
state = talloc(result, struct sock_connect_state);
@@ -202,6 +197,11 @@ _PUBLIC_ struct smbcli_socket *smbcli_sock_connect_byname(const char *host, cons
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
struct smbcli_socket *result;
+ if (event_ctx == NULL) {
+ DEBUG(0, ("Invalid NULL event context passed in as parameter\n"));
+ return NULL;
+ }
+
if (tmp_ctx == NULL) {
DEBUG(0, ("talloc_new failed\n"));
return NULL;
@@ -214,16 +214,6 @@ _PUBLIC_ struct smbcli_socket *smbcli_sock_connect_byname(const char *host, cons
return NULL;
}
- if (event_ctx == NULL) {
- event_ctx = event_context_init(mem_ctx);
- }
-
- if (event_ctx == NULL) {
- DEBUG(0, ("event_context_init failed\n"));
- talloc_free(tmp_ctx);
- return NULL;
- }
-
/* allow hostnames of the form NAME#xx and do a netbios lookup */
if ((p = strchr(name, '#'))) {
name_type = strtol(p+1, NULL, 16);
diff --git a/source4/libcli/resolve/host.c b/source4/libcli/resolve/host.c
index 4b8f3f9553..1a695432ee 100644
--- a/source4/libcli/resolve/host.c
+++ b/source4/libcli/resolve/host.c
@@ -135,7 +135,6 @@ struct composite_context *resolve_name_host_send(TALLOC_CTX *mem_ctx,
c = composite_create(mem_ctx, event_ctx);
if (c == NULL) return NULL;
- c->event_ctx = talloc_reference(c, event_ctx);
if (composite_nomem(c->event_ctx, c)) return c;
state = talloc(c, struct host_state);
diff --git a/source4/libcli/resolve/nbtlist.c b/source4/libcli/resolve/nbtlist.c
index 887bdd7ecf..8f085c5404 100644
--- a/source4/libcli/resolve/nbtlist.c
+++ b/source4/libcli/resolve/nbtlist.c
@@ -110,10 +110,9 @@ struct composite_context *resolve_name_nbtlist_send(TALLOC_CTX *mem_ctx,
struct nbtlist_state *state;
int i;
- c = composite_create(event_ctx, event_ctx);
+ c = composite_create(mem_ctx, event_ctx);
if (c == NULL) return NULL;
- c->event_ctx = talloc_reference(c, event_ctx);
if (composite_nomem(c->event_ctx, c)) return c;
state = talloc(c, struct nbtlist_state);
diff --git a/source4/libcli/resolve/resolve.c b/source4/libcli/resolve/resolve.c
index 33ace09443..aaf9ff1f8d 100644
--- a/source4/libcli/resolve/resolve.c
+++ b/source4/libcli/resolve/resolve.c
@@ -136,19 +136,14 @@ struct composite_context *resolve_name_send(struct resolve_context *ctx,
struct composite_context *c;
struct resolve_state *state;
- c = composite_create(event_ctx, event_ctx);
- if (c == NULL) return NULL;
-
- if (ctx == NULL) {
+ if (ctx == NULL || event_ctx == NULL) {
composite_error(c, NT_STATUS_INVALID_PARAMETER);
return c;
}
- if (event_ctx == NULL) {
- c->event_ctx = event_context_init(c);
- } else {
- c->event_ctx = talloc_reference(c, event_ctx);
- }
+ c = composite_create(ctx, event_ctx);
+ if (c == NULL) return NULL;
+
if (composite_nomem(c->event_ctx, c)) return c;
state = talloc(c, struct resolve_state);
diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c
index c44c62f868..c4abfa5e37 100644
--- a/source4/libcli/smb_composite/connect.c
+++ b/source4/libcli/smb_composite/connect.c
@@ -451,17 +451,15 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec
c = talloc_zero(mem_ctx, struct composite_context);
if (c == NULL) goto failed;
+ c->event_ctx = talloc_reference(c, event_ctx);
+ if (c->event_ctx == NULL) goto failed;
+
state = talloc_zero(c, struct connect_state);
if (state == NULL) goto failed;
- if (event_ctx == NULL) {
- event_ctx = event_context_init(mem_ctx);
- }
-
state->io = io;
c->state = COMPOSITE_STATE_IN_PROGRESS;
- c->event_ctx = talloc_reference(c, event_ctx);
c->private_data = state;
state->stage = CONNECT_RESOLVE;
diff --git a/source4/libcli/smb_composite/fetchfile.c b/source4/libcli/smb_composite/fetchfile.c
index d8d7481270..9cd02a51f4 100644
--- a/source4/libcli/smb_composite/fetchfile.c
+++ b/source4/libcli/smb_composite/fetchfile.c
@@ -62,7 +62,6 @@ static NTSTATUS fetchfile_connect(struct composite_context *c,
state->creq->async.fn = fetchfile_composite_handler;
state->stage = FETCHFILE_READ;
- c->event_ctx = talloc_reference(c, state->creq->event_ctx);
return NT_STATUS_OK;
}
@@ -158,7 +157,6 @@ struct composite_context *smb_composite_fetchfile_send(struct smb_composite_fetc
c->state = COMPOSITE_STATE_IN_PROGRESS;
state->stage = FETCHFILE_CONNECT;
- c->event_ctx = talloc_reference(c, state->creq->event_ctx);
c->private_data = state;
return c;
diff --git a/source4/libcli/smb_composite/fsinfo.c b/source4/libcli/smb_composite/fsinfo.c
index 2ec13df9b6..270d71f518 100644
--- a/source4/libcli/smb_composite/fsinfo.c
+++ b/source4/libcli/smb_composite/fsinfo.c
@@ -52,7 +52,6 @@ static NTSTATUS fsinfo_connect(struct composite_context *c,
state->req->async.fn = fsinfo_raw_handler;
state->stage = FSINFO_QUERY;
- c->event_ctx = talloc_reference(c, state->req->session->transport->socket->event.ctx);
return NT_STATUS_OK;
}
@@ -158,7 +157,6 @@ struct composite_context *smb_composite_fsinfo_send(struct smbcli_tree *tree,
c->state = COMPOSITE_STATE_IN_PROGRESS;
state->stage = FSINFO_CONNECT;
- c->event_ctx = talloc_reference(c, tree->session->transport->socket->event.ctx);
c->private_data = state;
state->creq = smb_composite_connect_send(state->connect, state,
diff --git a/source4/libcli/wrepl/winsrepl.c b/source4/libcli/wrepl/winsrepl.c
index 3e7793c0c7..0a4e52bd7b 100644
--- a/source4/libcli/wrepl/winsrepl.c
+++ b/source4/libcli/wrepl/winsrepl.c
@@ -172,11 +172,7 @@ struct wrepl_socket *wrepl_socket_init(TALLOC_CTX *mem_ctx,
wrepl_socket = talloc_zero(mem_ctx, struct wrepl_socket);
if (!wrepl_socket) return NULL;
- if (event_ctx == NULL) {
- wrepl_socket->event.ctx = event_context_init(wrepl_socket);
- } else {
- wrepl_socket->event.ctx = talloc_reference(wrepl_socket, event_ctx);
- }
+ wrepl_socket->event.ctx = talloc_reference(wrepl_socket, event_ctx);
if (!wrepl_socket->event.ctx) goto failed;
wrepl_socket->iconv_convenience = iconv_convenience;