mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
s3:smbd: keep 'num_users' and 'users' directly under smbd_server_connection
The plan is to have users_struct as some kind of low level abstraction for a smb1/smb2 session, that can be used by SMB_VFS modules. metze
This commit is contained in:
parent
d95dbb86c5
commit
6ce72a01ab
@ -452,6 +452,9 @@ struct smbd_server_connection {
|
||||
bool using_smb2;
|
||||
int trans_num;
|
||||
|
||||
size_t num_users;
|
||||
struct user_struct *users;
|
||||
|
||||
struct files_struct *files;
|
||||
struct bitmap *file_bmap;
|
||||
int real_max_open_files;
|
||||
@ -535,9 +538,7 @@ struct smbd_server_connection {
|
||||
* this holds info on user ids that are already
|
||||
* validated for this VC
|
||||
*/
|
||||
user_struct *validated_users;
|
||||
uint16_t next_vuid;
|
||||
int num_validated_vuids;
|
||||
} sessions;
|
||||
struct {
|
||||
connection_struct *Connections;
|
||||
|
@ -52,7 +52,7 @@ static user_struct *get_valid_user_struct_internal(
|
||||
if (vuid == UID_FIELD_INVALID)
|
||||
return NULL;
|
||||
|
||||
usp=sconn->smb1.sessions.validated_users;
|
||||
usp=sconn->users;
|
||||
for (;usp;usp=usp->next,count++) {
|
||||
if (vuid == usp->vuid) {
|
||||
switch (server_allocated) {
|
||||
@ -69,8 +69,7 @@ static user_struct *get_valid_user_struct_internal(
|
||||
break;
|
||||
}
|
||||
if (count > 10) {
|
||||
DLIST_PROMOTE(sconn->smb1.sessions.validated_users,
|
||||
usp);
|
||||
DLIST_PROMOTE(sconn->users, usp);
|
||||
}
|
||||
return usp;
|
||||
}
|
||||
@ -128,14 +127,15 @@ void invalidate_vuid(struct smbd_server_connection *sconn, uint16 vuid)
|
||||
TALLOC_FREE(vuser->gensec_security);
|
||||
}
|
||||
|
||||
DLIST_REMOVE(sconn->smb1.sessions.validated_users, vuser);
|
||||
DLIST_REMOVE(sconn->users, vuser);
|
||||
SMB_ASSERT(sconn->num_users > 0);
|
||||
sconn->num_users--;
|
||||
|
||||
/* clear the vuid from the 'cache' on each connection, and
|
||||
from the vuid 'owner' of connections */
|
||||
conn_clear_vuid_caches(sconn, vuid);
|
||||
|
||||
TALLOC_FREE(vuser);
|
||||
sconn->smb1.sessions.num_validated_vuids--;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -148,9 +148,8 @@ void invalidate_all_vuids(struct smbd_server_connection *sconn)
|
||||
return;
|
||||
}
|
||||
|
||||
while (sconn->smb1.sessions.validated_users != NULL) {
|
||||
invalidate_vuid(sconn,
|
||||
sconn->smb1.sessions.validated_users->vuid);
|
||||
while (sconn->users != NULL) {
|
||||
invalidate_vuid(sconn, sconn->users->vuid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,7 +172,7 @@ int register_initial_vuid(struct smbd_server_connection *sconn)
|
||||
user_struct *vuser;
|
||||
|
||||
/* Limit allowed vuids to 16bits - VUID_OFFSET. */
|
||||
if (sconn->smb1.sessions.num_validated_vuids >= 0xFFFF-VUID_OFFSET) {
|
||||
if (sconn->num_users >= 0xFFFF-VUID_OFFSET) {
|
||||
return UID_FIELD_INVALID;
|
||||
}
|
||||
|
||||
@ -201,9 +200,10 @@ int register_initial_vuid(struct smbd_server_connection *sconn)
|
||||
* to NTLMSSP.
|
||||
*/
|
||||
increment_next_vuid(&sconn->smb1.sessions.next_vuid);
|
||||
sconn->smb1.sessions.num_validated_vuids++;
|
||||
|
||||
DLIST_ADD(sconn->smb1.sessions.validated_users, vuser);
|
||||
sconn->num_users++;
|
||||
DLIST_ADD(sconn->users, vuser);
|
||||
|
||||
return vuser->vuid;
|
||||
}
|
||||
|
||||
|
@ -2984,20 +2984,17 @@ static void smbd_id_cache_kill(struct messaging_context *msg_ctx,
|
||||
{
|
||||
const char *msg = (data && data->data)
|
||||
? (const char *)data->data : "<NULL>";
|
||||
struct user_struct *validated_users;
|
||||
struct id_cache_ref id;
|
||||
struct smbd_server_connection *sconn =
|
||||
talloc_get_type_abort(private_data,
|
||||
struct smbd_server_connection);
|
||||
|
||||
validated_users = sconn->smb1.sessions.validated_users;
|
||||
|
||||
if (!id_cache_ref_parse(msg, &id)) {
|
||||
DEBUG(0, ("Invalid ?ID: %s\n", msg));
|
||||
return;
|
||||
}
|
||||
|
||||
if (id_in_use(validated_users, &id)) {
|
||||
if (id_in_use(sconn->users, &id)) {
|
||||
exit_server_cleanly(msg);
|
||||
}
|
||||
id_cache_delete_from_cache(&id);
|
||||
@ -3265,9 +3262,7 @@ void smbd_process(struct tevent_context *ev_ctx,
|
||||
sconn->smb1.sessions.max_send = BUFFER_SIZE;
|
||||
sconn->smb1.sessions.last_session_tag = UID_FIELD_INVALID;
|
||||
/* this holds info on user ids that are already validated for this VC */
|
||||
sconn->smb1.sessions.validated_users = NULL;
|
||||
sconn->smb1.sessions.next_vuid = VUID_OFFSET;
|
||||
sconn->smb1.sessions.num_validated_vuids = 0;
|
||||
|
||||
conn_init(sconn);
|
||||
if (!init_dptrs(sconn)) {
|
||||
|
@ -173,7 +173,8 @@ static NTSTATUS smbd_smb2_auth_generic_return(struct smbd_smb2_session *session,
|
||||
session->compat_vuser->session_info = session->session_info;
|
||||
session->compat_vuser->session_keystr = NULL;
|
||||
session->compat_vuser->vuid = session->vuid;
|
||||
DLIST_ADD(session->sconn->smb1.sessions.validated_users, session->compat_vuser);
|
||||
DLIST_ADD(session->sconn->users, session->compat_vuser);
|
||||
session->sconn->num_users++;
|
||||
|
||||
if (security_session_user_level(session->session_info, NULL) >= SECURITY_USER) {
|
||||
session->compat_vuser->homes_snum =
|
||||
|
Loading…
Reference in New Issue
Block a user