From: Jeremy Allison Date: Wed, 11 Dec 2019 23:06:40 +0000 (-0800) Subject: s3: libsmbclient: Cope with SMB2 servers that return STATUS_USER_SESSION_DELETED... X-Git-Tag: talloc-2.3.4~186 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=be2e2044b8ef56112162a42ac19b3791c787916b;p=thirdparty%2Fsamba.git 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 Reviewed-by: Bjoern Jacke Autobuild-User(master): Björn Jacke Autobuild-Date(master): Wed May 11 18:06:42 UTC 2022 on sn-devel-184 --- diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c index 09d27868c0e..ce17e4fed09 100644 --- a/source3/libsmb/libsmb_server.c +++ b/source3/libsmb/libsmb_server.c @@ -61,14 +61,33 @@ 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)) { + ok = true; + } + if (!ok) { return 1; } }