From 3bf66a490e3ee24c0cbe0dbfc1525482f02b7c45 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 11 Dec 2019 15:06:40 -0800 Subject: [PATCH] s3: libsmbclient: Cope with SMB2 servers that return STATUS_USER_SESSION_DELETED on a SMB2_ECHO (SMB2_OP_KEEPALIVE) call with a NULL session. This is already tested by smb2.session.expire which shows that Windows and Samba servers don't need this, but some third party server are returning STATUS_USER_SESSION_DELETED with a NULL sessionid. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13218 Signed-off-by: Jeremy Allison --- source3/libsmb/libsmb_server.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c index 0067df48cac..84730b4b396 100644 --- a/source3/libsmb/libsmb_server.c +++ b/source3/libsmb/libsmb_server.c @@ -61,15 +61,34 @@ SMBC_check_server(SMBCCTX * context, 1, data_blob_const(data, sizeof(data))); if (!NT_STATUS_IS_OK(status)) { + bool ok = false; + /* + * Some SMB2 servers (not Samba or Windows) + * check the session status on SMB2_ECHO and return + * NT_STATUS_USER_SESSION_DELETED + * if the session was not set. That's OK, they still + * replied. + * BUG: https://bugzilla.samba.org/show_bug.cgi?id=13218 + */ + if (smbXcli_conn_protocol(server->cli->conn) >= + PROTOCOL_SMB2_02) { + if (NT_STATUS_EQUAL(status, + NT_STATUS_USER_SESSION_DELETED)) { + ok = true; + } + } /* * Some NetApp servers return * NT_STATUS_INVALID_PARAMETER.That's OK, they still * replied. * BUG: https://bugzilla.samba.org/show_bug.cgi?id=13007 */ - if (!NT_STATUS_EQUAL(status, + if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) { - return 1; + ok = true; + } + if (!ok) { + return -1; } } server->last_echo_time = now; -- 2.24.1.735.g03f4e72817-goog