summaryrefslogtreecommitdiff
path: root/source4/libcli/smb2
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-07-30 17:29:02 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:15:11 -0500
commit7c50eec25edd2e70d9127f8cc35588c4bfbb53f9 (patch)
tree46467d8674008d99b64307166f5481065342a623 /source4/libcli/smb2
parent7e949c9fb12483df11c7e926e2c5ed8e4b9b9d20 (diff)
downloadsamba-7c50eec25edd2e70d9127f8cc35588c4bfbb53f9.tar.gz
samba-7c50eec25edd2e70d9127f8cc35588c4bfbb53f9.tar.bz2
samba-7c50eec25edd2e70d9127f8cc35588c4bfbb53f9.zip
r17318: make better usage of the composite api
metze (This used to be commit 683fc25f6524a3821ba70529251aabe97bad9370)
Diffstat (limited to 'source4/libcli/smb2')
-rw-r--r--source4/libcli/smb2/connect.c22
-rw-r--r--source4/libcli/smb2/session.c42
2 files changed, 13 insertions, 51 deletions
diff --git a/source4/libcli/smb2/connect.c b/source4/libcli/smb2/connect.c
index b185ff7a88..0d772bccd8 100644
--- a/source4/libcli/smb2/connect.c
+++ b/source4/libcli/smb2/connect.c
@@ -171,38 +171,24 @@ struct composite_context *smb2_connect_send(TALLOC_CTX *mem_ctx,
struct nbt_name name;
struct composite_context *creq;
- c = talloc_zero(mem_ctx, struct composite_context);
+ c = composite_create(mem_ctx, ev);
if (c == NULL) return NULL;
state = talloc(c, struct smb2_connect_state);
- if (state == NULL) {
- c->status = NT_STATUS_NO_MEMORY;
- goto failed;
- }
-
- c->state = COMPOSITE_STATE_IN_PROGRESS;
+ if (composite_nomem(state, c)) return c;
c->private_data = state;
- c->event_ctx = ev;
state->credentials = credentials;
state->host = talloc_strdup(c, host);
+ if (composite_nomem(state->host, c)) return c;
state->share = talloc_strdup(c, share);
- if (state->host == NULL || state->share == NULL) {
- c->status = NT_STATUS_NO_MEMORY;
- goto failed;
- }
+ if (composite_nomem(state->share, c)) return c;
ZERO_STRUCT(name);
name.name = host;
creq = resolve_name_send(&name, c->event_ctx, lp_name_resolve_order());
-
composite_continue(c, creq, continue_resolve, c);
-
- return c;
-
-failed:
- composite_error(c, c->status);
return c;
}
diff --git a/source4/libcli/smb2/session.c b/source4/libcli/smb2/session.c
index 7518a3d6d3..8ebdc93bd4 100644
--- a/source4/libcli/smb2/session.c
+++ b/source4/libcli/smb2/session.c
@@ -196,18 +196,12 @@ struct composite_context *smb2_session_setup_spnego_send(struct smb2_session *se
struct composite_context *c;
struct smb2_session_state *state;
- c = talloc_zero(session, struct composite_context);
+ c = composite_create(session, session->transport->socket->event.ctx);
if (c == NULL) return NULL;
state = talloc(c, struct smb2_session_state);
- if (state == NULL) {
- c->status = NT_STATUS_NO_MEMORY;
- goto failed;
- }
-
- c->state = COMPOSITE_STATE_IN_PROGRESS;
+ if (composite_nomem(state, c)) return c;
c->private_data = state;
- c->event_ctx = session->transport->socket->event.ctx;
ZERO_STRUCT(state->io);
state->io.in._pad = 0x0000;
@@ -216,47 +210,29 @@ struct composite_context *smb2_session_setup_spnego_send(struct smb2_session *se
state->io.in.unknown4 = 0; /* uint64_t */
c->status = gensec_set_credentials(session->gensec, credentials);
- if (!NT_STATUS_IS_OK(c->status)) {
- goto failed;
- }
+ if (!composite_is_ok(c)) return c;
c->status = gensec_set_target_hostname(session->gensec,
session->transport->socket->hostname);
- if (!NT_STATUS_IS_OK(c->status)) {
- goto failed;
- }
+ if (!composite_is_ok(c)) return c;
c->status = gensec_set_target_service(session->gensec, "cifs");
- if (!NT_STATUS_IS_OK(c->status)) {
- goto failed;
- }
+ if (!composite_is_ok(c)) return c;
c->status = gensec_start_mech_by_oid(session->gensec, GENSEC_OID_SPNEGO);
- if (!NT_STATUS_IS_OK(c->status)) {
- goto failed;
- }
+ if (!composite_is_ok(c)) return c;
c->status = gensec_update(session->gensec, c,
session->transport->negotiate.secblob,
&state->io.in.secblob);
if (!NT_STATUS_EQUAL(c->status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
- goto failed;
+ composite_error(c, c->status);
+ return c;
}
state->gensec_status = c->status;
state->req = smb2_session_setup_send(session, &state->io);
- if (state->req == NULL) {
- c->status = NT_STATUS_NO_MEMORY;
- goto failed;
- }
-
- state->req->async.fn = session_request_handler;
- state->req->async.private = c;
-
- return c;
-
-failed:
- composite_error(c, c->status);
+ composite_continue_smb2(c, state->req, session_request_handler, c);
return c;
}