From: Stefan Metzmacher Date: Tue, 2 Jun 2020 14:43:43 +0000 (+0200) Subject: s3:smbd: add smbd_server_disconnect_client[_ex]() X-Git-Tag: samba-4.13.0rc1~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54bd3a46c84b87aa4d391c797c363df954b9b686;p=thirdparty%2Fsamba.git 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 Reviewed-by: Günther Deschner --- diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index 3f7aa94ce3c..7e0f11d5d15 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -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); diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c index 86354098b95..7d990a0ca43 100644 --- a/source3/smbd/smb2_server.c +++ b/source3/smbd/smb2_server.c @@ -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)