GUACAMOLE-221: Implement function for sending required to client owner.

This commit is contained in:
Nick Couchman 2020-06-27 19:57:12 -04:00
parent 5ec2551761
commit c579e7337f
5 changed files with 43 additions and 11 deletions

View File

@ -478,6 +478,25 @@ int guac_client_load_plugin(guac_client* client, const char* protocol) {
} }
int guac_client_owner_send_required(guac_client* client, const char** required) {
int retval;
pthread_rwlock_rdlock(&(client->__users_lock));
/* Invoke callback with current owner */
retval = guac_protocol_send_required(client->__owner->socket, required);
/* Flush the socket */
guac_socket_flush(client->__owner->socket);
pthread_rwlock_unlock(&(client->__users_lock));
/* Return value from sending required */
return retval;
}
/** /**
* Updates the provided approximate processing lag, taking into account the * Updates the provided approximate processing lag, taking into account the
* processing lag of the given user. * processing lag of the given user.

View File

@ -549,6 +549,22 @@ int guac_client_load_plugin(guac_client* client, const char* protocol);
*/ */
int guac_client_get_processing_lag(guac_client* client); int guac_client_get_processing_lag(guac_client* client);
/**
* Sends a request to the owner of the given guac_client for parameters required
* to continue the connection started by the client. The function returns zero
* on success or non-zero on failure.
*
* @param client
* The client where additional connection parameters are required.
*
* @param required
* The NULL-terminated array of required parameters.
*
* @return
* Zero on success, non-zero on failure.
*/
int guac_client_owner_send_required(guac_client* client, const char** required);
/** /**
* Streams the given connection parameter value over an argument value stream * Streams the given connection parameter value over an argument value stream
* ("argv" instruction), exposing the current value of the named connection * ("argv" instruction), exposing the current value of the named connection

View File

@ -258,9 +258,8 @@ static BOOL rdp_freerdp_authenticate(freerdp* instance, char** username,
pthread_mutex_lock(&(rdp_client->rdp_credential_lock)); pthread_mutex_lock(&(rdp_client->rdp_credential_lock));
/* Send require params and flush socket. */ /* Send require params and flush socket. */
guac_socket_require_keep_alive(client->__owner->socket); guac_socket_require_keep_alive(client->socket);
guac_protocol_send_required(client->__owner->socket, (const char**) params); guac_client_owner_send_required(client, (const char**) params);
guac_socket_flush(client->__owner->socket);
/* Wait for condition. */ /* Wait for condition. */
pthread_cond_wait(&(rdp_client->rdp_credential_cond), &(rdp_client->rdp_credential_lock)); pthread_cond_wait(&(rdp_client->rdp_credential_cond), &(rdp_client->rdp_credential_lock));

View File

@ -78,9 +78,8 @@ static void guac_ssh_get_credential(guac_client *client, char* cred_name) {
pthread_mutex_lock(&(ssh_client->term_channel_lock)); pthread_mutex_lock(&(ssh_client->term_channel_lock));
/* Let the owner know what we require and flush the socket. */ /* Let the owner know what we require and flush the socket. */
guac_socket_require_keep_alive(client->__owner->socket); guac_socket_require_keep_alive(client->socket);
guac_protocol_send_required(client->__owner->socket, (const char* []) {cred_name, NULL}); guac_client_owner_send_required(client, (const char* []) {cred_name, NULL});
guac_socket_flush(client->__owner->socket);
/* Wait for the response, and then unlock the thread. */ /* Wait for the response, and then unlock the thread. */
pthread_cond_wait(&(ssh_client->ssh_credential_cond), &(ssh_client->term_channel_lock)); pthread_cond_wait(&(ssh_client->ssh_credential_cond), &(ssh_client->term_channel_lock));

View File

@ -42,10 +42,9 @@ char* guac_vnc_get_password(rfbClient* client) {
pthread_mutex_lock(&(vnc_client->vnc_credential_lock)); pthread_mutex_lock(&(vnc_client->vnc_credential_lock));
/* Send the request for password and flush the socket. */ /* Send the request for password and flush the socket. */
guac_socket_require_keep_alive(gc->__owner->socket); guac_socket_require_keep_alive(gc->socket);
guac_protocol_send_required(gc->__owner->socket, guac_client_owner_send_required(gc,
(const char* []) {GUAC_VNC_PARAMETER_NAME_PASSWORD, NULL}); (const char* []) {GUAC_VNC_PARAMETER_NAME_PASSWORD, NULL});
guac_socket_flush(gc->__owner->socket);
/* Set the conditional flag. */ /* Set the conditional flag. */
vnc_client->vnc_credential_flags |= GUAC_VNC_COND_FLAG_PASSWORD; vnc_client->vnc_credential_flags |= GUAC_VNC_COND_FLAG_PASSWORD;
@ -93,8 +92,8 @@ rfbCredential* guac_vnc_get_credentials(rfbClient* client, int credentialType) {
pthread_mutex_lock(&(vnc_client->vnc_credential_lock)); pthread_mutex_lock(&(vnc_client->vnc_credential_lock));
/* Send required parameters to client and flush the socket. */ /* Send required parameters to client and flush the socket. */
guac_protocol_send_required(gc->socket, (const char**) params); guac_socket_require_keep_alive(gc->socket);
guac_socket_flush(gc->socket); guac_client_owner_send_required(gc, (const char**) params);
/* Wait for the parameters to be returned. */ /* Wait for the parameters to be returned. */
pthread_cond_wait(&(vnc_client->vnc_credential_cond), pthread_cond_wait(&(vnc_client->vnc_credential_cond),