From 1f50d04a5cf3ec8909ebf5b7547adef2b16af0cb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 11 Jul 2011 13:56:10 +0200 Subject: s3:auth_server: use cli_echo() to check if the server is alive This works over port 139 and also 445. send_keepalive() would only work on port 139. metze --- source3/auth/auth_server.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'source3') diff --git a/source3/auth/auth_server.c b/source3/auth/auth_server.c index a942c74bf6..1b7993bb9c 100644 --- a/source3/auth/auth_server.c +++ b/source3/auth/auth_server.c @@ -158,20 +158,25 @@ static bool send_server_keepalive(const struct timeval *now, { struct server_security_state *state = talloc_get_type_abort( private_data, struct server_security_state); + NTSTATUS status; + unsigned char garbage[16]; if (!cli_state_is_connected(state->cli)) { return false; } - if (send_keepalive(state->cli->fd)) { - return True; + /* Ping the server to keep the connection alive using SMBecho. */ + memset(garbage, 0xf0, sizeof(garbage)); + status = cli_echo(state->cli, 1, data_blob_const(garbage, sizeof(garbage))); + if (NT_STATUS_IS_OK(status)) { + return true; } - DEBUG( 2, ( "send_server_keepalive: password server keepalive " - "failed.\n")); + DEBUG(2,("send_server_keepalive: password server SMBecho failed: %s\n", + nt_errstr(status))); cli_shutdown(state->cli); state->cli = NULL; - return False; + return false; } static int destroy_server_security(struct server_security_state *state) -- cgit