diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-01-16 11:15:08 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:08:53 -0500 |
commit | 7cbc768376ed0a839afca64aeea99cd53d0fbc6f (patch) | |
tree | 116b18a6fc59ec306275f32c136201f83708e5fc /source4/libcli/composite/connect.c | |
parent | 6eabc2a711446819e0694bd56eb71ea7f101ae66 (diff) | |
download | samba-7cbc768376ed0a839afca64aeea99cd53d0fbc6f.tar.gz samba-7cbc768376ed0a839afca64aeea99cd53d0fbc6f.tar.bz2 samba-7cbc768376ed0a839afca64aeea99cd53d0fbc6f.zip |
r4777: added a smb_composite_sesssetup() async composite function. This
encapsulates all the different session setup methods, including the
multi-pass spnego code.
I have hooked this into all the places that previously used the
RAW_SESSSETUP_GENERIC method, and have removed the old
RAW_SESSSETUP_GENERIC code from clisession.c and clitree.c. A nice
side effect is that these two modules are now very simple again, back
to being "raw" session setup handling, which was what was originally
intended.
I have also used this to replace the session setup code in the
smb_composite_connect() code, and used that to build a very simple
replacement for smbcli_tree_full_connection().
As a result, smbclient, smbtorture and all our other SMB connection
code now goes via these composite async functions. That should give
them a good workout!
(This used to be commit 080d0518bc7d6fd4bc3ef783e7d4d2e3275d0799)
Diffstat (limited to 'source4/libcli/composite/connect.c')
-rw-r--r-- | source4/libcli/composite/connect.c | 88 |
1 files changed, 23 insertions, 65 deletions
diff --git a/source4/libcli/composite/connect.c b/source4/libcli/composite/connect.c index 310084d0b1..c51c8d48fd 100644 --- a/source4/libcli/composite/connect.c +++ b/source4/libcli/composite/connect.c @@ -103,15 +103,16 @@ static NTSTATUS connect_session_setup(struct smbcli_composite *c, struct smb_composite_connect *io) { struct connect_state *state = c->private; - struct smbcli_request *req = c->req; - union smb_sesssetup *io_setup = c->req_parms; + struct smbcli_composite *req = c->req; + struct smbcli_request *req2; + struct smb_composite_sesssetup *io_setup = c->req_parms; union smb_tcon *io_tcon; NTSTATUS status; - status = smb_raw_session_setup_recv(req, c, io_setup); + status = smb_composite_sesssetup_recv(req); NT_STATUS_NOT_OK_RETURN(status); - state->session->vuid = io_setup->nt1.out.vuid; + state->session->vuid = io_setup->out.vuid; /* setup for a tconx */ io->out.tree = smbcli_tree_init(state->session); @@ -136,41 +137,19 @@ static NTSTATUS connect_session_setup(struct smbcli_composite *c, io_tcon->tconx.in.device = io->in.service_type; } - req = smb_tree_connect_send(io->out.tree, io_tcon); - NT_STATUS_HAVE_NO_MEMORY(req); + req2 = smb_tree_connect_send(io->out.tree, io_tcon); + NT_STATUS_HAVE_NO_MEMORY(req2); - req->async.fn = request_handler; - req->async.private = c; + req2->async.fn = request_handler; + req2->async.private = c; c->req_parms = io_tcon; - c->req = req; + c->req = req2; c->stage = CONNECT_TCON; return NT_STATUS_OK; } /* - form an encrypted lanman password from a plaintext password - and the server supplied challenge -*/ -static DATA_BLOB lanman_blob(const char *pass, DATA_BLOB challenge) -{ - DATA_BLOB blob = data_blob(NULL, 24); - SMBencrypt(pass, challenge.data, blob.data); - return blob; -} - -/* - form an encrypted NT password from a plaintext password - and the server supplied challenge -*/ -static DATA_BLOB nt_blob(const char *pass, DATA_BLOB challenge) -{ - DATA_BLOB blob = data_blob(NULL, 24); - SMBNTencrypt(pass, challenge.data, blob.data); - return blob; -} - -/* a negprot request has competed */ static NTSTATUS connect_negprot(struct smbcli_composite *c, @@ -178,8 +157,9 @@ static NTSTATUS connect_negprot(struct smbcli_composite *c, { struct connect_state *state = c->private; struct smbcli_request *req = c->req; + struct smbcli_composite *req2; NTSTATUS status; - union smb_sesssetup *io_setup; + struct smb_composite_sesssetup *io_setup; status = smb_raw_negotiate_recv(req); NT_STATUS_NOT_OK_RETURN(status); @@ -191,45 +171,23 @@ static NTSTATUS connect_negprot(struct smbcli_composite *c, /* get rid of the extra reference to the transport */ talloc_free(state->transport); - io_setup = talloc(c, union smb_sesssetup); + io_setup = talloc(c, struct smb_composite_sesssetup); NT_STATUS_HAVE_NO_MEMORY(io_setup); /* prepare a session setup to establish a security context */ - io_setup->nt1.level = RAW_SESSSETUP_NT1; - io_setup->nt1.in.bufsize = state->session->transport->options.max_xmit; - io_setup->nt1.in.mpx_max = state->session->transport->options.max_mux; - io_setup->nt1.in.vc_num = 1; - io_setup->nt1.in.sesskey = state->transport->negotiate.sesskey; - io_setup->nt1.in.capabilities = state->transport->negotiate.capabilities; - io_setup->nt1.in.domain = io->in.domain; - io_setup->nt1.in.user = io->in.user; - io_setup->nt1.in.os = "Unix"; - io_setup->nt1.in.lanman = "Samba"; - - if (!io->in.password) { - io_setup->nt1.in.password1 = data_blob(NULL, 0); - io_setup->nt1.in.password2 = data_blob(NULL, 0); - } else if (state->session->transport->negotiate.sec_mode & - NEGOTIATE_SECURITY_CHALLENGE_RESPONSE) { - io_setup->nt1.in.password1 = lanman_blob(io->in.password, - state->transport->negotiate.secblob); - io_setup->nt1.in.password2 = nt_blob(io->in.password, - state->transport->negotiate.secblob); - smb_session_use_nt1_session_keys(state->session, io->in.password, &io_setup->nt1.in.password2); + io_setup->in.sesskey = state->transport->negotiate.sesskey; + io_setup->in.capabilities = state->transport->negotiate.capabilities; + io_setup->in.domain = io->in.domain; + io_setup->in.user = io->in.user; + io_setup->in.password = io->in.password; - } else { - io_setup->nt1.in.password1 = data_blob(io->in.password, - strlen(io->in.password)); - io_setup->nt1.in.password2 = data_blob(NULL, 0); - } + req2 = smb_composite_sesssetup_send(state->session, io_setup); + NT_STATUS_HAVE_NO_MEMORY(req2); - req = smb_raw_session_setup_send(state->session, io_setup); - NT_STATUS_HAVE_NO_MEMORY(req); - - req->async.fn = request_handler; - req->async.private = c; + req2->async.fn = composite_handler; + req2->async.private = c; c->req_parms = io_setup; - c->req = req; + c->req = req2; c->stage = CONNECT_SESSION_SETUP; return NT_STATUS_OK; |