From 45cd2bc2b33230b69eeaa6f82be6f7af36770f0a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 17 May 2012 00:32:40 +0200 Subject: s3:smb2_sesssetup: make use of smb2srv_session_close_previous_send/recv metze --- source3/smbd/smb2_sesssetup.c | 66 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'source3') diff --git a/source3/smbd/smb2_sesssetup.c b/source3/smbd/smb2_sesssetup.c index ee588b06fe..85bcc05c4a 100644 --- a/source3/smbd/smb2_sesssetup.c +++ b/source3/smbd/smb2_sesssetup.c @@ -411,6 +411,7 @@ static int smbd_smb2_session_setup_state_destructor(struct smbd_smb2_session_set } static void smbd_smb2_session_setup_gensec_done(struct tevent_req *subreq); +static void smbd_smb2_session_setup_previous_done(struct tevent_req *subreq); static struct tevent_req *smbd_smb2_session_setup_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, @@ -534,6 +535,71 @@ static void smbd_smb2_session_setup_gensec_done(struct tevent_req *subreq) return; } + if ((state->in_previous_session_id != 0) && + (state->session->global->session_wire_id != + state->in_previous_session_id)) + { + subreq = smb2srv_session_close_previous_send(state, state->ev, + state->session->connection, + state->session_info, + state->in_previous_session_id, + state->session->global->session_wire_id); + if (tevent_req_nomem(subreq, req)) { + return; + } + tevent_req_set_callback(subreq, + smbd_smb2_session_setup_previous_done, + req); + return; + } + + if (state->session->global->auth_session_info != NULL) { + status = smbd_smb2_reauth_generic_return(state->session, + state->smb2req, + state->session_info, + &state->out_session_flags, + &state->out_session_id); + if (tevent_req_nterror(req, status)) { + return; + } + /* we want to keep the session */ + state->session = NULL; + tevent_req_done(req); + return; + } + + status = smbd_smb2_auth_generic_return(state->session, + state->smb2req, + state->in_security_mode, + state->session_info, + &state->out_session_flags, + &state->out_session_id); + if (tevent_req_nterror(req, status)) { + return; + } + + /* we want to keep the session */ + state->session = NULL; + tevent_req_done(req); + return; +} + +static void smbd_smb2_session_setup_previous_done(struct tevent_req *subreq) +{ + struct tevent_req *req = + tevent_req_callback_data(subreq, + struct tevent_req); + struct smbd_smb2_session_setup_state *state = + tevent_req_data(req, + struct smbd_smb2_session_setup_state); + NTSTATUS status; + + status = smb2srv_session_close_previous_recv(subreq); + TALLOC_FREE(subreq); + if (tevent_req_nterror(req, status)) { + return; + } + if (state->session->global->auth_session_info != NULL) { status = smbd_smb2_reauth_generic_return(state->session, state->smb2req, -- cgit