summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2011-08-01 15:39:01 +1000
committerAndrew Bartlett <abartlet@samba.org>2011-08-03 18:48:02 +1000
commit35b309fa0cac9341f364243b03ebfcc80f74198e (patch)
treeb99fc49ec70be97a41289b3978db367fba63a769 /source4/libcli
parentd3fe48ba48b25f359292ee96dbf5cecc0b0b16a3 (diff)
downloadsamba-35b309fa0cac9341f364243b03ebfcc80f74198e.tar.gz
samba-35b309fa0cac9341f364243b03ebfcc80f74198e.tar.bz2
samba-35b309fa0cac9341f364243b03ebfcc80f74198e.zip
gensec: clarify memory ownership for gensec_session_info() and gensec_session_key()
This is slightly less efficient, because we no longer keep a cache on the gensec structures, but much clearer in terms of memory ownership. Both gensec_session_info() and gensec_session_key() now take a mem_ctx and put the result only on that context. Some duplication of memory in the callers (who were rightly uncertain about who was the rightful owner of the returned memory) has been removed to compensate for the internal copy. Andrew Bartlett
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/smb2/session.c7
-rw-r--r--source4/libcli/smb_composite/sesssetup.c5
2 files changed, 3 insertions, 9 deletions
diff --git a/source4/libcli/smb2/session.c b/source4/libcli/smb2/session.c
index d46cdefc69..0f749a0b6c 100644
--- a/source4/libcli/smb2/session.c
+++ b/source4/libcli/smb2/session.c
@@ -233,8 +233,6 @@ static void smb2_session_setup_spnego_handler(struct smb2_request *subreq)
tevent_req_data(req,
struct smb2_session_setup_spnego_state);
struct smb2_session *session = subreq->session;
- NTSTATUS session_key_err;
- DATA_BLOB session_key;
NTSTATUS peer_status;
NTSTATUS status;
@@ -267,10 +265,7 @@ static void smb2_session_setup_spnego_handler(struct smb2_request *subreq)
return;
}
- session_key_err = gensec_session_key(session->gensec, &session_key);
- if (NT_STATUS_IS_OK(session_key_err)) {
- session->session_key = session_key;
- }
+ gensec_session_key(session->gensec, session, &session->session_key);
if (session->transport->signing_required) {
if (session->session_key.length == 0) {
diff --git a/source4/libcli/smb_composite/sesssetup.c b/source4/libcli/smb_composite/sesssetup.c
index ebc35983d2..d617055c41 100644
--- a/source4/libcli/smb_composite/sesssetup.c
+++ b/source4/libcli/smb_composite/sesssetup.c
@@ -200,10 +200,9 @@ static void request_handler(struct smbcli_request *req)
c->status = NT_STATUS_INTERNAL_ERROR;
break;
}
- session_key_err = gensec_session_key(session->gensec, &session_key);
+ session_key_err = gensec_session_key(session->gensec, session, &session->user_session_key);
if (NT_STATUS_IS_OK(session_key_err)) {
- set_user_session_key(session, &session_key);
- smbcli_transport_simple_set_signing(session->transport, session_key, null_data_blob);
+ smbcli_transport_simple_set_signing(session->transport, session->user_session_key, null_data_blob);
}
}