1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

smbd: use session->global->session_wire_id instead of session->compat->vuid

session->compat->vuid is set to session->global->session_wire_id after a
successful session setup, so both variables will always carry the same value. Cf
the next commit which removes vuid from user_struct.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Ralph Boehme 2019-12-29 14:33:00 +01:00 committed by Jeremy Allison
parent 5992f8fa93
commit bcadd7d798
10 changed files with 26 additions and 27 deletions

View File

@ -665,7 +665,7 @@ struct files_struct *file_fsp_get(struct smbd_smb2_request *smb2req,
return NULL;
}
if (smb2req->session->compat->vuid != fsp->vuid) {
if (smb2req->session->global->session_wire_id != fsp->vuid) {
return NULL;
}

View File

@ -43,7 +43,7 @@ static struct user_struct *get_valid_user_struct_internal(
usp=sconn->users;
for (;usp;usp=usp->next,count++) {
if (vuid == usp->vuid) {
if (vuid == usp->session->global->session_wire_id) {
switch (server_allocated) {
case SERVER_ALLOCATED_REQUIRED_YES:
if (usp->session_info == NULL) {

View File

@ -615,7 +615,7 @@ static NTSTATUS make_connection_snum(struct smbXsrv_connection *xconn,
goto err_root_exit;
}
conn->vuid = vuser->vuid;
conn->vuid = session->global->session_wire_id;
{
char *s = talloc_sub_full(talloc_tos(),

View File

@ -355,7 +355,7 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req)
if (!session_claim(session)) {
DEBUG(1, ("smb1: Failed to claim session for vuid=%llu\n",
(unsigned long long)session->compat->vuid));
(unsigned long long)session->global->session_wire_id));
data_blob_free(&out_blob);
TALLOC_FREE(session);
reply_nterror(req, NT_STATUS_LOGON_FAILURE);
@ -365,7 +365,7 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req)
status = smbXsrv_session_update(session);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("smb1: Failed to update session for vuid=%llu - %s\n",
(unsigned long long)session->compat->vuid,
(unsigned long long)session->global->session_wire_id,
nt_errstr(status)));
data_blob_free(&out_blob);
TALLOC_FREE(session);
@ -444,7 +444,7 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req)
status = smbXsrv_session_update(session);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("smb1: Failed to update session for vuid=%llu - %s\n",
(unsigned long long)session->compat->vuid,
(unsigned long long)session->global->session_wire_id,
nt_errstr(status)));
data_blob_free(&out_blob);
TALLOC_FREE(session);
@ -452,7 +452,7 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req)
return;
}
conn_clear_vuid_caches(sconn, session->compat->vuid);
conn_clear_vuid_caches(sconn, session->global->session_wire_id);
/* current_user_info is changed on new vuid */
reload_services(sconn, conn_snum_used, true);
@ -1110,7 +1110,7 @@ void reply_sesssetup_and_X(struct smb_request *req)
nt_status = smbXsrv_session_update(session);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("smb1: Failed to update session for vuid=%llu - %s\n",
(unsigned long long)session->compat->vuid,
(unsigned long long)session->global->session_wire_id,
nt_errstr(nt_status)));
TALLOC_FREE(session);
reply_nterror(req, nt_status_squash(nt_status));
@ -1120,7 +1120,7 @@ void reply_sesssetup_and_X(struct smb_request *req)
if (!session_claim(session)) {
DEBUG(1, ("smb1: Failed to claim session for vuid=%llu\n",
(unsigned long long)session->compat->vuid));
(unsigned long long)session->global->session_wire_id));
TALLOC_FREE(session);
reply_nterror(req, NT_STATUS_LOGON_FAILURE);
END_PROFILE(SMBsesssetupX);

View File

@ -41,7 +41,7 @@ struct smb_request *smbd_smb2_fake_smb_request(struct smbd_smb2_request *req)
}
smbreq->request_time = req->request_time;
smbreq->vuid = req->session->compat->vuid;
smbreq->vuid = req->session->global->session_wire_id;
smbreq->tid = req->tcon->compat->cnum;
smbreq->conn = req->tcon->compat;
smbreq->sconn = req->sconn;

