summaryrefslogtreecommitdiffstats
path: root/source3/smbd
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2014-02-17 12:01:12 +0100
committerStefan Metzmacher <metze@samba.org>2014-02-21 11:48:12 +0100
commit52ccb40d595fc80bfa53b0b9cd75ffb902369681 (patch)
treef2cd180bc20262f1d7a76652720d9325b9ccff31 /source3/smbd
parent58c71bee40bb91868fc69d8f7fa640db0e33efae (diff)
downloadsamba-52ccb40d595fc80bfa53b0b9cd75ffb902369681.tar.gz
samba-52ccb40d595fc80bfa53b0b9cd75ffb902369681.tar.xz
samba-52ccb40d595fc80bfa53b0b9cd75ffb902369681.zip
s3:smbd: maintain smbd_server_connection->status
If this isn't NT_STATUS_OK, we skip any io on the socket. This avoids possible problems during shutdown. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/globals.h1
-rw-r--r--source3/smbd/process.c25
-rw-r--r--source3/smbd/server_exit.c11
-rw-r--r--source3/smbd/smb2_server.c16
4 files changed, 53 insertions, 0 deletions
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h
index 94111b60ad..bae3ed03ae 100644
--- a/source3/smbd/globals.h
+++ b/source3/smbd/globals.h
@@ -633,6 +633,7 @@ struct user_struct {
};
struct smbd_server_connection {
+ NTSTATUS status;
int sock;
const struct tsocket_address *local_address;
const struct tsocket_address *remote_address;
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index f5ca2f9594..65d005df31 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -152,6 +152,13 @@ bool srv_send_smb(struct smbd_server_connection *sconn, char *buffer,
ssize_t ret;
char *buf_out = buffer;
+ if (!NT_STATUS_IS_OK(sconn->status)) {
+ /*
+ * we're not supposed to do any io
+ */
+ return true;
+ }
+
smbd_lock_socket(sconn);
if (do_signing) {
@@ -2445,6 +2452,15 @@ static void smbd_server_connection_handler(struct tevent_context *ev,
struct smbd_server_connection *conn = talloc_get_type(private_data,
struct smbd_server_connection);
+ if (!NT_STATUS_IS_OK(conn->status)) {
+ /*
+ * we're not supposed to do any io
+ */
+ TEVENT_FD_NOT_READABLE(conn->smb1.fde);
+ TEVENT_FD_NOT_WRITEABLE(conn->smb1.fde);
+ return;
+ }
+
if (flags & TEVENT_FD_WRITE) {
smbd_server_connection_write_handler(conn);
return;
@@ -2463,6 +2479,15 @@ static void smbd_server_echo_handler(struct tevent_context *ev,
struct smbd_server_connection *conn = talloc_get_type(private_data,
struct smbd_server_connection);
+ if (!NT_STATUS_IS_OK(conn->status)) {
+ /*
+ * we're not supposed to do any io
+ */
+ TEVENT_FD_NOT_READABLE(conn->smb1.echo_handler.trusted_fde);
+ TEVENT_FD_NOT_WRITEABLE(conn->smb1.echo_handler.trusted_fde);
+ return;
+ }
+
if (flags & TEVENT_FD_WRITE) {
smbd_server_connection_write_handler(conn);
return;
diff --git a/source3/smbd/server_exit.c b/source3/smbd/server_exit.c
index c656908969..357c69a071 100644
--- a/source3/smbd/server_exit.c
+++ b/source3/smbd/server_exit.c
@@ -102,6 +102,17 @@ static void exit_server_common(enum server_exit_reason how,
if (sconn) {
NTSTATUS status;
+ if (NT_STATUS_IS_OK(sconn->status)) {
+ switch (how) {
+ case SERVER_EXIT_ABNORMAL:
+ sconn->status = NT_STATUS_INTERNAL_ERROR;
+ break;
+ case SERVER_EXIT_NORMAL:
+ sconn->status = NT_STATUS_LOCAL_DISCONNECT;
+ break;
+ }
+ }
+
TALLOC_FREE(sconn->smb1.negprot.auth_context);
if (lp_log_writeable_files_on_exit()) {
diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c
index fe42ac99f9..5e6bfd95ca 100644
--- a/source3/smbd/smb2_server.c
+++ b/source3/smbd/smb2_server.c
@@ -2841,6 +2841,13 @@ static NTSTATUS smbd_smb2_request_next_incoming(struct smbd_server_connection *s
size_t max_send_queue_len;
size_t cur_send_queue_len;
+ if (!NT_STATUS_IS_OK(sconn->status)) {
+ /*
+ * we're not supposed to do any io
+ */
+ return NT_STATUS_OK;
+ }
+
if (state->req != NULL) {
/*
* if there is already a tstream_readv_pdu
@@ -3087,6 +3094,15 @@ static NTSTATUS smbd_smb2_io_handler(struct smbd_server_connection *sconn,
NTSTATUS status;
NTTIME now;
+ if (!NT_STATUS_IS_OK(sconn->status)) {
+ /*
+ * we're not supposed to do any io
+ */
+ TEVENT_FD_NOT_READABLE(sconn->smb2.fde);
+ TEVENT_FD_NOT_WRITEABLE(sconn->smb2.fde);
+ return NT_STATUS_OK;
+ }
+
if (fde_flags & TEVENT_FD_WRITE) {
status = smbd_smb2_flush_send_queue(sconn);
if (!NT_STATUS_IS_OK(status)) {