From c90c057e1276cc92f6143eafc6f5aef9bdbd5ca5 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sat, 9 Mar 2019 21:39:56 -0500 Subject: [PATCH] GUACAMOLE-414: Add version checks for TLS locking. --- src/protocols/vnc/vnc.c | 7 +++++++ src/protocols/vnc/vnc.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/protocols/vnc/vnc.c b/src/protocols/vnc/vnc.c index d13826d1..54e88dca 100644 --- a/src/protocols/vnc/vnc.c +++ b/src/protocols/vnc/vnc.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -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); diff --git a/src/protocols/vnc/vnc.h b/src/protocols/vnc/vnc.h index 31e78461..de9b3239 100644 --- a/src/protocols/vnc/vnc.h +++ b/src/protocols/vnc/vnc.h @@ -32,6 +32,7 @@ #include #include #include +#include #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.