diff options
author | Stefan Metzmacher <metze@samba.org> | 2015-07-29 15:48:05 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2015-07-30 21:58:14 +0200 |
commit | 2c39036806c34eaaee5dbe2000e978a10c5af6c2 (patch) | |
tree | d63f306478fa2d2958e91aa99d8ee1844389ce2e /source3/smbd | |
parent | e9885cfd0e4abd6a6a8e276e11a57e6e58e873e6 (diff) | |
download | samba-2c39036806c34eaaee5dbe2000e978a10c5af6c2.tar.gz |
smbXsrv_session: add smbXsrv_session_create_auth()
Pair-Programmed-With: Michael Adam <obnox@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/globals.h | 6 | ||||
-rw-r--r-- | source3/smbd/smbXsrv_session.c | 53 |
2 files changed, 59 insertions, 0 deletions
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index c0fc8485cfc..e8fb1d548d7 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -545,6 +545,12 @@ NTSTATUS smbXsrv_session_find_auth(const struct smbXsrv_session *session, const struct smbXsrv_connection *conn, NTTIME now, struct smbXsrv_session_auth0 **_a); +NTSTATUS smbXsrv_session_create_auth(struct smbXsrv_session *session, + struct smbXsrv_connection *conn, + NTTIME now, + uint8_t in_flags, + uint8_t in_security_mode, + struct smbXsrv_session_auth0 **_a); struct tevent_req *smb2srv_session_shutdown_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct smbXsrv_session *session, diff --git a/source3/smbd/smbXsrv_session.c b/source3/smbd/smbXsrv_session.c index de8d8327bc9..52a4cf36aaf 100644 --- a/source3/smbd/smbXsrv_session.c +++ b/source3/smbd/smbXsrv_session.c @@ -1407,6 +1407,59 @@ NTSTATUS smbXsrv_session_find_auth(const struct smbXsrv_session *session, return NT_STATUS_USER_SESSION_DELETED; } +static int smbXsrv_session_auth0_destructor(struct smbXsrv_session_auth0 *a) +{ + if (a->session == NULL) { + return 0; + } + + DLIST_REMOVE(a->session->pending_auth, a); + a->session = NULL; + return 0; +} + +NTSTATUS smbXsrv_session_create_auth(struct smbXsrv_session *session, + struct smbXsrv_connection *conn, + NTTIME now, + uint8_t in_flags, + uint8_t in_security_mode, + struct smbXsrv_session_auth0 **_a) +{ + struct smbXsrv_session_auth0 *a; + NTSTATUS status; + + status = smbXsrv_session_find_auth(session, conn, 0, &a); + if (NT_STATUS_IS_OK(status)) { + return NT_STATUS_INTERNAL_ERROR; + } + + a = talloc_zero(session, struct smbXsrv_session_auth0); + if (a == NULL) { + return NT_STATUS_NO_MEMORY; + } + a->session = session; + a->connection = conn; + a->in_flags = in_flags; + a->in_security_mode = in_security_mode; + a->creation_time = now; + a->idle_time = now; + + if (conn->protocol >= PROTOCOL_SMB3_10) { + a->preauth = talloc(a, struct smbXsrv_preauth); + if (a->preauth == NULL) { + TALLOC_FREE(session); + return NT_STATUS_NO_MEMORY; + } + *a->preauth = conn->smb2.preauth; + } + + talloc_set_destructor(a, smbXsrv_session_auth0_destructor); + DLIST_ADD_END(session->pending_auth, a, NULL); + + *_a = a; + return NT_STATUS_OK; +} + struct smb2srv_session_shutdown_state { struct tevent_queue *wait_queue; }; |