From 5881209f1261e8d45d12acb9eb8af3e8d694f5f0 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sat, 27 Jun 2020 17:55:43 -0400 Subject: [PATCH] GUACAMOLE-221: Move keep-alives to protocol implementation and only send required instruction to owner. --- src/libguac/protocol.c | 3 --- src/protocols/rdp/rdp.c | 5 +++-- src/protocols/ssh/ssh.c | 7 ++++--- src/protocols/vnc/auth.c | 5 +++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libguac/protocol.c b/src/libguac/protocol.c index 284c94b5..ff903c4b 100644 --- a/src/libguac/protocol.c +++ b/src/libguac/protocol.c @@ -981,9 +981,6 @@ int guac_protocol_send_required(guac_socket* socket, const char** required) { guac_socket_instruction_begin(socket); - // The socket should be kept alive while waiting for user response. - guac_socket_require_keep_alive(socket); - if (guac_socket_write_string(socket, "8.required")) return -1; diff --git a/src/protocols/rdp/rdp.c b/src/protocols/rdp/rdp.c index fb52dff5..75a20bda 100644 --- a/src/protocols/rdp/rdp.c +++ b/src/protocols/rdp/rdp.c @@ -258,8 +258,9 @@ static BOOL rdp_freerdp_authenticate(freerdp* instance, char** username, pthread_mutex_lock(&(rdp_client->rdp_credential_lock)); /* Send require params and flush socket. */ - guac_protocol_send_required(client->socket, (const char**) params); - guac_socket_flush(client->socket); + guac_socket_require_keep_alive(client->__owner->socket); + guac_protocol_send_required(client->__owner->socket, (const char**) params); + guac_socket_flush(client->__owner->socket); /* Wait for condition. */ pthread_cond_wait(&(rdp_client->rdp_credential_cond), &(rdp_client->rdp_credential_lock)); diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c index 74e0e8cb..d2bc5b12 100644 --- a/src/protocols/ssh/ssh.c +++ b/src/protocols/ssh/ssh.c @@ -76,9 +76,10 @@ static void guac_ssh_get_credential(guac_client *client, char* cred_name) { /* Lock the terminal thread while prompting for the credential. */ pthread_mutex_lock(&(ssh_client->term_channel_lock)); - /* Let the client know what we require and flush the socket. */ - guac_protocol_send_required(client->socket, (const char* []) {cred_name, NULL}); - guac_socket_flush(client->socket); + /* Let the owner know what we require and flush the socket. */ + guac_socket_require_keep_alive(client->__owner->socket); + guac_protocol_send_required(client->__owner->socket, (const char* []) {cred_name, NULL}); + guac_socket_flush(client->__owner->socket); /* Wait for the response, and then unlock the thread. */ pthread_cond_wait(&(ssh_client->ssh_credential_cond), &(ssh_client->term_channel_lock)); diff --git a/src/protocols/vnc/auth.c b/src/protocols/vnc/auth.c index 47aae87f..6ea21a38 100644 --- a/src/protocols/vnc/auth.c +++ b/src/protocols/vnc/auth.c @@ -42,9 +42,10 @@ char* guac_vnc_get_password(rfbClient* client) { pthread_mutex_lock(&(vnc_client->vnc_credential_lock)); /* Send the request for password and flush the socket. */ - guac_protocol_send_required(gc->socket, + guac_socket_require_keep_alive(gc->__owner->socket); + guac_protocol_send_required(gc->__owner->socket, (const char* []) {"password", NULL}); - guac_socket_flush(gc->socket); + guac_socket_flush(gc->__owner->socket); /* Set the conditional flag. */ vnc_client->vnc_credential_flags |= GUAC_VNC_COND_FLAG_PASSWORD;