s3:auth_server: use cli_echo() to check if the server is alive
authorStefan Metzmacher <metze@samba.org>
Mon, 11 Jul 2011 11:56:10 +0000 (13:56 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 11 Jul 2011 16:18:28 +0000 (18:18 +0200)
This works over port 139 and also 445. send_keepalive() would
only work on port 139.

metze

source3/auth/auth_server.c

index a942c74bf68dc2d3b76a88e0b84d3dcc7dbe7e5c..1b7993bb9cd8e3f1351739c4d4a40b100f01366a 100644 (file)
@@ -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)