From ab4d635b92b116b02b88843b4ec4f5b7517bab1a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 26 Sep 2005 11:47:55 +0000 Subject: r10504: - seperate implementation specific stuff, from the generic composite stuff. - don't use SMBCLI_REQUEST_* state's in the genreic composite stuff - move monitor_fn to libnet. NOTE: I have maybe found some bugs, in code that is dirrectly in DONE or ERROR state in the _send() function. I haven't fixed this bugs in this commit! We may need some composite_trigger_*() functions or so. And maybe some other generic helper functions... metze (This used to be commit 4527815a0a9b96e460f301cb1f0c0b3964c166fc) --- source4/libcli/smb_composite/connect.c | 396 +++++++++++++++++++++++++++++++++ 1 file changed, 396 insertions(+) create mode 100644 source4/libcli/smb_composite/connect.c (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c new file mode 100644 index 0000000000..56d9d988c3 --- /dev/null +++ b/source4/libcli/smb_composite/connect.c @@ -0,0 +1,396 @@ +/* + Unix SMB/CIFS implementation. + + Copyright (C) Andrew Tridgell 2005 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +/* + a composite API for making a full SMB connection +*/ + +#include "includes.h" +#include "libcli/raw/libcliraw.h" +#include "libcli/composite/composite.h" +#include "libcli/smb_composite/smb_composite.h" + +/* the stages of this call */ +enum connect_stage {CONNECT_RESOLVE, + CONNECT_SOCKET, + CONNECT_SESSION_REQUEST, + CONNECT_NEGPROT, + CONNECT_SESSION_SETUP, + CONNECT_TCON}; + +struct connect_state { + enum connect_stage stage; + struct smbcli_socket *sock; + struct smbcli_transport *transport; + struct smbcli_session *session; + struct smb_composite_connect *io; + union smb_tcon *io_tcon; + struct smb_composite_sesssetup *io_setup; + struct smbcli_request *req; + struct composite_context *creq; +}; + + +static void request_handler(struct smbcli_request *); +static void composite_handler(struct composite_context *); + +/* + setup a negprot send +*/ +static NTSTATUS connect_send_negprot(struct composite_context *c, + struct smb_composite_connect *io) +{ + struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); + + state->req = smb_raw_negotiate_send(state->transport, lp_maxprotocol()); + NT_STATUS_HAVE_NO_MEMORY(state->req); + + state->req->async.fn = request_handler; + state->req->async.private = c; + state->stage = CONNECT_NEGPROT; + + return NT_STATUS_OK; +} + + +/* + a tree connect request has competed +*/ +static NTSTATUS connect_tcon(struct composite_context *c, + struct smb_composite_connect *io) +{ + struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); + NTSTATUS status; + + status = smb_raw_tcon_recv(state->req, c, state->io_tcon); + NT_STATUS_NOT_OK_RETURN(status); + + io->out.tree->tid = state->io_tcon->tconx.out.tid; + if (state->io_tcon->tconx.out.dev_type) { + io->out.tree->device = talloc_strdup(io->out.tree, + state->io_tcon->tconx.out.dev_type); + } + if (state->io_tcon->tconx.out.fs_type) { + io->out.tree->fs_type = talloc_strdup(io->out.tree, + state->io_tcon->tconx.out.fs_type); + } + + /* all done! */ + c->state = COMPOSITE_STATE_DONE; + + return NT_STATUS_OK; +} + + +/* + a session setup request has competed +*/ +static NTSTATUS connect_session_setup(struct composite_context *c, + struct smb_composite_connect *io) +{ + struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); + NTSTATUS status; + + status = smb_composite_sesssetup_recv(state->creq); + NT_STATUS_NOT_OK_RETURN(status); + + state->session->vuid = state->io_setup->out.vuid; + + /* setup for a tconx */ + io->out.tree = smbcli_tree_init(state->session, state, True); + NT_STATUS_HAVE_NO_MEMORY(io->out.tree); + + state->io_tcon = talloc(c, union smb_tcon); + NT_STATUS_HAVE_NO_MEMORY(state->io_tcon); + + /* connect to a share using a tree connect */ + state->io_tcon->generic.level = RAW_TCON_TCONX; + state->io_tcon->tconx.in.flags = 0; + state->io_tcon->tconx.in.password = data_blob(NULL, 0); + + state->io_tcon->tconx.in.path = talloc_asprintf(state->io_tcon, + "\\\\%s\\%s", + io->in.called_name, + io->in.service); + NT_STATUS_HAVE_NO_MEMORY(state->io_tcon->tconx.in.path); + if (!io->in.service_type) { + state->io_tcon->tconx.in.device = "?????"; + } else { + state->io_tcon->tconx.in.device = io->in.service_type; + } + + state->req = smb_raw_tcon_send(io->out.tree, state->io_tcon); + NT_STATUS_HAVE_NO_MEMORY(state->req); + if (state->req->state == SMBCLI_REQUEST_ERROR) { + return state->req->status; + } + + state->req->async.fn = request_handler; + state->req->async.private = c; + state->stage = CONNECT_TCON; + + return NT_STATUS_OK; +} + +/* + a negprot request has competed +*/ +static NTSTATUS connect_negprot(struct composite_context *c, + struct smb_composite_connect *io) +{ + struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); + NTSTATUS status; + + status = smb_raw_negotiate_recv(state->req); + NT_STATUS_NOT_OK_RETURN(status); + + /* next step is a session setup */ + state->session = smbcli_session_init(state->transport, state, True); + NT_STATUS_HAVE_NO_MEMORY(state->session); + + state->io_setup = talloc(c, struct smb_composite_sesssetup); + NT_STATUS_HAVE_NO_MEMORY(state->io_setup); + + /* prepare a session setup to establish a security context */ + state->io_setup->in.sesskey = state->transport->negotiate.sesskey; + state->io_setup->in.capabilities = state->transport->negotiate.capabilities; + state->io_setup->in.credentials = io->in.credentials; + state->io_setup->in.workgroup = io->in.workgroup; + + state->creq = smb_composite_sesssetup_send(state->session, state->io_setup); + NT_STATUS_HAVE_NO_MEMORY(state->creq); + if (state->creq->state == COMPOSITE_STATE_ERROR) { + return state->creq->status; + } + + state->creq->async.fn = composite_handler; + state->creq->async.private_data = c; + state->stage = CONNECT_SESSION_SETUP; + + return NT_STATUS_OK; +} + + +/* + a session request operation has competed +*/ +static NTSTATUS connect_session_request(struct composite_context *c, + struct smb_composite_connect *io) +{ + struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); + NTSTATUS status; + + status = smbcli_transport_connect_recv(state->req); + NT_STATUS_NOT_OK_RETURN(status); + + /* next step is a negprot */ + return connect_send_negprot(c, io); +} + +/* + a socket connection operation has competed +*/ +static NTSTATUS connect_socket(struct composite_context *c, + struct smb_composite_connect *io) +{ + struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); + NTSTATUS status; + struct nbt_name calling, called; + + status = smbcli_sock_connect_recv(state->creq); + NT_STATUS_NOT_OK_RETURN(status); + + /* the socket is up - we can initialise the smbcli transport layer */ + state->transport = smbcli_transport_init(state->sock, state, True); + NT_STATUS_HAVE_NO_MEMORY(state->transport); + + make_nbt_name_client(&calling, cli_credentials_get_workstation(io->in.credentials)); + + nbt_choose_called_name(state, &called, io->in.called_name, NBT_NAME_SERVER); + + /* we have a connected socket - next step is a session + request, if needed. Port 445 doesn't need it, so it goes + straight to the negprot */ + if (state->sock->port == 445) { + status = nbt_name_dup(state->transport, &called, + &state->transport->called); + NT_STATUS_NOT_OK_RETURN(status); + return connect_send_negprot(c, io); + } + + state->req = smbcli_transport_connect_send(state->transport, &calling, &called); + NT_STATUS_HAVE_NO_MEMORY(state->req); + + state->req->async.fn = request_handler; + state->req->async.private = c; + state->stage = CONNECT_SESSION_REQUEST; + + return NT_STATUS_OK; +} + + +/* + called when name resolution is finished +*/ +static NTSTATUS connect_resolve(struct composite_context *c, + struct smb_composite_connect *io) +{ + struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); + NTSTATUS status; + const char *address; + + status = resolve_name_recv(state->creq, state, &address); + NT_STATUS_NOT_OK_RETURN(status); + + state->creq = smbcli_sock_connect_send(state->sock, address, state->io->in.port, io->in.dest_host); + NT_STATUS_HAVE_NO_MEMORY(state->creq); + + state->stage = CONNECT_SOCKET; + state->creq->async.private_data = c; + state->creq->async.fn = composite_handler; + + return NT_STATUS_OK; +} + + +/* + handle and dispatch state transitions +*/ +static void state_handler(struct composite_context *c) +{ + struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); + + switch (state->stage) { + case CONNECT_RESOLVE: + c->status = connect_resolve(c, state->io); + break; + case CONNECT_SOCKET: + c->status = connect_socket(c, state->io); + break; + case CONNECT_SESSION_REQUEST: + c->status = connect_session_request(c, state->io); + break; + case CONNECT_NEGPROT: + c->status = connect_negprot(c, state->io); + break; + case CONNECT_SESSION_SETUP: + c->status = connect_session_setup(c, state->io); + break; + case CONNECT_TCON: + c->status = connect_tcon(c, state->io); + break; + } + + if (!NT_STATUS_IS_OK(c->status)) { + c->state = COMPOSITE_STATE_ERROR; + } + + if (c->state >= COMPOSITE_STATE_DONE && + c->async.fn) { + c->async.fn(c); + } +} + + +/* + handler for completion of a smbcli_request sub-request +*/ +static void request_handler(struct smbcli_request *req) +{ + struct composite_context *c = talloc_get_type(req->async.private, + struct composite_context); + state_handler(c); +} + +/* + handler for completion of a smbcli_composite sub-request +*/ +static void composite_handler(struct composite_context *creq) +{ + struct composite_context *c = talloc_get_type(creq->async.private_data, + struct composite_context); + state_handler(c); +} + +/* + a function to establish a smbcli_tree from scratch +*/ +struct composite_context *smb_composite_connect_send(struct smb_composite_connect *io, + struct event_context *event_ctx) +{ + struct composite_context *c; + struct connect_state *state; + struct nbt_name name; + + c = talloc_zero(NULL, struct composite_context); + if (c == NULL) goto failed; + + state = talloc(c, struct connect_state); + if (state == NULL) goto failed; + + state->sock = smbcli_sock_init(state, event_ctx); + if (state->sock == NULL) goto failed; + + state->io = io; + + c->state = COMPOSITE_STATE_IN_PROGRESS; + c->event_ctx = talloc_reference(c, state->sock->event.ctx); + c->private_data = state; + + state->stage = CONNECT_RESOLVE; + make_nbt_name_server(&name, io->in.dest_host); + state->creq = resolve_name_send(&name, c->event_ctx, lp_name_resolve_order()); + + if (state->creq == NULL) goto failed; + state->creq->async.private_data = c; + state->creq->async.fn = composite_handler; + + return c; +failed: + talloc_free(c); + return NULL; +} + +/* + recv half of async composite connect code +*/ +NTSTATUS smb_composite_connect_recv(struct composite_context *c, TALLOC_CTX *mem_ctx) +{ + NTSTATUS status; + + status = composite_wait(c); + + if (NT_STATUS_IS_OK(status)) { + struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); + talloc_steal(mem_ctx, state->io->out.tree); + } + + talloc_free(c); + return status; +} + +/* + sync version of smb_composite_connect +*/ +NTSTATUS smb_composite_connect(struct smb_composite_connect *io, TALLOC_CTX *mem_ctx, + struct event_context *ev) +{ + struct composite_context *c = smb_composite_connect_send(io, ev); + return smb_composite_connect_recv(c, mem_ctx); +} -- cgit From 68c70ef396f84077dd08f97bf700f0c2963c8676 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 2 Oct 2005 10:02:35 +0000 Subject: r10677: Add smb_composite_connectmulti: Send out multiple SYN packets at once, use the first one that replies correctly. Add a talloc context to smb_composite_connect() Volker (This used to be commit 6b88de182e40cb00a833c085f801fd47c92bbe94) --- source4/libcli/smb_composite/connect.c | 44 +++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 8 deletions(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 56d9d988c3..53cc8a9ac0 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -25,6 +25,7 @@ #include "libcli/raw/libcliraw.h" #include "libcli/composite/composite.h" #include "libcli/smb_composite/smb_composite.h" +#include "lib/events/events.h" /* the stages of this call */ enum connect_stage {CONNECT_RESOLVE, @@ -39,6 +40,7 @@ struct connect_state { struct smbcli_socket *sock; struct smbcli_transport *transport; struct smbcli_session *session; + struct smb_composite_connectmulti *conn; struct smb_composite_connect *io; union smb_tcon *io_tcon; struct smb_composite_sesssetup *io_setup; @@ -213,9 +215,11 @@ static NTSTATUS connect_socket(struct composite_context *c, NTSTATUS status; struct nbt_name calling, called; - status = smbcli_sock_connect_recv(state->creq); + status = smb_composite_connectmulti_recv(state->creq, state); NT_STATUS_NOT_OK_RETURN(status); + state->sock = state->conn->out.socket; + /* the socket is up - we can initialise the smbcli transport layer */ state->transport = smbcli_transport_init(state->sock, state, True); NT_STATUS_HAVE_NO_MEMORY(state->transport); @@ -254,11 +258,33 @@ static NTSTATUS connect_resolve(struct composite_context *c, struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); NTSTATUS status; const char *address; + struct smb_composite_connectmulti *conn; status = resolve_name_recv(state->creq, state, &address); NT_STATUS_NOT_OK_RETURN(status); - state->creq = smbcli_sock_connect_send(state->sock, address, state->io->in.port, io->in.dest_host); + conn = talloc(state, struct smb_composite_connectmulti); + NT_STATUS_HAVE_NO_MEMORY(conn); + state->conn = conn; + conn->in.num_dests = 1; + + conn->in.addresses = talloc_array(state->conn, const char *, 1); + NT_STATUS_HAVE_NO_MEMORY(conn->in.addresses); + conn->in.addresses[0] = address; + + conn->in.hostnames = talloc_array(state->conn, const char *, 1); + NT_STATUS_HAVE_NO_MEMORY(conn->in.hostnames); + conn->in.hostnames[0] = state->io->in.dest_host; + + conn->in.ports = NULL; + if (state->io->in.port != 0) { + conn->in.ports = talloc_array(state->conn, int, 1); + NT_STATUS_HAVE_NO_MEMORY(conn->in.ports); + conn->in.ports[0] = state->io->in.port; + } + + state->creq = smb_composite_connectmulti_send(conn, state, + c->event_ctx); NT_STATUS_HAVE_NO_MEMORY(state->creq); state->stage = CONNECT_SOCKET; @@ -332,25 +358,27 @@ static void composite_handler(struct composite_context *creq) a function to establish a smbcli_tree from scratch */ struct composite_context *smb_composite_connect_send(struct smb_composite_connect *io, - struct event_context *event_ctx) + TALLOC_CTX *mem_ctx, + struct event_context *event_ctx) { struct composite_context *c; struct connect_state *state; struct nbt_name name; - c = talloc_zero(NULL, struct composite_context); + c = talloc_zero(mem_ctx, struct composite_context); if (c == NULL) goto failed; state = talloc(c, struct connect_state); if (state == NULL) goto failed; - state->sock = smbcli_sock_init(state, event_ctx); - if (state->sock == 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, state->sock->event.ctx); + c->event_ctx = talloc_reference(c, event_ctx); c->private_data = state; state->stage = CONNECT_RESOLVE; @@ -391,6 +419,6 @@ NTSTATUS smb_composite_connect_recv(struct composite_context *c, TALLOC_CTX *mem NTSTATUS smb_composite_connect(struct smb_composite_connect *io, TALLOC_CTX *mem_ctx, struct event_context *ev) { - struct composite_context *c = smb_composite_connect_send(io, ev); + struct composite_context *c = smb_composite_connect_send(io, mem_ctx, ev); return smb_composite_connect_recv(c, mem_ctx); } -- cgit From d617556ef50863d6a03c81a04f0f6b05848a250e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 10 Oct 2005 19:57:55 +0000 Subject: r10878: Reply to some comments by tridge and metze: * rename the composite helper functions from comp_* to composite_* * Move the lsa initialization to wb_connect_lsa.c * Equip smb_composite_connect with a fallback_to_anonymous The latter two simplify wb_init_domain.c quite a bit. Volker (This used to be commit deb127e04ea01ae93394da5ebffb39d81caeb6d9) --- source4/libcli/smb_composite/connect.c | 83 +++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 2 deletions(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 53cc8a9ac0..925d5ddb38 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -30,9 +30,10 @@ /* the stages of this call */ enum connect_stage {CONNECT_RESOLVE, CONNECT_SOCKET, - CONNECT_SESSION_REQUEST, + CONNECT_SESSION_REQUEST, CONNECT_NEGPROT, CONNECT_SESSION_SETUP, + CONNECT_SESSION_SETUP_ANON, CONNECT_TCON}; struct connect_state { @@ -101,7 +102,59 @@ static NTSTATUS connect_tcon(struct composite_context *c, /* - a session setup request has competed + a session setup request with anonymous fallback has completed +*/ +static NTSTATUS connect_session_setup_anon(struct composite_context *c, + struct smb_composite_connect *io) +{ + struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); + NTSTATUS status; + + status = smb_composite_sesssetup_recv(state->creq); + NT_STATUS_NOT_OK_RETURN(status); + + io->out.anonymous_fallback_done = True; + + state->session->vuid = state->io_setup->out.vuid; + + /* setup for a tconx */ + io->out.tree = smbcli_tree_init(state->session, state, True); + NT_STATUS_HAVE_NO_MEMORY(io->out.tree); + + state->io_tcon = talloc(c, union smb_tcon); + NT_STATUS_HAVE_NO_MEMORY(state->io_tcon); + + /* connect to a share using a tree connect */ + state->io_tcon->generic.level = RAW_TCON_TCONX; + state->io_tcon->tconx.in.flags = 0; + state->io_tcon->tconx.in.password = data_blob(NULL, 0); + + state->io_tcon->tconx.in.path = talloc_asprintf(state->io_tcon, + "\\\\%s\\%s", + io->in.called_name, + io->in.service); + NT_STATUS_HAVE_NO_MEMORY(state->io_tcon->tconx.in.path); + if (!io->in.service_type) { + state->io_tcon->tconx.in.device = "?????"; + } else { + state->io_tcon->tconx.in.device = io->in.service_type; + } + + state->req = smb_raw_tcon_send(io->out.tree, state->io_tcon); + NT_STATUS_HAVE_NO_MEMORY(state->req); + if (state->req->state == SMBCLI_REQUEST_ERROR) { + return state->req->status; + } + + state->req->async.fn = request_handler; + state->req->async.private = c; + state->stage = CONNECT_TCON; + + return NT_STATUS_OK; +} + +/* + a session setup request has completed */ static NTSTATUS connect_session_setup(struct composite_context *c, struct smb_composite_connect *io) @@ -110,6 +163,29 @@ static NTSTATUS connect_session_setup(struct composite_context *c, NTSTATUS status; status = smb_composite_sesssetup_recv(state->creq); + + if (!NT_STATUS_IS_OK(status) && + !cli_credentials_is_anonymous(state->io->in.credentials) && + io->in.fallback_to_anonymous) { + + state->io_setup->in.credentials = cli_credentials_init(state); + NT_STATUS_HAVE_NO_MEMORY(state->io_setup->in.credentials); + cli_credentials_set_conf(state->io_setup->in.credentials); + cli_credentials_set_anonymous(state->io_setup->in.credentials); + + state->creq = smb_composite_sesssetup_send(state->session, + state->io_setup); + NT_STATUS_HAVE_NO_MEMORY(state->creq); + if (state->creq->state == COMPOSITE_STATE_ERROR) { + return state->creq->status; + } + state->creq->async.fn = composite_handler; + state->creq->async.private_data = c; + state->stage = CONNECT_SESSION_SETUP_ANON; + + return NT_STATUS_OK; + } + NT_STATUS_NOT_OK_RETURN(status); state->session->vuid = state->io_setup->out.vuid; @@ -318,6 +394,9 @@ static void state_handler(struct composite_context *c) case CONNECT_SESSION_SETUP: c->status = connect_session_setup(c, state->io); break; + case CONNECT_SESSION_SETUP_ANON: + c->status = connect_session_setup_anon(c, state->io); + break; case CONNECT_TCON: c->status = connect_tcon(c, state->io); break; -- cgit From df30ef140d24863b849eaa81624509fabd663ee7 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 21 Oct 2005 19:31:36 +0000 Subject: r11248: Fix anon fallback with spnego (This used to be commit 13ebdea11532f4810d01095a54d430c36c91d826) --- source4/libcli/smb_composite/connect.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 925d5ddb38..466d86233a 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -173,6 +173,11 @@ static NTSTATUS connect_session_setup(struct composite_context *c, cli_credentials_set_conf(state->io_setup->in.credentials); cli_credentials_set_anonymous(state->io_setup->in.credentials); + /* If the preceding attempt was with extended security, we + * have been given a uid in the NTLMSSP_CHALLENGE reply. This + * would lead to an invalid uid in the anonymous fallback */ + state->session->vuid = 0; + state->creq = smb_composite_sesssetup_send(state->session, state->io_setup); NT_STATUS_HAVE_NO_MEMORY(state->creq); -- cgit From 3608b6af426c99eaa99f366d556018193a1aaa2d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 23 Oct 2005 11:23:55 +0000 Subject: r11264: Winbind does not rely on the hostname resolution mechanisms of composite_connect, so in io.in.dest_host I'm setting the IP address. Gensec does not like that as a target hostname, so if a called name is present, use that. So we can session setup using kerberos now. Volker (This used to be commit c26b432c27954c8dc6ac8e702bd5e34a351d15bd) --- source4/libcli/smb_composite/connect.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 466d86233a..4e9ee48cb7 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -355,7 +355,11 @@ static NTSTATUS connect_resolve(struct composite_context *c, conn->in.hostnames = talloc_array(state->conn, const char *, 1); NT_STATUS_HAVE_NO_MEMORY(conn->in.hostnames); - conn->in.hostnames[0] = state->io->in.dest_host; + if (state->io->in.called_name != NULL) { + conn->in.hostnames[0] = state->io->in.called_name; + } else { + conn->in.hostnames[0] = state->io->in.dest_host; + } conn->in.ports = NULL; if (state->io->in.port != 0) { -- cgit From 134b2488c82ae13392121f71e4960178a38f3e01 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 28 Oct 2005 11:02:42 +0000 Subject: r11369: Implement socket_connect_multi: Connect to multiple ipv4 tcp ports in sequence, with a 2-millisecond timeout between firing the syn packets. Build smbcli_sock_connect_send upon that. Volker (This used to be commit 5718df44d90d113304c5deed1e2e7f82ff9e928f) --- source4/libcli/smb_composite/connect.c | 42 ++++++---------------------------- 1 file changed, 7 insertions(+), 35 deletions(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 4e9ee48cb7..643871a8c4 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -41,7 +41,6 @@ struct connect_state { struct smbcli_socket *sock; struct smbcli_transport *transport; struct smbcli_session *session; - struct smb_composite_connectmulti *conn; struct smb_composite_connect *io; union smb_tcon *io_tcon; struct smb_composite_sesssetup *io_setup; @@ -73,7 +72,7 @@ static NTSTATUS connect_send_negprot(struct composite_context *c, /* - a tree connect request has competed + a tree connect request has completed */ static NTSTATUS connect_tcon(struct composite_context *c, struct smb_composite_connect *io) @@ -232,7 +231,7 @@ static NTSTATUS connect_session_setup(struct composite_context *c, } /* - a negprot request has competed + a negprot request has completed */ static NTSTATUS connect_negprot(struct composite_context *c, struct smb_composite_connect *io) @@ -271,7 +270,7 @@ static NTSTATUS connect_negprot(struct composite_context *c, /* - a session request operation has competed + a session request operation has completed */ static NTSTATUS connect_session_request(struct composite_context *c, struct smb_composite_connect *io) @@ -287,7 +286,7 @@ static NTSTATUS connect_session_request(struct composite_context *c, } /* - a socket connection operation has competed + a socket connection operation has completed */ static NTSTATUS connect_socket(struct composite_context *c, struct smb_composite_connect *io) @@ -296,11 +295,9 @@ static NTSTATUS connect_socket(struct composite_context *c, NTSTATUS status; struct nbt_name calling, called; - status = smb_composite_connectmulti_recv(state->creq, state); + status = smbcli_sock_connect_recv(state->creq, state, &state->sock); NT_STATUS_NOT_OK_RETURN(status); - state->sock = state->conn->out.socket; - /* the socket is up - we can initialise the smbcli transport layer */ state->transport = smbcli_transport_init(state->sock, state, True); NT_STATUS_HAVE_NO_MEMORY(state->transport); @@ -339,37 +336,12 @@ static NTSTATUS connect_resolve(struct composite_context *c, struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); NTSTATUS status; const char *address; - struct smb_composite_connectmulti *conn; status = resolve_name_recv(state->creq, state, &address); NT_STATUS_NOT_OK_RETURN(status); - conn = talloc(state, struct smb_composite_connectmulti); - NT_STATUS_HAVE_NO_MEMORY(conn); - state->conn = conn; - conn->in.num_dests = 1; - - conn->in.addresses = talloc_array(state->conn, const char *, 1); - NT_STATUS_HAVE_NO_MEMORY(conn->in.addresses); - conn->in.addresses[0] = address; - - conn->in.hostnames = talloc_array(state->conn, const char *, 1); - NT_STATUS_HAVE_NO_MEMORY(conn->in.hostnames); - if (state->io->in.called_name != NULL) { - conn->in.hostnames[0] = state->io->in.called_name; - } else { - conn->in.hostnames[0] = state->io->in.dest_host; - } - - conn->in.ports = NULL; - if (state->io->in.port != 0) { - conn->in.ports = talloc_array(state->conn, int, 1); - NT_STATUS_HAVE_NO_MEMORY(conn->in.ports); - conn->in.ports[0] = state->io->in.port; - } - - state->creq = smb_composite_connectmulti_send(conn, state, - c->event_ctx); + state->creq = smbcli_sock_connect_send(state, address, io->in.port, + io->in.dest_host, c->event_ctx); NT_STATUS_HAVE_NO_MEMORY(state->creq); state->stage = CONNECT_SOCKET; -- cgit From 08964b9de8e3e28ae15000f03c2a9f5223ff8007 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 6 Nov 2005 12:19:34 +0000 Subject: r11532: Enable kerberos session setup for winbind smb connections (This used to be commit f0e4075db5e913d2262058bb7234c446160823d9) --- source4/libcli/smb_composite/connect.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 643871a8c4..81a82ad427 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -302,6 +302,15 @@ static NTSTATUS connect_socket(struct composite_context *c, state->transport = smbcli_transport_init(state->sock, state, True); NT_STATUS_HAVE_NO_MEMORY(state->transport); + if (state->io->in.called_name != NULL) { + /* If connecting to an IP address, we might want the real name + * of the host for later kerberos. The called name is a better + * approximation */ + state->sock->hostname = + talloc_strdup(state->sock, io->in.called_name); + NT_STATUS_HAVE_NO_MEMORY(state->sock->hostname); + } + make_nbt_name_client(&calling, cli_credentials_get_workstation(io->in.credentials)); nbt_choose_called_name(state, &called, io->in.called_name, NBT_NAME_SERVER); -- cgit From 0ed6a35f000c3cc0856adce126d08d7a26d138e3 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 6 Nov 2005 12:24:33 +0000 Subject: r11533: Be a bit less intrusive (This used to be commit f341c8b4c8e8b8096c604b5842b9b7f7c4c9653c) --- source4/libcli/smb_composite/connect.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 81a82ad427..785b0d076b 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -302,7 +302,8 @@ static NTSTATUS connect_socket(struct composite_context *c, state->transport = smbcli_transport_init(state->sock, state, True); NT_STATUS_HAVE_NO_MEMORY(state->transport); - if (state->io->in.called_name != NULL) { + if (is_ipaddress(state->sock->hostname) && + (state->io->in.called_name != NULL)) { /* If connecting to an IP address, we might want the real name * of the host for later kerberos. The called name is a better * approximation */ -- cgit From 2cd5ca7d25f12aa9198bf8c2deb6aea282f573ee Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 28 Dec 2005 15:38:36 +0000 Subject: r12542: Move some more prototypes out to seperate headers (This used to be commit 0aca5fd5130d980d07398f3291d294202aefe3c2) --- source4/libcli/smb_composite/connect.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 785b0d076b..4191c43ca6 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -26,6 +26,7 @@ #include "libcli/composite/composite.h" #include "libcli/smb_composite/smb_composite.h" #include "lib/events/events.h" +#include "libcli/nbt/libnbt.h" /* the stages of this call */ enum connect_stage {CONNECT_RESOLVE, -- cgit From d4de4c2d210d2e8c9b5aedf70695594809ad6a0b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 Dec 2005 13:16:54 +0000 Subject: r12608: Remove some unused #include lines. (This used to be commit 70e7449318aa0e9d2639c76730a7d1683b2f4981) --- source4/libcli/smb_composite/connect.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 4191c43ca6..785b0d076b 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -26,7 +26,6 @@ #include "libcli/composite/composite.h" #include "libcli/smb_composite/smb_composite.h" #include "lib/events/events.h" -#include "libcli/nbt/libnbt.h" /* the stages of this call */ enum connect_stage {CONNECT_RESOLVE, -- cgit From 4ac2be99588b48b0652a524bf12fb1aa9c3f5fbb Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 7 Mar 2006 11:07:23 +0000 Subject: r13924: Split more prototypes out of include/proto.h + initial work on header file dependencies (This used to be commit 122835876748a3eaf5e8d31ad1abddab9acb8781) --- source4/libcli/smb_composite/connect.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 785b0d076b..07da2d363a 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -26,6 +26,7 @@ #include "libcli/composite/composite.h" #include "libcli/smb_composite/smb_composite.h" #include "lib/events/events.h" +#include "libcli/resolve/resolve.h" /* the stages of this call */ enum connect_stage {CONNECT_RESOLVE, -- cgit From 3f16241a1d3243447d0244ebac05b447aec94df8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 14 Mar 2006 01:29:56 +0000 Subject: r14363: Remove credentials.h from the global includes. (This used to be commit 98c4c3051391c6f89df5d133665f51bef66b1563) --- source4/libcli/smb_composite/connect.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 07da2d363a..b36e37a1a4 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -27,6 +27,7 @@ #include "libcli/smb_composite/smb_composite.h" #include "lib/events/events.h" #include "libcli/resolve/resolve.h" +#include "auth/credentials/credentials.h" /* the stages of this call */ enum connect_stage {CONNECT_RESOLVE, -- cgit From 8528016978b084213ef53d66e1b6e831b1a01acc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 16 Mar 2006 00:23:11 +0000 Subject: r14464: Don't include ndr_BASENAME.h files unless strictly required, instead try to include just the BASENAME.h files (containing only structs) (This used to be commit 3dd477ca5147f28a962b8437e2611a8222d706bd) --- source4/libcli/smb_composite/connect.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index b36e37a1a4..a28d33cf7f 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -28,6 +28,7 @@ #include "lib/events/events.h" #include "libcli/resolve/resolve.h" #include "auth/credentials/credentials.h" +#include "librpc/gen_ndr/ndr_nbt.h" /* the stages of this call */ enum connect_stage {CONNECT_RESOLVE, -- cgit From 7bf085571eba5f321d35ff449d68da39ec303dab Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 22 Jun 2006 17:06:36 +0000 Subject: r16464: split client and server min/max protocol settings metze (This used to be commit 6164d1e22e0545f558315591d49f862de06ea945) --- source4/libcli/smb_composite/connect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index a28d33cf7f..7d4960d7d5 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -63,7 +63,7 @@ static NTSTATUS connect_send_negprot(struct composite_context *c, { struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); - state->req = smb_raw_negotiate_send(state->transport, lp_maxprotocol()); + state->req = smb_raw_negotiate_send(state->transport, lp_cli_maxprotocol()); NT_STATUS_HAVE_NO_MEMORY(state->req); state->req->async.fn = request_handler; -- cgit From 9b97c4d02e5391f5e5df10468c3a5f428e49d955 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 24 Oct 2006 16:14:00 +0000 Subject: r19480: - clear the whole session struct (only let the pid untouched) - zero state struct metze (This used to be commit 97fb407a4cfcf71e95663e437cb7f638ac4028fc) --- source4/libcli/smb_composite/connect.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 7d4960d7d5..fc788d5d31 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -179,6 +179,9 @@ static NTSTATUS connect_session_setup(struct composite_context *c, * have been given a uid in the NTLMSSP_CHALLENGE reply. This * would lead to an invalid uid in the anonymous fallback */ state->session->vuid = 0; + data_blob_free(&state->session->user_session_key); + talloc_free(state->session->gensec); + state->session->gensec = NULL; state->creq = smb_composite_sesssetup_send(state->session, state->io_setup); @@ -441,7 +444,7 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec c = talloc_zero(mem_ctx, struct composite_context); if (c == NULL) goto failed; - state = talloc(c, struct connect_state); + state = talloc_zero(c, struct connect_state); if (state == NULL) goto failed; if (event_ctx == NULL) { -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/libcli/smb_composite/connect.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index fc788d5d31..026fe0b029 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -5,7 +5,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ /* a composite API for making a full SMB connection -- cgit From ffeee68e4b72dd94fee57366bd8d38b8c284c3d4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 12:42:09 +0000 Subject: r25026: Move param/param.h out of includes.h (This used to be commit abe8349f9b4387961ff3665d8c589d61cd2edf31) --- source4/libcli/smb_composite/connect.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 026fe0b029..27b16ecc41 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -28,6 +28,7 @@ #include "libcli/resolve/resolve.h" #include "auth/credentials/credentials.h" #include "librpc/gen_ndr/ndr_nbt.h" +#include "param/param.h" /* the stages of this call */ enum connect_stage {CONNECT_RESOLVE, -- cgit From 37d53832a4623653f706e77985a79d84bd7c6694 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 28 Sep 2007 01:17:46 +0000 Subject: r25398: Parse loadparm context to all lp_*() functions. (This used to be commit 3fcc960839c6e5ca4de2c3c042f12f369ac5f238) --- source4/libcli/smb_composite/connect.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 27b16ecc41..22b2cdb0e2 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -63,7 +63,7 @@ static NTSTATUS connect_send_negprot(struct composite_context *c, { struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); - state->req = smb_raw_negotiate_send(state->transport, lp_cli_maxprotocol()); + state->req = smb_raw_negotiate_send(state->transport, lp_cli_maxprotocol(global_loadparm)); NT_STATUS_HAVE_NO_MEMORY(state->req); state->req->async.fn = request_handler; @@ -172,7 +172,7 @@ static NTSTATUS connect_session_setup(struct composite_context *c, state->io_setup->in.credentials = cli_credentials_init(state); NT_STATUS_HAVE_NO_MEMORY(state->io_setup->in.credentials); - cli_credentials_set_conf(state->io_setup->in.credentials); + cli_credentials_set_conf(state->io_setup->in.credentials, global_loadparm); cli_credentials_set_anonymous(state->io_setup->in.credentials); /* If the preceding attempt was with extended security, we @@ -459,7 +459,7 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec state->stage = CONNECT_RESOLVE; make_nbt_name_server(&name, io->in.dest_host); - state->creq = resolve_name_send(&name, c->event_ctx, lp_name_resolve_order()); + state->creq = resolve_name_send(&name, c->event_ctx, lp_name_resolve_order(global_loadparm)); if (state->creq == NULL) goto failed; state->creq->async.private_data = c; -- cgit From 2f3551ca7cee59d4d053cceb87abdf1da1b3a1ad Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 1 Oct 2007 18:52:55 +0000 Subject: r25446: Merge some changes I made on the way home from SFO: 2007-09-29 More higher-level passing around of lp_ctx. 2007-09-29 Fix warning. 2007-09-29 Pass loadparm contexts on a higher level. 2007-09-29 Avoid using global loadparm context. (This used to be commit 3468952e771ab31f90b6c374ade01c5550810f42) --- source4/libcli/smb_composite/connect.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 22b2cdb0e2..23974619d6 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -63,7 +63,8 @@ static NTSTATUS connect_send_negprot(struct composite_context *c, { struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); - state->req = smb_raw_negotiate_send(state->transport, lp_cli_maxprotocol(global_loadparm)); + state->req = smb_raw_negotiate_send(state->transport, + lp_cli_maxprotocol(global_loadparm)); NT_STATUS_HAVE_NO_MEMORY(state->req); state->req->async.fn = request_handler; @@ -172,7 +173,8 @@ static NTSTATUS connect_session_setup(struct composite_context *c, state->io_setup->in.credentials = cli_credentials_init(state); NT_STATUS_HAVE_NO_MEMORY(state->io_setup->in.credentials); - cli_credentials_set_conf(state->io_setup->in.credentials, global_loadparm); + cli_credentials_set_conf(state->io_setup->in.credentials, + global_loadparm); cli_credentials_set_anonymous(state->io_setup->in.credentials); /* If the preceding attempt was with extended security, we @@ -459,7 +461,8 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec state->stage = CONNECT_RESOLVE; make_nbt_name_server(&name, io->in.dest_host); - state->creq = resolve_name_send(&name, c->event_ctx, lp_name_resolve_order(global_loadparm)); + state->creq = resolve_name_send(&name, c->event_ctx, + lp_name_resolve_order(global_loadparm)); if (state->creq == NULL) goto failed; state->creq->async.private_data = c; -- cgit From 2151cde58014ea2e822c13d2f8a369b45dc19ca8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Oct 2007 22:28:14 +0000 Subject: r25554: Convert last instances of BOOL, True and False to the standard types. (This used to be commit 566aa14139510788548a874e9213d91317f83ca9) --- source4/libcli/smb_composite/connect.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 23974619d6..9f18c0d924 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -116,12 +116,12 @@ static NTSTATUS connect_session_setup_anon(struct composite_context *c, status = smb_composite_sesssetup_recv(state->creq); NT_STATUS_NOT_OK_RETURN(status); - io->out.anonymous_fallback_done = True; + io->out.anonymous_fallback_done = true; state->session->vuid = state->io_setup->out.vuid; /* setup for a tconx */ - io->out.tree = smbcli_tree_init(state->session, state, True); + io->out.tree = smbcli_tree_init(state->session, state, true); NT_STATUS_HAVE_NO_MEMORY(io->out.tree); state->io_tcon = talloc(c, union smb_tcon); @@ -203,7 +203,7 @@ static NTSTATUS connect_session_setup(struct composite_context *c, state->session->vuid = state->io_setup->out.vuid; /* setup for a tconx */ - io->out.tree = smbcli_tree_init(state->session, state, True); + io->out.tree = smbcli_tree_init(state->session, state, true); NT_STATUS_HAVE_NO_MEMORY(io->out.tree); state->io_tcon = talloc(c, union smb_tcon); @@ -251,7 +251,7 @@ static NTSTATUS connect_negprot(struct composite_context *c, NT_STATUS_NOT_OK_RETURN(status); /* next step is a session setup */ - state->session = smbcli_session_init(state->transport, state, True); + state->session = smbcli_session_init(state->transport, state, true); NT_STATUS_HAVE_NO_MEMORY(state->session); state->io_setup = talloc(c, struct smb_composite_sesssetup); @@ -307,7 +307,7 @@ static NTSTATUS connect_socket(struct composite_context *c, NT_STATUS_NOT_OK_RETURN(status); /* the socket is up - we can initialise the smbcli transport layer */ - state->transport = smbcli_transport_init(state->sock, state, True); + state->transport = smbcli_transport_init(state->sock, state, true); NT_STATUS_HAVE_NO_MEMORY(state->transport); if (is_ipaddress(state->sock->hostname) && -- cgit From 6c999cd12344f2bb8b1d2941210b4c205b3e0aad Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 2 Dec 2007 22:32:11 +0100 Subject: r26236: Remove more uses of global_loadparm or specify loadparm_context explicitly. (This used to be commit 5b29ef7c03d9ae76b0ca909e9f03a58e1bad3521) --- source4/libcli/smb_composite/connect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 9f18c0d924..0238d5c550 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -63,7 +63,7 @@ static NTSTATUS connect_send_negprot(struct composite_context *c, { struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); - state->req = smb_raw_negotiate_send(state->transport, + state->req = smb_raw_negotiate_send(state->transport, lp_unicode(global_loadparm), lp_cli_maxprotocol(global_loadparm)); NT_STATUS_HAVE_NO_MEMORY(state->req); -- cgit From 2f8dc4f48f1802baa3405e7803563f6840e0d1b3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 3 Dec 2007 21:25:06 +0100 Subject: r26266: Remove more global_loadparm uses. (This used to be commit 99113075c4a96679bcec4f4d6bba4acb3dee4245) --- source4/libcli/smb_composite/connect.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 0238d5c550..9579cd20b5 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -307,7 +307,9 @@ static NTSTATUS connect_socket(struct composite_context *c, NT_STATUS_NOT_OK_RETURN(status); /* the socket is up - we can initialise the smbcli transport layer */ - state->transport = smbcli_transport_init(state->sock, state, true); + state->transport = smbcli_transport_init(state->sock, state, true, + lp_max_xmit(global_loadparm), + lp_maxmux(global_loadparm)); NT_STATUS_HAVE_NO_MEMORY(state->transport); if (is_ipaddress(state->sock->hostname) && -- cgit From 5f4842cf65ce64bfdf577cd549565da20ca818cf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 10 Dec 2007 18:41:19 +0100 Subject: r26376: Add context for libcli_resolve. (This used to be commit 459e1466a411d6f83b7372e248566e6e71c745fc) --- source4/libcli/smb_composite/connect.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 9579cd20b5..1a8262c76a 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -463,8 +463,7 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec state->stage = CONNECT_RESOLVE; make_nbt_name_server(&name, io->in.dest_host); - state->creq = resolve_name_send(&name, c->event_ctx, - lp_name_resolve_order(global_loadparm)); + state->creq = resolve_name_send(lp_resolve_context(global_loadparm), &name, c->event_ctx); if (state->creq == NULL) goto failed; state->creq->async.private_data = c; -- cgit From 4b0199a5493ea2b88558cc40871e63c1dc8dbb56 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 12 Dec 2007 02:15:29 +0100 Subject: r26409: Pass smb ports along. (This used to be commit 2833f320de1f1fd39c710ad0a61c3fa1bb1df31f) --- source4/libcli/smb_composite/connect.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 1a8262c76a..fafd3b0173 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -360,7 +360,8 @@ static NTSTATUS connect_resolve(struct composite_context *c, status = resolve_name_recv(state->creq, state, &address); NT_STATUS_NOT_OK_RETURN(status); - state->creq = smbcli_sock_connect_send(state, address, io->in.port, + state->creq = smbcli_sock_connect_send(state, address, + io->in.dest_ports, io->in.dest_host, c->event_ctx); NT_STATUS_HAVE_NO_MEMORY(state->creq); -- cgit From 771b347f9b185895390445be96081c781e28a26d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Jan 2008 18:39:01 -0600 Subject: r26644: Janitorial: Pass resolve_context explicitly to various SMB functions, should help fix the build for OpenChange. (This used to be commit 385ffe4f4cc9a21a760c0f00410f56e2592fd507) --- source4/libcli/smb_composite/connect.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index fafd3b0173..b71cfc2c19 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -309,7 +309,8 @@ static NTSTATUS connect_socket(struct composite_context *c, /* the socket is up - we can initialise the smbcli transport layer */ state->transport = smbcli_transport_init(state->sock, state, true, lp_max_xmit(global_loadparm), - lp_maxmux(global_loadparm)); + lp_maxmux(global_loadparm), + lp_use_spnego(global_loadparm) && lp_nt_status_support(global_loadparm)); NT_STATUS_HAVE_NO_MEMORY(state->transport); if (is_ipaddress(state->sock->hostname) && @@ -362,7 +363,8 @@ static NTSTATUS connect_resolve(struct composite_context *c, state->creq = smbcli_sock_connect_send(state, address, io->in.dest_ports, - io->in.dest_host, c->event_ctx); + io->in.dest_host, + NULL, c->event_ctx); NT_STATUS_HAVE_NO_MEMORY(state->creq); state->stage = CONNECT_SOCKET; @@ -440,6 +442,7 @@ static void composite_handler(struct composite_context *creq) */ struct composite_context *smb_composite_connect_send(struct smb_composite_connect *io, TALLOC_CTX *mem_ctx, + struct resolve_context *resolve_ctx, struct event_context *event_ctx) { struct composite_context *c; @@ -464,7 +467,7 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec state->stage = CONNECT_RESOLVE; make_nbt_name_server(&name, io->in.dest_host); - state->creq = resolve_name_send(lp_resolve_context(global_loadparm), &name, c->event_ctx); + state->creq = resolve_name_send(resolve_ctx, &name, c->event_ctx); if (state->creq == NULL) goto failed; state->creq->async.private_data = c; @@ -498,8 +501,9 @@ NTSTATUS smb_composite_connect_recv(struct composite_context *c, TALLOC_CTX *mem sync version of smb_composite_connect */ NTSTATUS smb_composite_connect(struct smb_composite_connect *io, TALLOC_CTX *mem_ctx, + struct resolve_context *resolve_ctx, struct event_context *ev) { - struct composite_context *c = smb_composite_connect_send(io, mem_ctx, ev); + struct composite_context *c = smb_composite_connect_send(io, mem_ctx, resolve_ctx, ev); return smb_composite_connect_recv(c, mem_ctx); } -- cgit From 969b8579c755441092e27b499ecedbd7d725816d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Jan 2008 18:39:15 -0600 Subject: r26646: libcli/smb_composite: Allow specifying SMB parameters in smb_composite_connect structure. AFAIK no global variables will now be used when doing RPC client connections. (This used to be commit 0ef75e4e3cb0e1bd10e367a00f5e9b725587c40a) --- source4/libcli/smb_composite/connect.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index b71cfc2c19..bdefe39b71 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -63,8 +63,7 @@ static NTSTATUS connect_send_negprot(struct composite_context *c, { struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); - state->req = smb_raw_negotiate_send(state->transport, lp_unicode(global_loadparm), - lp_cli_maxprotocol(global_loadparm)); + state->req = smb_raw_negotiate_send(state->transport, io->in.unicode, io->in.max_protocol); NT_STATUS_HAVE_NO_MEMORY(state->req); state->req->async.fn = request_handler; @@ -308,9 +307,9 @@ static NTSTATUS connect_socket(struct composite_context *c, /* the socket is up - we can initialise the smbcli transport layer */ state->transport = smbcli_transport_init(state->sock, state, true, - lp_max_xmit(global_loadparm), - lp_maxmux(global_loadparm), - lp_use_spnego(global_loadparm) && lp_nt_status_support(global_loadparm)); + io->in.max_xmit, + io->in.max_mux, + io->in.use_spnego); NT_STATUS_HAVE_NO_MEMORY(state->transport); if (is_ipaddress(state->sock->hostname) && -- cgit From 425732f688865ebe2bfe568c8278edec50cbdedf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 3 Jan 2008 17:21:58 -0600 Subject: r26651: libsmb: Allow specifying signing policy from higher up. The number of arguments is getting a bit excessive now, so it probably makes sense to pass in the smbcli_options struct rather than all members individually and add a convenience function for obtaining a smbcli_options struct from a loadparm context. (This used to be commit 9f64213463b5bf3bcbf36913139e9a5042e967a2) --- source4/libcli/smb_composite/connect.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index bdefe39b71..e45a8a25f9 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -309,7 +309,8 @@ static NTSTATUS connect_socket(struct composite_context *c, state->transport = smbcli_transport_init(state->sock, state, true, io->in.max_xmit, io->in.max_mux, - io->in.use_spnego); + io->in.use_spnego, + io->in.signing); NT_STATUS_HAVE_NO_MEMORY(state->transport); if (is_ipaddress(state->sock->hostname) && -- cgit From dcc282590b34537fc1ead61c3300172528273b44 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 3 Jan 2008 17:22:12 -0600 Subject: r26654: libcli/smb_composite: Rather than specifying each of the gazillion options for SMB individually, just specify the smbcli_options struct. (This used to be commit 8a97886e24a4b969aa91409c06f423b71a45f6eb) --- source4/libcli/smb_composite/connect.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index e45a8a25f9..a44765e980 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -63,7 +63,7 @@ static NTSTATUS connect_send_negprot(struct composite_context *c, { struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); - state->req = smb_raw_negotiate_send(state->transport, io->in.unicode, io->in.max_protocol); + state->req = smb_raw_negotiate_send(state->transport, io->in.options.unicode, io->in.options.max_protocol); NT_STATUS_HAVE_NO_MEMORY(state->req); state->req->async.fn = request_handler; @@ -307,10 +307,7 @@ static NTSTATUS connect_socket(struct composite_context *c, /* the socket is up - we can initialise the smbcli transport layer */ state->transport = smbcli_transport_init(state->sock, state, true, - io->in.max_xmit, - io->in.max_mux, - io->in.use_spnego, - io->in.signing); + &io->in.options); NT_STATUS_HAVE_NO_MEMORY(state->transport); if (is_ipaddress(state->sock->hostname) && -- cgit From b7e34eb62580565d1526f793b5df8b26cdd65aa4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 5 Jan 2008 19:33:11 -0600 Subject: r26674: smb_composite: Avoid use of global_loadparm. Hopefully this fixes OpenChange's mapiadmin. (This used to be commit 2df0f7016e27705c3799b2f6bb20fcc17b103c36) --- source4/libcli/smb_composite/connect.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index a44765e980..22573442a2 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -172,8 +172,9 @@ static NTSTATUS connect_session_setup(struct composite_context *c, state->io_setup->in.credentials = cli_credentials_init(state); NT_STATUS_HAVE_NO_MEMORY(state->io_setup->in.credentials); - cli_credentials_set_conf(state->io_setup->in.credentials, - global_loadparm); + cli_credentials_set_workstation(state->io_setup->in.credentials, + cli_credentials_get_workstation(state->io->in.credentials), + CRED_SPECIFIED); cli_credentials_set_anonymous(state->io_setup->in.credentials); /* If the preceding attempt was with extended security, we -- cgit From afe3e8172ddaa5e4aa811faceecda4f943d6e2ef Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Apr 2008 04:53:27 +0200 Subject: Install public header files again and include required prototypes. (This used to be commit 47ffbbf67435904754469544390b67d34c958343) --- source4/libcli/smb_composite/connect.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 22573442a2..c44c62f868 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -22,6 +22,7 @@ #include "includes.h" #include "libcli/raw/libcliraw.h" +#include "libcli/raw/raw_proto.h" #include "libcli/composite/composite.h" #include "libcli/smb_composite/smb_composite.h" #include "lib/events/events.h" -- cgit From 4e83011f72ba3df387512755a17760b42a7bf2f2 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 21 Apr 2008 17:58:23 -0400 Subject: Remove more event_context_init() uses from function calls within deep down the code. Make sure we pass around the event_context where we need it instead. All test but a few python ones fail. Jelmer promised to fix them. (This used to be commit 3045d391626fba169aa26be52174883e18d323e9) --- source4/libcli/smb_composite/connect.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'source4/libcli/smb_composite/connect.c') 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; -- cgit From c4219fd8030494986c5fa418c46defb1a9c05c7e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 25 Apr 2008 15:08:52 +0100 Subject: Make the composite 'connect to server' code useful for security=server The ability to short-circuit the connection code to only do a negprot allows us to do the rest once we have the user's password. We return the 8 byte challenge so we can pass it to the client. Andrew Bartlett (This used to be commit 40fe386b0374df8b390b995c332d048dbbc08f1b) --- source4/libcli/smb_composite/connect.c | 42 +++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 11 deletions(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index c4abfa5e37..4400c61a81 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -38,7 +38,9 @@ enum connect_stage {CONNECT_RESOLVE, CONNECT_NEGPROT, CONNECT_SESSION_SETUP, CONNECT_SESSION_SETUP_ANON, - CONNECT_TCON}; + CONNECT_TCON, + CONNECT_DONE +}; struct connect_state { enum connect_stage stage; @@ -97,8 +99,7 @@ static NTSTATUS connect_tcon(struct composite_context *c, state->io_tcon->tconx.out.fs_type); } - /* all done! */ - c->state = COMPOSITE_STATE_DONE; + state->stage = CONNECT_DONE; return NT_STATUS_OK; } @@ -203,6 +204,13 @@ static NTSTATUS connect_session_setup(struct composite_context *c, state->session->vuid = state->io_setup->out.vuid; + /* If we don't have a remote share name then this indicates that + * we don't want to do a tree connect */ + if (!io->in.service) { + state->stage = CONNECT_DONE; + return NT_STATUS_OK; + } + /* setup for a tconx */ io->out.tree = smbcli_tree_init(state->session, state, true); NT_STATUS_HAVE_NO_MEMORY(io->out.tree); @@ -251,10 +259,23 @@ static NTSTATUS connect_negprot(struct composite_context *c, status = smb_raw_negotiate_recv(state->req); NT_STATUS_NOT_OK_RETURN(status); + if (!(state->transport->negotiate.capabilities & CAP_EXTENDED_SECURITY)) { + io->out.negprot_challenge = state->transport->negotiate.secblob; + } else { + io->out.negprot_challenge = data_blob(NULL, 0); + } + + /* If we don't have any credentials then this indicates that + * we don't want to do a session setup */ + if (!io->in.credentials) { + state->stage = CONNECT_DONE; + return NT_STATUS_OK; + } + /* next step is a session setup */ state->session = smbcli_session_init(state->transport, state, true); NT_STATUS_HAVE_NO_MEMORY(state->session); - + state->io_setup = talloc(c, struct smb_composite_sesssetup); NT_STATUS_HAVE_NO_MEMORY(state->io_setup); @@ -272,6 +293,7 @@ static NTSTATUS connect_negprot(struct composite_context *c, state->creq->async.fn = composite_handler; state->creq->async.private_data = c; + state->stage = CONNECT_SESSION_SETUP; return NT_STATUS_OK; @@ -405,13 +427,11 @@ static void state_handler(struct composite_context *c) break; } - if (!NT_STATUS_IS_OK(c->status)) { - c->state = COMPOSITE_STATE_ERROR; - } - - if (c->state >= COMPOSITE_STATE_DONE && - c->async.fn) { - c->async.fn(c); + if (state->stage == CONNECT_DONE) { + /* all done! */ + composite_done(c); + } else { + composite_is_ok(c); } } -- cgit From 35e45534c64930a0f22c5975c64be41d96265a00 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 25 Apr 2008 15:59:22 +0100 Subject: Revert to using the old CIFS connection API. Rather than add a new 'out' member to the API, simply fill in the 'tree' early enough that we can access the server challenge there. Andrew Bartlett (This used to be commit 6dbbcf8aaf9b93af970d1701dfb185460d4dc788) --- source4/libcli/smb_composite/connect.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 4400c61a81..39c614f042 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -122,9 +122,6 @@ static NTSTATUS connect_session_setup_anon(struct composite_context *c, state->session->vuid = state->io_setup->out.vuid; /* setup for a tconx */ - io->out.tree = smbcli_tree_init(state->session, state, true); - NT_STATUS_HAVE_NO_MEMORY(io->out.tree); - state->io_tcon = talloc(c, union smb_tcon); NT_STATUS_HAVE_NO_MEMORY(state->io_tcon); @@ -211,10 +208,6 @@ static NTSTATUS connect_session_setup(struct composite_context *c, return NT_STATUS_OK; } - /* setup for a tconx */ - io->out.tree = smbcli_tree_init(state->session, state, true); - NT_STATUS_HAVE_NO_MEMORY(io->out.tree); - state->io_tcon = talloc(c, union smb_tcon); NT_STATUS_HAVE_NO_MEMORY(state->io_tcon); @@ -259,11 +252,14 @@ static NTSTATUS connect_negprot(struct composite_context *c, status = smb_raw_negotiate_recv(state->req); NT_STATUS_NOT_OK_RETURN(status); - if (!(state->transport->negotiate.capabilities & CAP_EXTENDED_SECURITY)) { - io->out.negprot_challenge = state->transport->negotiate.secblob; - } else { - io->out.negprot_challenge = data_blob(NULL, 0); - } + /* next step is a session setup */ + state->session = smbcli_session_init(state->transport, state, true); + NT_STATUS_HAVE_NO_MEMORY(state->session); + + /* setup for a tconx (or at least have the structure ready to + * return, if we won't go that far) */ + io->out.tree = smbcli_tree_init(state->session, state, true); + NT_STATUS_HAVE_NO_MEMORY(io->out.tree); /* If we don't have any credentials then this indicates that * we don't want to do a session setup */ @@ -272,10 +268,6 @@ static NTSTATUS connect_negprot(struct composite_context *c, return NT_STATUS_OK; } - /* next step is a session setup */ - state->session = smbcli_session_init(state->transport, state, true); - NT_STATUS_HAVE_NO_MEMORY(state->session); - state->io_setup = talloc(c, struct smb_composite_sesssetup); NT_STATUS_HAVE_NO_MEMORY(state->io_setup); -- cgit From f8fb5d8c4da11cdb8ac79649fd74047d4cc42c68 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 5 May 2008 12:57:23 +1000 Subject: Reorder this function in the file, so it reads bottom-up. The rest of this file reads bottom-up, but this function (connect_send_negprot()) was out of place. Andrew Bartlett (This used to be commit f0c95cd74fb6fea57cef89b59e5d2f10ea25c138) --- source4/libcli/smb_composite/connect.c | 37 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'source4/libcli/smb_composite/connect.c') diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index 39c614f042..e56339f96b 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -58,25 +58,6 @@ struct connect_state { static void request_handler(struct smbcli_request *); static void composite_handler(struct composite_context *); -/* - setup a negprot send -*/ -static NTSTATUS connect_send_negprot(struct composite_context *c, - struct smb_composite_connect *io) -{ - struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); - - state->req = smb_raw_negotiate_send(state->transport, io->in.options.unicode, io->in.options.max_protocol); - NT_STATUS_HAVE_NO_MEMORY(state->req); - - state->req->async.fn = request_handler; - state->req->async.private = c; - state->stage = CONNECT_NEGPROT; - - return NT_STATUS_OK; -} - - /* a tree connect request has completed */ @@ -291,6 +272,24 @@ static NTSTATUS connect_negprot(struct composite_context *c, return NT_STATUS_OK; } +/* + setup a negprot send +*/ +static NTSTATUS connect_send_negprot(struct composite_context *c, + struct smb_composite_connect *io) +{ + struct connect_state *state = talloc_get_type(c->private_data, struct connect_state); + + state->req = smb_raw_negotiate_send(state->transport, io->in.options.unicode, io->in.options.max_protocol); + NT_STATUS_HAVE_NO_MEMORY(state->req); + + state->req->async.fn = request_handler; + state->req->async.private = c; + state->stage = CONNECT_NEGPROT; + + return NT_STATUS_OK; +} + /* a session request operation has completed -- cgit