1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-29 21:47:30 +03:00

r3186: Use the properties of the new talloc() system to handle the auth

session info and server info structures.

Andrew Bartlett
This commit is contained in:
Andrew Bartlett 2004-10-25 04:19:02 +00:00 committed by Gerald (Jerry) Carter
parent fbe932ddd4
commit 5bdf391b3b
3 changed files with 19 additions and 18 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}