summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2004-10-25 04:19:02 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:04:38 -0500
commite5fc6dd0bb460017f6678202afc1b73acb58af09 (patch)
tree5951f48f22b888abf90e3467a32142c3f05d40e8 /source4
parentf7c6a9438dba17032aea102d18b44c6d96ae470b (diff)
downloadsamba-e5fc6dd0bb460017f6678202afc1b73acb58af09.tar.gz
samba-e5fc6dd0bb460017f6678202afc1b73acb58af09.tar.bz2
samba-e5fc6dd0bb460017f6678202afc1b73acb58af09.zip
r3186: Use the properties of the new talloc() system to handle the auth
session info and server info structures. Andrew Bartlett (This used to be commit 5bdf391b3bc10291739f5640be9a404dbbeda273)
Diffstat (limited to 'source4')
-rw-r--r--source4/auth/auth_util.c14
-rw-r--r--source4/smb_server/password.c11
-rw-r--r--source4/smb_server/sesssetup.c12
3 files changed, 19 insertions, 18 deletions
diff --git a/source4/auth/auth_util.c b/source4/auth/auth_util.c
index c8bad6128c..839e87585b 100644
--- a/source4/auth/auth_util.c
+++ b/source4/auth/auth_util.c
@@ -534,18 +534,19 @@ BOOL make_auth_methods(struct auth_context *auth_context, struct auth_methods **
return True;
}
-NTSTATUS make_session_info(struct auth_serversupplied_info *server_info,
+NTSTATUS make_session_info(TALLOC_CTX *mem_ctx,
+ struct auth_serversupplied_info *server_info,
struct auth_session_info **session_info)
{
NTSTATUS nt_status;
- *session_info = talloc_p(server_info, struct auth_session_info);
+ *session_info = talloc_p(mem_ctx, struct auth_session_info);
if (!*session_info) {
return NT_STATUS_NO_MEMORY;
}
- (*session_info)->refcount = 1;
(*session_info)->server_info = server_info;
+ talloc_reference(*session_info, server_info);
/* unless set otherwise, the session key is the user session
* key from the auth subsystem */
@@ -570,12 +571,7 @@ NTSTATUS make_session_info(struct auth_serversupplied_info *server_info,
void free_session_info(struct auth_session_info **session_info)
{
DEBUG(5,("attempting to free a session_info structure\n"));
- if (*session_info) {
- (*session_info)->refcount--;
- if ((*session_info)->refcount <= 0) {
- talloc_free((*session_info));
- }
- }
+ talloc_free((*session_info));
*session_info = NULL;
}
diff --git a/source4/smb_server/password.c b/source4/smb_server/password.c
index c302f65980..d553d8612d 100644
--- a/source4/smb_server/password.c
+++ b/source4/smb_server/password.c
@@ -58,8 +58,6 @@ void smbsrv_invalidate_vuid(struct smbsrv_connection *smb_conn, uint16_t vuid)
session_yield(sess);
- free_session_info(&sess->session_info);
-
DLIST_REMOVE(smb_conn->sessions.session_list, sess);
/* clear the vuid from the 'cache' on each connection, and
@@ -135,8 +133,13 @@ uint16_t smbsrv_register_session(struct smbsrv_connection *smb_conn,
smb_conn->sessions.num_validated_vuids++;
/* use this to keep tabs on all our info from the authentication */
- sess->session_info = session_info;
- sess->gensec_ctx = gensec_ctx;
+ if (session_info) {
+ sess->session_info = talloc_reference(sess, session_info);
+ }
+
+ if (gensec_ctx) {
+ sess->gensec_ctx = talloc_reference(sess, gensec_ctx);
+ }
sess->smb_conn = smb_conn;
DLIST_ADD(smb_conn->sessions.session_list, sess);
diff --git a/source4/smb_server/sesssetup.c b/source4/smb_server/sesssetup.c
index 7b4c217b8f..03a750e070 100644
--- a/source4/smb_server/sesssetup.c
+++ b/source4/smb_server/sesssetup.c
@@ -74,7 +74,8 @@ static NTSTATUS sesssetup_old(struct smbsrv_request *req, union smb_sesssetup *s
return nt_status_squash(status);
}
- status = make_session_info(server_info, &session_info);
+ /* This references server_info into session_info */
+ status = make_session_info(req, server_info, &session_info);
if (!NT_STATUS_IS_OK(status)) {
return nt_status_squash(status);
}
@@ -157,12 +158,12 @@ static NTSTATUS sesssetup_nt1(struct smbsrv_request *req, union smb_sesssetup *s
return nt_status_squash(status);
}
- status = make_session_info(server_info, &session_info);
+ /* This references server_info into session_info */
+ status = make_session_info(req, server_info, &session_info);
if (!NT_STATUS_IS_OK(status)) {
return nt_status_squash(status);
}
-
- talloc_steal(session_info, server_info);
+ talloc_free(server_info);
sess->nt1.out.action = 0;
sess->nt1.out.vuid = smbsrv_register_session(req->smb_conn, session_info, NULL);
@@ -238,7 +239,8 @@ static NTSTATUS sesssetup_spnego(struct smbsrv_request *req, union smb_sesssetup
}
if (!smb_sess) {
- vuid = smbsrv_register_session(req->smb_conn, session_info, gensec_ctx);
+ vuid = smbsrv_register_session(req->smb_conn,
+ session_info, gensec_ctx);
if (vuid == UID_FIELD_INVALID) {
return NT_STATUS_ACCESS_DENIED;
}