View File

@ -1882,7 +1882,10 @@ static NTSTATUS smbd_smb2_request_check_tcon(struct smbd_smb2_request *req)
return status;
}
if (!change_to_user_and_service(tcon->compat, req->session->compat->vuid)) {
if (!change_to_user_and_service(
tcon->compat,
req->session->global->session_wire_id))
{
return NT_STATUS_ACCESS_DENIED;
}

View File

@ -563,7 +563,7 @@ static NTSTATUS smbd_smb2_auth_generic_return(struct smbXsrv_session *session,
if (!session_claim(session)) {
DEBUG(1, ("smb2: Failed to claim session "
"for vuid=%llu\n",
(unsigned long long)session->compat->vuid));
(unsigned long long)session->global->session_wire_id));
return NT_STATUS_LOGON_FAILURE;
}
@ -571,7 +571,7 @@ static NTSTATUS smbd_smb2_auth_generic_return(struct smbXsrv_session *session,
status = smbXsrv_session_update(session);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("smb2: Failed to update session for vuid=%llu - %s\n",
(unsigned long long)session->compat->vuid,
(unsigned long long)session->global->session_wire_id,
nt_errstr(status)));
return NT_STATUS_LOGON_FAILURE;
}
@ -650,12 +650,13 @@ static NTSTATUS smbd_smb2_reauth_generic_return(struct smbXsrv_session *session,
status = smbXsrv_session_update(session);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("smb2: Failed to update session for vuid=%llu - %s\n",
(unsigned long long)session->compat->vuid,
(unsigned long long)session->global->session_wire_id,
nt_errstr(status)));
return NT_STATUS_LOGON_FAILURE;
}
conn_clear_vuid_caches(xconn->client->sconn, session->compat->vuid);
conn_clear_vuid_caches(xconn->client->sconn,
session->global->session_wire_id);
*out_session_id = session->global->session_wire_id;
@ -790,7 +791,7 @@ static NTSTATUS smbd_smb2_bind_auth_return(struct smbXsrv_session *session,
status = smbXsrv_session_update(session);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("smb2: Failed to update session for vuid=%llu - %s\n",
(unsigned long long)session->compat->vuid,
(unsigned long long)session->global->session_wire_id,
nt_errstr(status)));
return NT_STATUS_LOGON_FAILURE;
}

View File

@ -308,8 +308,9 @@ static void defer_rename_done(struct tevent_req *subreq)
/*
* Make sure we run as the user again
*/
ok = change_to_user_and_service(state->smb2req->tcon->compat,
state->smb2req->session->compat->vuid);
ok = change_to_user_and_service(
state->smb2req->tcon->compat,
state->smb2req->session->global->session_wire_id);
if (!ok) {
tevent_req_nterror(state->req, NT_STATUS_ACCESS_DENIED);
return;

View File

@ -1669,7 +1669,7 @@ NTSTATUS smbXsrv_session_logoff(struct smbXsrv_session *session)
* smbXsrv_tcon_disconnect() -> close_cnum() ->
* file_close_conn().
*/
file_close_user(sconn, session->compat->vuid);
file_close_user(sconn, session->global->session_wire_id);
}
if (session->tcon_table != NULL) {
@ -1687,7 +1687,7 @@ NTSTATUS smbXsrv_session_logoff(struct smbXsrv_session *session)
}
if (session->compat) {
invalidate_vuid(sconn, session->compat->vuid);
invalidate_vuid(sconn, session->global->session_wire_id);
session->compat = NULL;
}

View File

@ -1168,13 +1168,7 @@ NTSTATUS smb2srv_tcon_lookup(struct smbXsrv_session *session,
NTSTATUS smb2srv_tcon_disconnect_all(struct smbXsrv_session *session)
{
uint64_t vuid;
if (session->compat) {
vuid = session->compat->vuid;
} else {
vuid = 0;
}
uint64_t vuid = session->global->session_wire_id;
return smbXsrv_tcon_disconnect_all(session->tcon_table, vuid);
}