summaryrefslogtreecommitdiff
path: root/source4/librpc
diff options
context:
space:
mode:
authorRafal Szczesniak <mimir@samba.org>2005-12-09 00:04:38 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:47:12 -0500
commit38b0dde1148a55040f9c1948a510ee67273f8a49 (patch)
tree130fa69aee47c421265e75b642d230d8aa2380b1 /source4/librpc
parent6f33cdbc2a600f72f5c95f1bc292e0afa096b073 (diff)
downloadsamba-38b0dde1148a55040f9c1948a510ee67273f8a49.tar.gz
samba-38b0dde1148a55040f9c1948a510ee67273f8a49.tar.bz2
samba-38b0dde1148a55040f9c1948a510ee67273f8a49.zip
r12135: Move named pipe connect on smb2 function to async implementation.
Completely untested, it's a bit difficult without having vista around (yet), so - Andrew, please test it and let me know what's wrong. rafal (This used to be commit b9e7522bd4b626402c51a69695bea0928f5baef7)
Diffstat (limited to 'source4/librpc')
-rw-r--r--source4/librpc/rpc/dcerpc_connect.c118
-rw-r--r--source4/librpc/rpc/dcerpc_util.c46
2 files changed, 121 insertions, 43 deletions
diff --git a/source4/librpc/rpc/dcerpc_connect.c b/source4/librpc/rpc/dcerpc_connect.c
index 9af54740a2..35a0602cbf 100644
--- a/source4/librpc/rpc/dcerpc_connect.c
+++ b/source4/librpc/rpc/dcerpc_connect.c
@@ -194,3 +194,121 @@ NTSTATUS dcerpc_pipe_connect_ncacn_np_smb(TALLOC_CTX *tmp_ctx,
c = dcerpc_pipe_connect_ncacn_np_smb_send(tmp_ctx, io);
return dcerpc_pipe_connect_ncacn_np_smb_recv(c);
}
+
+
+struct pipe_np_smb2_state {
+ struct smb2_tree *tree;
+ struct dcerpc_pipe_connect io;
+};
+
+
+void continue_pipe_open_smb2(struct composite_context *ctx)
+{
+ struct composite_context *c = talloc_get_type(ctx->async.private_data,
+ struct composite_context);
+ struct pipe_np_smb2_state *s = talloc_get_type(c->private_data,
+ struct pipe_np_smb2_state);
+
+ c->status = dcerpc_pipe_open_smb2_recv(ctx);
+ if (!NT_STATUS_IS_OK(c->status)) {
+ DEBUG(0,("Failed to open pipe %s - %s\n", s->io.pipe_name, nt_errstr(c->status)));
+ composite_error(c, c->status);
+ return;
+ }
+
+ composite_done(c);
+}
+
+
+void continue_smb2_connect(struct composite_context *ctx)
+{
+ struct composite_context *open_req;
+ struct composite_context *c = talloc_get_type(ctx->async.private_data,
+ struct composite_context);
+ struct pipe_np_smb2_state *s = talloc_get_type(c->private_data,
+ struct pipe_np_smb2_state);
+
+ c->status = smb2_connect_recv(ctx, c, &s->tree);
+ if (!NT_STATUS_IS_OK(c->status)) {
+ DEBUG(0,("Failed to connect to %s - %s\n", s->io.binding->host, nt_errstr(c->status)));
+ composite_error(c, c->status);
+ return;
+ }
+
+ s->io.pipe_name = s->io.binding->endpoint;
+
+ open_req = dcerpc_pipe_open_smb2_send(s->io.pipe->conn, s->tree, s->io.pipe_name);
+ if (open_req == NULL) {
+ composite_error(c, NT_STATUS_NO_MEMORY);
+ return;
+ }
+
+ composite_continue(c, open_req, continue_pipe_open_smb2, c);
+}
+
+
+struct composite_context *dcerpc_pipe_connect_ncacn_np_smb2_send(TALLOC_CTX *mem_ctx,
+ struct dcerpc_pipe_connect *io)
+{
+ struct composite_context *c;
+ struct pipe_np_smb2_state *s;
+ struct composite_context *conn_req;
+
+ c = talloc_zero(mem_ctx, struct composite_context);
+ if (c == NULL) return NULL;
+
+ s = talloc_zero(c, struct pipe_np_smb2_state);
+ if (s == NULL) {
+ composite_error(c, NT_STATUS_NO_MEMORY);
+ goto done;
+ }
+
+ c->state = COMPOSITE_STATE_IN_PROGRESS;
+ c->private_data = s;
+ c->event_ctx = io->pipe->conn->event_ctx;
+
+ s->io = *io;
+
+ if (s->io.binding->flags & DCERPC_SCHANNEL) {
+ s->io.creds = cli_credentials_init(mem_ctx);
+ if (s->io.creds) {
+ composite_error(c, NT_STATUS_NO_MEMORY);
+ goto done;
+ }
+
+ cli_credentials_set_anonymous(s->io.creds);
+ cli_credentials_guess(s->io.creds);
+ }
+
+ conn_req = smb2_connect_send(mem_ctx, s->io.binding->host, "IPC$", s->io.creds,
+ c->event_ctx);
+ if (conn_req == NULL) {
+ composite_error(c, NT_STATUS_NO_MEMORY);
+ goto done;
+ }
+
+ composite_continue(c, conn_req, continue_smb2_connect, c);
+
+done:
+ return c;
+}
+
+
+NTSTATUS dcerpc_pipe_connect_ncacn_np_smb2_recv(struct composite_context *c)
+{
+ NTSTATUS status = composite_wait(c);
+
+ talloc_free(c);
+ return status;
+}
+
+
+/* open a rpc connection to a rpc pipe on SMB2 using the binding
+ structure to determine the endpoint and options */
+NTSTATUS dcerpc_pipe_connect_ncacn_np_smb2(TALLOC_CTX *mem_ctx,
+ struct dcerpc_pipe_connect *io)
+{
+ struct composite_context *c;
+ c = dcerpc_pipe_connect_ncacn_np_smb2_send(mem_ctx, io);
+ return dcerpc_pipe_connect_ncacn_np_smb2_recv(c);
+}
diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c
index 732eade694..72975461d0 100644
--- a/source4/librpc/rpc/dcerpc_util.c
+++ b/source4/librpc/rpc/dcerpc_util.c
@@ -1016,59 +1016,19 @@ NTSTATUS dcerpc_pipe_auth(struct dcerpc_pipe *p,
}
-/* open a rpc connection to a rpc pipe on SMB2 using the binding
- structure to determine the endpoint and options */
-static NTSTATUS dcerpc_pipe_connect_ncacn_np_smb2(TALLOC_CTX *tmp_ctx,
- struct dcerpc_pipe *p,
- struct dcerpc_binding *binding,
- const char *pipe_uuid,
- uint32_t pipe_version,
- struct cli_credentials *credentials)
-{
- NTSTATUS status;
- struct smb2_tree *tree;
- const char *pipe_name = NULL;
-
- if (binding->flags & DCERPC_SCHANNEL) {
- credentials = cli_credentials_init(tmp_ctx);
- cli_credentials_set_anonymous(credentials);
- cli_credentials_guess(credentials);
- }
- status = smb2_connect(tmp_ctx, binding->host, "IPC$", credentials, &tree,
- p->conn->event_ctx);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0,("Failed to connect to %s - %s\n",
- binding->host, nt_errstr(status)));
- return status;
- }
-
- pipe_name = binding->endpoint;
-
- status = dcerpc_pipe_open_smb2(p->conn, tree, pipe_name);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0,("Failed to open pipe %s - %s\n", pipe_name, nt_errstr(status)));
- return status;
- }
-
- talloc_steal(p->conn, tree);
-
- return NT_STATUS_OK;
-}
-
-
/* open a rpc connection to a rpc pipe on SMB using the binding
structure to determine the endpoint and options */
static NTSTATUS dcerpc_pipe_connect_ncacn_np(TALLOC_CTX *tmp_ctx,
struct dcerpc_pipe_connect *io)
{
if (io->binding->flags & DCERPC_SMB2) {
- return dcerpc_pipe_connect_ncacn_np_smb2(tmp_ctx, io->pipe, io->binding,
- io->pipe_uuid, io->pipe_version,
- io->creds);
+ return dcerpc_pipe_connect_ncacn_np_smb2(tmp_ctx, io);
+
}
return dcerpc_pipe_connect_ncacn_np_smb(tmp_ctx, io);
}
+
/* open a rpc connection to a rpc pipe on SMP using the binding
structure to determine the endpoint and options */
static NTSTATUS dcerpc_pipe_connect_ncalrpc(TALLOC_CTX *tmp_ctx,