diff options
author | Stefan Metzmacher <metze@samba.org> | 2020-06-02 16:43:43 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2020-07-08 15:54:39 +0000 |
commit | 54bd3a46c84b87aa4d391c797c363df954b9b686 (patch) | |
tree | f0e2cec76f217fd3f6d55d151e4c0e4d8bff2e44 | |
parent | 60d7f059a40457ab9fa01f1bf2eeddc1c3b7d0ab (diff) | |
download | samba-54bd3a46c84b87aa4d391c797c363df954b9b686.tar.gz |
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>
-rw-r--r-- | source3/smbd/globals.h | 6 | ||||
-rw-r--r-- | source3/smbd/smb2_server.c | 18 |
2 files changed, 24 insertions, 0 deletions
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) |