summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2012-05-16 16:05:48 +0200
committerStefan Metzmacher <metze@samba.org>2012-06-25 20:55:07 +0200
commit1b8bcaeda3ea1b292c8b9a5a6c1a25e0d40aa2b6 (patch)
tree6054c0341247ede75457120788a7f3d868283b9e
parentf32e99a0fc754916e611a90933b7874d7502db50 (diff)
downloadsamba-1b8bcaeda3ea1b292c8b9a5a6c1a25e0d40aa2b6.tar.gz
samba-1b8bcaeda3ea1b292c8b9a5a6c1a25e0d40aa2b6.tar.bz2
samba-1b8bcaeda3ea1b292c8b9a5a6c1a25e0d40aa2b6.zip
s3:smb2_sesssetup: make use of gensec_update_send/recv
metze
-rw-r--r--source3/smbd/smb2_sesssetup.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/source3/smbd/smb2_sesssetup.c b/source3/smbd/smb2_sesssetup.c
index 76d34108ad..d91c902ff3 100644
--- a/source3/smbd/smb2_sesssetup.c
+++ b/source3/smbd/smb2_sesssetup.c
@@ -427,6 +427,8 @@ static int smbd_smb2_session_setup_state_destructor(struct smbd_smb2_session_set
return 0;
}
+static void smbd_smb2_session_setup_done(struct tevent_req *subreq);
+
static struct tevent_req *smbd_smb2_session_setup_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct smbd_smb2_request *smb2req,
@@ -440,6 +442,7 @@ static struct tevent_req *smbd_smb2_session_setup_send(TALLOC_CTX *mem_ctx,
struct smbd_smb2_session_setup_state *state;
NTSTATUS status;
NTTIME now = timeval_to_nttime(&smb2req->request_time);
+ struct tevent_req *subreq;
req = tevent_req_create(mem_ctx, &state,
struct smbd_smb2_session_setup_state);
@@ -500,15 +503,37 @@ static struct tevent_req *smbd_smb2_session_setup_send(TALLOC_CTX *mem_ctx,
}
become_root();
- status = gensec_update(state->session->gensec,
- state, NULL,
- state->in_security_buffer,
- &state->out_security_buffer);
+ subreq = gensec_update_send(state, state->ev,
+ state->session->gensec,
+ state->in_security_buffer);
unbecome_root();
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, smbd_smb2_session_setup_done, req);
+
+ return req;
+}
+
+static void smbd_smb2_session_setup_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;
+
+ become_root();
+ status = gensec_update_recv(subreq, state,
+ &state->out_security_buffer);
+ unbecome_root();
+ TALLOC_FREE(subreq);
if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED) &&
!NT_STATUS_IS_OK(status)) {
tevent_req_nterror(req, status);
- return tevent_req_post(req, ev);
+ return;
}
if (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
@@ -516,7 +541,7 @@ static struct tevent_req *smbd_smb2_session_setup_send(TALLOC_CTX *mem_ctx,
/* we want to keep the session */
state->session = NULL;
tevent_req_nterror(req, status);
- return tevent_req_post(req, ev);
+ return;
}
if (state->session->global->auth_session_info != NULL) {
@@ -525,12 +550,12 @@ static struct tevent_req *smbd_smb2_session_setup_send(TALLOC_CTX *mem_ctx,
&state->out_session_flags,
&state->out_session_id);
if (tevent_req_nterror(req, status)) {
- return tevent_req_post(req, ev);
+ return;
}
/* we want to keep the session */
state->session = NULL;
tevent_req_done(req);
- return tevent_req_post(req, ev);
+ return;
}
status = smbd_smb2_auth_generic_return(state->session,
@@ -541,13 +566,13 @@ static struct tevent_req *smbd_smb2_session_setup_send(TALLOC_CTX *mem_ctx,
&state->out_session_flags,
&state->out_session_id);
if (tevent_req_nterror(req, status)) {
- return tevent_req_post(req, ev);
+ return;
}
/* we want to keep the session */
state->session = NULL;
tevent_req_done(req);
- return tevent_req_post(req, ev);
+ return;
}
static NTSTATUS smbd_smb2_session_setup_recv(struct tevent_req *req,