GUACAMOLE-414: Add version checks for TLS locking.

This commit is contained in:
Nick Couchman 2019-03-09 21:39:56 -05:00
parent e9a10d66b7
commit c90c057e12
2 changed files with 10 additions and 0 deletions

View File

@ -47,6 +47,7 @@
#include <guacamole/socket.h>
#include <guacamole/timestamp.h>
#include <rfb/rfbclient.h>
#include <rfb/rfbconfig.h>
#include <rfb/rfbproto.h>
#include <stdlib.h>
@ -55,6 +56,7 @@
char* GUAC_VNC_CLIENT_KEY = "GUAC_VNC";
#if LIBVNCSERVER_VERSION_MAJOR >=0 && LIBVNCSERVER_VERSION_MINOR >= 9 && LIBVNCSERVER_VERSION_PATCHLEVEL >= 11
/**
* A callback function that is called by the VNC library prior to writing
* data to a TLS-encrypted socket. This returns the rfbBool FALSE value
@ -110,6 +112,7 @@ static rfbBool guac_vnc_unlock_write_to_tls(rfbClient* rfb_client) {
}
return TRUE;
}
#endif
rfbClient* guac_vnc_get_client(guac_client* client) {
@ -124,9 +127,11 @@ rfbClient* guac_vnc_get_client(guac_client* client) {
rfb_client->GotFrameBufferUpdate = guac_vnc_update;
rfb_client->GotCopyRect = guac_vnc_copyrect;
#if LIBVNCSERVER_VERSION_MAJOR >=0 && LIBVNCSERVER_VERSION_MINOR >= 9 && LIBVNCSERVER_VERSION_PATCHLEVEL >= 11
/* TLS Locking and Unlocking */
rfb_client->LockWriteToTLS = guac_vnc_lock_write_to_tls;
rfb_client->UnlockWriteToTLS = guac_vnc_unlock_write_to_tls;
#endif
/* Do not handle clipboard and local cursor if read-only */
if (vnc_settings->read_only == 0) {
@ -242,8 +247,10 @@ void* guac_vnc_client_thread(void* data) {
rfbClientLog = guac_vnc_client_log_info;
rfbClientErr = guac_vnc_client_log_error;
#if LIBVNCSERVER_VERSION_MAJOR >=0 && LIBVNCSERVER_VERSION_MINOR >= 9 && LIBVNCSERVER_VERSION_PATCHLEVEL >= 11
/* Initialize the write lock */
pthread_mutex_init(&(vnc_client->tls_lock), NULL);
#endif
/* Attempt connection */
rfbClient* rfb_client = guac_vnc_get_client(client);

View File

@ -32,6 +32,7 @@
#include <guacamole/client.h>
#include <guacamole/layer.h>
#include <rfb/rfbclient.h>
#include <rfb/rfbconfig.h>
#ifdef ENABLE_PULSE
#include "pulse/pulse.h"
@ -55,10 +56,12 @@ typedef struct guac_vnc_client {
*/
pthread_t client_thread;
#if LIBVNCSERVER_VERSION_MAJOR >=0 && LIBVNCSERVER_VERSION_MINOR >= 9 && LIBVNCSERVER_VERSION_PATCHLEVEL >= 11
/**
* The TLS mutex lock for the client.
*/
pthread_mutex_t tls_lock;
#endif
/**
* The underlying VNC client.