summaryrefslogtreecommitdiff
path: root/auth
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 /auth
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 'auth')
-rw-r--r--auth/gensec/gensec.c10
-rw-r--r--auth/gensec/gensec.h7
2 files changed, 11 insertions, 6 deletions
diff --git a/auth/gensec/gensec.c b/auth/gensec/gensec.c
index 4736e73d5a..417b05cf06 100644
--- a/auth/gensec/gensec.c
+++ b/auth/gensec/gensec.c
@@ -148,7 +148,8 @@ _PUBLIC_ NTSTATUS gensec_unwrap(struct gensec_security *gensec_security,
}
_PUBLIC_ NTSTATUS gensec_session_key(struct gensec_security *gensec_security,
- DATA_BLOB *session_key)
+ TALLOC_CTX *mem_ctx,
+ DATA_BLOB *session_key)
{
if (!gensec_security->ops->session_key) {
return NT_STATUS_NOT_IMPLEMENTED;
@@ -157,7 +158,7 @@ _PUBLIC_ NTSTATUS gensec_session_key(struct gensec_security *gensec_security,
return NT_STATUS_NO_USER_SESSION_KEY;
}
- return gensec_security->ops->session_key(gensec_security, session_key);
+ return gensec_security->ops->session_key(gensec_security, mem_ctx, session_key);
}
/**
@@ -171,12 +172,13 @@ _PUBLIC_ NTSTATUS gensec_session_key(struct gensec_security *gensec_security,
*/
_PUBLIC_ NTSTATUS gensec_session_info(struct gensec_security *gensec_security,
- struct auth_session_info **session_info)
+ TALLOC_CTX *mem_ctx,
+ struct auth_session_info **session_info)
{
if (!gensec_security->ops->session_info) {
return NT_STATUS_NOT_IMPLEMENTED;
}
- return gensec_security->ops->session_info(gensec_security, session_info);
+ return gensec_security->ops->session_info(gensec_security, mem_ctx, session_info);
}
/**
diff --git a/auth/gensec/gensec.h b/auth/gensec/gensec.h
index 852618c1af..38f2513742 100644
--- a/auth/gensec/gensec.h
+++ b/auth/gensec/gensec.h
@@ -132,8 +132,9 @@ struct gensec_security_ops {
size_t *len_processed);
NTSTATUS (*packet_full_request)(struct gensec_security *gensec_security,
DATA_BLOB blob, size_t *size);
- NTSTATUS (*session_key)(struct gensec_security *gensec_security, DATA_BLOB *session_key);
- NTSTATUS (*session_info)(struct gensec_security *gensec_security,
+ NTSTATUS (*session_key)(struct gensec_security *gensec_security, TALLOC_CTX *mem_ctx,
+ DATA_BLOB *session_key);
+ NTSTATUS (*session_info)(struct gensec_security *gensec_security, TALLOC_CTX *mem_ctx,
struct auth_session_info **session_info);
void (*want_feature)(struct gensec_security *gensec_security,
uint32_t feature);
@@ -233,6 +234,7 @@ const char *gensec_get_target_service(struct gensec_security *gensec_security);
NTSTATUS gensec_set_target_hostname(struct gensec_security *gensec_security, const char *hostname);
const char *gensec_get_target_hostname(struct gensec_security *gensec_security);
NTSTATUS gensec_session_key(struct gensec_security *gensec_security,
+ TALLOC_CTX *mem_ctx,
DATA_BLOB *session_key);
NTSTATUS gensec_start_mech_by_oid(struct gensec_security *gensec_security,
const char *mech_oid);
@@ -269,6 +271,7 @@ NTSTATUS gensec_server_start(TALLOC_CTX *mem_ctx,
struct auth4_context *auth_context,
struct gensec_security **gensec_security);
NTSTATUS gensec_session_info(struct gensec_security *gensec_security,
+ TALLOC_CTX *mem_ctx,
struct auth_session_info **session_info);
NTSTATUS gensec_set_local_address(struct gensec_security *gensec_security,