From 3a28534232c49778f03d21712589712e3e283f8f Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 25 Oct 2013 17:49:22 -0700 Subject: [PATCH] Ticket #429: Detect listenForIncomingConnectionsNoFork() function, conditionally compile listen support. --- configure.ac | 25 +++++++++++++++++++++++++ src/protocols/vnc/client.c | 12 +++++++++++- src/protocols/vnc/client.h | 2 ++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 632853e5..87eaf181 100644 --- a/configure.ac +++ b/configure.ac @@ -230,6 +230,31 @@ then fi +# +# Listening support within libVNCServer +# + +if test "x${have_libvncserver}" = "xyes" +then + + have_vnc_listen=yes + AC_CHECK_DECL([listenForIncomingConnectionsNoFork], + [], [have_vnc_listen=no], + [[#include ]]) + + if test "x${have_vnc_listen}" = "xno" + then + AC_MSG_WARN([ + -------------------------------------------- + No listening support found in libvncclient. + Support for listen-mode connections will not be built. + --------------------------------------------]) + else + AC_DEFINE([ENABLE_VNC_LISTEN]) + fi + +fi + # # FreeRDP # diff --git a/src/protocols/vnc/client.c b/src/protocols/vnc/client.c index 50cdd9d0..a13b2385 100644 --- a/src/protocols/vnc/client.c +++ b/src/protocols/vnc/client.c @@ -77,8 +77,11 @@ const char* GUAC_CLIENT_ARGS[] = { "audio-servername", #endif +#ifdef ENABLE_VNC_LISTEN "reverse-connect", "listen-timeout", +#endif + NULL }; @@ -104,8 +107,11 @@ enum VNC_ARGS_IDX { IDX_AUDIO_SERVERNAME, #endif +#ifdef ENABLE_VNC_LISTEN IDX_REVERSE_CONNECT, IDX_LISTEN_TIMEOUT, +#endif + VNC_ARGS_COUNT }; @@ -169,6 +175,7 @@ static rfbClient* __guac_vnc_get_client(guac_client* client) { } #endif +#ifdef ENABLE_VNC_LISTEN /* If reverse connection enabled, start listening */ if (guac_client_data->reverse_connect) { @@ -182,6 +189,7 @@ static rfbClient* __guac_vnc_get_client(guac_client* client) { return NULL; } +#endif /* Set encodings if provided */ if (guac_client_data->encodings) @@ -264,6 +272,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) { else retries_remaining = 0; +#ifdef ENABLE_VNC_LISTEN /* Set reverse-connection flag */ guac_client_data->reverse_connect = (strcmp(argv[IDX_REVERSE_CONNECT], "true") == 0); @@ -272,7 +281,8 @@ int guac_client_init(guac_client* client, int argc, char** argv) { if (argv[IDX_LISTEN_TIMEOUT][0] != '\0') guac_client_data->listen_timeout = atoi(argv[IDX_LISTEN_TIMEOUT]); else - guac_client_data->listen_timeout = 5000; + guac_client_data->listen_timeout = 5000; +#endif /* Ensure connection is kept alive during lengthy connects */ guac_socket_require_keep_alive(client->socket); diff --git a/src/protocols/vnc/client.h b/src/protocols/vnc/client.h index 3752c0ef..c8133f61 100644 --- a/src/protocols/vnc/client.h +++ b/src/protocols/vnc/client.h @@ -134,6 +134,7 @@ typedef struct vnc_guac_client_data { */ int dest_port; +#ifdef ENABLE_VNC_LISTEN /** * Whether not actually connecting to a VNC server, but rather listening * for a connection from the VNC server (reverse connection). @@ -145,6 +146,7 @@ typedef struct vnc_guac_client_data { * milliseconds. */ int listen_timeout; +#endif /** * Whether the cursor should be rendered on the server (remote) or on the