1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

s3: lib: libsmbclient: If reusing a server struct, check every cli->timout miliseconds if it's still valid before use.

Uses an cli_echo() call to do so.

Based on code from <shargagan@novell.com>

Bug 11079 - libsmbclient not checking the cached connection alive status before re-using it from connection cache

https://bugzilla.samba.org/show_bug.cgi?id=11079

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>

Autobuild-User(master): David Disseldorp <ddiss@samba.org>
Autobuild-Date(master): Fri Mar 20 13:48:26 CET 2015 on sn-devel-104
This commit is contained in:
Jeremy Allison 2015-03-18 14:15:16 -07:00 committed by David Disseldorp
parent 00d92f5925
commit 4f4151ea05
2 changed files with 17 additions and 0 deletions

View File

@ -81,6 +81,7 @@ struct _SMBCSRV {
bool no_pathinfo3;
bool no_nt_session;
struct policy_handle pol;
time_t last_echo_time;
SMBCSRV *next, *prev;
};

View File

@ -45,10 +45,26 @@ int
SMBC_check_server(SMBCCTX * context,
SMBCSRV * server)
{
time_t now;
if (!cli_state_is_connected(server->cli)) {
return 1;
}
now = time_mono(NULL);
if (server->last_echo_time == (time_t)0 ||
now > server->last_echo_time +
(server->cli->timeout/1000)) {
unsigned char data[16] = {0};
NTSTATUS status = cli_echo(server->cli,
1,
data_blob_const(data, sizeof(data)));
if (!NT_STATUS_IS_OK(status)) {
return 1;
}
server->last_echo_time = now;
}
return 0;
}