1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-26 10:04:02 +03:00

s3:smbd: add smbd_server_disconnect_client[_ex]()

With multichannel things may not happen only on one connection.
We may need to disconnect all connections of a client, when something
bad happens.

The first users of this will be the lease/oplock break code,
if they are not able allocate memory or something similar
we need to bail out.

Having a special smbXsrv_client based function is better than
calling exit_server*() directly.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11897

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
This commit is contained in:
Stefan Metzmacher 2020-06-02 16:43:43 +02:00
parent 60d7f059a4
commit 54bd3a46c8
2 changed files with 24 additions and 0 deletions

View File

@ -229,6 +229,12 @@ void smbd_server_connection_terminate_ex(struct smbXsrv_connection *xconn,
#define smbd_server_connection_terminate(xconn, reason) \
smbd_server_connection_terminate_ex(xconn, reason, __location__)
void smbd_server_disconnect_client_ex(struct smbXsrv_client *client,
const char *reason,
const char *location);
#define smbd_server_disconnect_client(__client, __reason) \
smbd_server_disconnect_client_ex(__client, __reason, __location__)
const char *smb2_opcode_name(uint16_t opcode);
bool smbd_is_smb2_header(const uint8_t *inbuf, size_t size);
bool smbd_smb2_is_compound(const struct smbd_smb2_request *req);

View File

@ -1299,6 +1299,24 @@ void smbd_server_connection_terminate_ex(struct smbXsrv_connection *xconn,
exit_server_cleanly(reason);
}
void smbd_server_disconnect_client_ex(struct smbXsrv_client *client,
const char *reason,
const char *location)
{
size_t num_ok = 0;
num_ok = smbXsrv_client_valid_connections(client);
DBG_WARNING("client[%s] num_ok[%zu] reason[%s] at %s\n",
client->global->remote_address, num_ok,
reason, location);
/*
* Something bad happened we need to disconnect all connections.
*/
exit_server_cleanly(reason);
}
static bool dup_smb2_vec4(TALLOC_CTX *ctx,
struct iovec *outvec,
const struct iovec *srcvec)