summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2012-05-17 00:30:43 +0200
committerStefan Metzmacher <metze@samba.org>2012-06-25 20:55:07 +0200
commited750694607827a3d35ad0980c3aad4a406108d0 (patch)
tree0568ddd3cb8ed9549adc3f35cc259176d6f873a6
parent1b8bcaeda3ea1b292c8b9a5a6c1a25e0d40aa2b6 (diff)
downloadsamba-ed750694607827a3d35ad0980c3aad4a406108d0.tar.gz
samba-ed750694607827a3d35ad0980c3aad4a406108d0.tar.bz2
samba-ed750694607827a3d35ad0980c3aad4a406108d0.zip
s3:smb2_sesssetup: inline gensec_session_info() call
metze
-rw-r--r--source3/smbd/smb2_sesssetup.c40
1 files changed, 15 insertions, 25 deletions
diff --git a/source3/smbd/smb2_sesssetup.c b/source3/smbd/smb2_sesssetup.c
index d91c902ff3..ee588b06fe 100644
--- a/source3/smbd/smb2_sesssetup.c
+++ b/source3/smbd/smb2_sesssetup.c
@@ -177,8 +177,7 @@ static void smbd_smb2_request_sesssetup_done(struct tevent_req *subreq)
static NTSTATUS smbd_smb2_auth_generic_return(struct smbXsrv_session *session,
struct smbd_smb2_request *smb2req,
uint8_t in_security_mode,
- uint64_t in_previous_session_id,
- DATA_BLOB in_security_buffer,
+ struct auth_session_info *session_info,
uint16_t *out_session_flags,
uint64_t *out_session_id)
{
@@ -186,7 +185,6 @@ static NTSTATUS smbd_smb2_auth_generic_return(struct smbXsrv_session *session,
bool guest = false;
uint8_t session_key[16];
struct smbXsrv_session *x = session;
- struct auth_session_info *session_info;
struct smbXsrv_connection *conn = session->connection;
if ((in_security_mode & SMB2_NEGOTIATE_SIGNING_REQUIRED) ||
@@ -194,14 +192,6 @@ static NTSTATUS smbd_smb2_auth_generic_return(struct smbXsrv_session *session,
x->global->signing_required = true;
}
- status = gensec_session_info(session->gensec,
- session->global,
- &session_info);
- if (!NT_STATUS_IS_OK(status)) {
- TALLOC_FREE(session);
- return status;
- }
-
if (security_session_user_level(session_info, NULL) < SECURITY_USER) {
/* we map anonymous to guest internally */
*out_session_flags |= SMB2_SESSION_FLAG_IS_GUEST;
@@ -334,22 +324,14 @@ static NTSTATUS smbd_smb2_auth_generic_return(struct smbXsrv_session *session,
static NTSTATUS smbd_smb2_reauth_generic_return(struct smbXsrv_session *session,
struct smbd_smb2_request *smb2req,
+ struct auth_session_info *session_info,
uint16_t *out_session_flags,
uint64_t *out_session_id)
{
NTSTATUS status;
struct smbXsrv_session *x = session;
- struct auth_session_info *session_info;
struct smbXsrv_connection *conn = session->connection;
- status = gensec_session_info(session->gensec,
- session->global,
- &session_info);
- if (!NT_STATUS_IS_OK(status)) {
- TALLOC_FREE(session);
- return status;
- }
-
data_blob_clear_free(&session_info->session_key);
session_info->session_key = data_blob_dup_talloc(session_info,
x->global->application_key);
@@ -412,6 +394,7 @@ struct smbd_smb2_session_setup_state {
uint64_t in_previous_session_id;
DATA_BLOB in_security_buffer;
struct smbXsrv_session *session;
+ struct auth_session_info *session_info;
uint16_t out_session_flags;
DATA_BLOB out_security_buffer;
uint64_t out_session_id;
@@ -427,7 +410,7 @@ 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 void smbd_smb2_session_setup_gensec_done(struct tevent_req *subreq);
static struct tevent_req *smbd_smb2_session_setup_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
@@ -510,12 +493,12 @@ static struct tevent_req *smbd_smb2_session_setup_send(TALLOC_CTX *mem_ctx,
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
}
- tevent_req_set_callback(subreq, smbd_smb2_session_setup_done, req);
+ tevent_req_set_callback(subreq, smbd_smb2_session_setup_gensec_done, req);
return req;
}
-static void smbd_smb2_session_setup_done(struct tevent_req *subreq)
+static void smbd_smb2_session_setup_gensec_done(struct tevent_req *subreq)
{
struct tevent_req *req =
tevent_req_callback_data(subreq,
@@ -544,9 +527,17 @@ static void smbd_smb2_session_setup_done(struct tevent_req *subreq)
return;
}
+ status = gensec_session_info(state->session->gensec,
+ state->session->global,
+ &state->session_info);
+ 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,
+ state->session_info,
&state->out_session_flags,
&state->out_session_id);
if (tevent_req_nterror(req, status)) {
@@ -561,8 +552,7 @@ static void smbd_smb2_session_setup_done(struct tevent_req *subreq)
status = smbd_smb2_auth_generic_return(state->session,
state->smb2req,
state->in_security_mode,
- state->in_previous_session_id,
- state->in_security_buffer,
+ state->session_info,
&state->out_session_flags,
&state->out_session_id);
if (tevent_req_nterror(req, status)) {