]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:smbd: add smbd_server_disconnect_client[_ex]()
authorStefan Metzmacher <metze@samba.org>
Tue, 2 Jun 2020 14:43:43 +0000 (16:43 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 8 Jul 2020 15:54:39 +0000 (15:54 +0000)
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>
source3/smbd/globals.h
source3/smbd/smb2_server.c

index 3f7aa94ce3cb5c1dabc3051ee29831da1d9e2182..7e0f11d5d150020835bcd0e87d1e2820b9c94d3c 100644 (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);
index 86354098b958b43d69e993b63f9eb078df21d979..7d990a0ca43cf6c701568c6aa82616b33345e1ba 100644 (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)