diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2013-03-28 08:55:23 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2013-03-28 08:55:23 +0100 |
commit | e77bf36d9afbc7e56522574b06217d57c11dd095 (patch) | |
tree | 123ed036d60c80c816474f516bc0198be58d8410 /nxcomp | |
parent | d16188f08b659a6dc2a150d84c5ed5d7bf5cf02b (diff) | |
download | nx-libs-e77bf36d9afbc7e56522574b06217d57c11dd095.tar.gz nx-libs-e77bf36d9afbc7e56522574b06217d57c11dd095.tar.bz2 nx-libs-e77bf36d9afbc7e56522574b06217d57c11dd095.zip |
release 3.5.0.19
Diffstat (limited to 'nxcomp')
-rw-r--r-- | nxcomp/Agent.h | 28 | ||||
-rw-r--r-- | nxcomp/Auth.cpp | 17 | ||||
-rw-r--r-- | nxcomp/Loop.cpp | 64 | ||||
-rw-r--r-- | nxcomp/Makefile.in | 41 | ||||
-rw-r--r-- | nxcomp/Message.cpp | 4 | ||||
-rw-r--r-- | nxcomp/Misc.cpp | 18 | ||||
-rw-r--r-- | nxcomp/Misc.h | 12 | ||||
-rw-r--r-- | nxcomp/Pgn.cpp | 6 | ||||
-rw-r--r-- | nxcomp/Proxy.cpp | 4 | ||||
-rw-r--r-- | nxcomp/Split.cpp | 2 | ||||
-rw-r--r-- | nxcomp/configure.in | 4 |
11 files changed, 147 insertions, 53 deletions
diff --git a/nxcomp/Agent.h b/nxcomp/Agent.h index fac5acd43..ded344d84 100644 --- a/nxcomp/Agent.h +++ b/nxcomp/Agent.h @@ -149,30 +149,38 @@ class Agent int remoteCanRead(const fd_set * const readSet) { + // OS X 10.5 requires the second argument to be non-const, so copy readSet. + // It's safe though, as FD_ISSET does not operate on it. + fd_set readWorkSet = *readSet; + #if defined(TEST) || defined(INFO) *logofs << "Agent: remoteCanRead() is " << - (FD_ISSET(remoteFd_, readSet) && transport_ -> dequeuable() != 0) - << " with FD_ISSET() " << (int) FD_ISSET(remoteFd_, readSet) + (FD_ISSET(remoteFd_, &readWorkSet) && transport_ -> dequeuable() != 0) + << " with FD_ISSET() " << (int) FD_ISSET(remoteFd_, &readWorkSet) << " and dequeuable " << transport_ -> dequeuable() << ".\n" << logofs_flush; #endif - return (FD_ISSET(remoteFd_, readSet) && + return (FD_ISSET(remoteFd_, &readWorkSet) && transport_ -> dequeuable() != 0); } int remoteCanWrite(const fd_set * const writeSet) { + // OS X 10.5 requires the second argument to be non-const, so copy writeSet. + // It's safe though, as FD_ISSET does not operate on it. + fd_set writeWorkSet = *writeSet; + #if defined(TEST) || defined(INFO) *logofs << "Agent: remoteCanWrite() is " << - (FD_ISSET(remoteFd_, writeSet) && transport_ -> + (FD_ISSET(remoteFd_, &writeWorkSet) && transport_ -> queuable() != 0 && canRead_ == 1) << " with FD_ISSET() " - << (int) FD_ISSET(remoteFd_, writeSet) << " queueable " + << (int) FD_ISSET(remoteFd_, &writeWorkSet) << " queueable " << transport_ -> queuable() << " channel can read " << canRead_ << ".\n" << logofs_flush; #endif - return (FD_ISSET(remoteFd_, writeSet) && + return (FD_ISSET(remoteFd_, &writeWorkSet) && transport_ -> queuable() != 0 && canRead_ == 1); } @@ -203,13 +211,17 @@ class Agent int proxyCanRead(const fd_set * const readSet) { + // OS X 10.5 requires the second argument to be non-const, so copy readSet. + // It's safe though, as FD_ISSET does not operate on it. + fd_set readWorkSet = *readSet; + #if defined(TEST) || defined(INFO) *logofs << "Agent: proxyCanRead() is " - << ((int) FD_ISSET(proxy -> getFd(), readSet) + << ((int) FD_ISSET(proxy -> getFd(), &readWorkSet) << ".\n" << logofs_flush; #endif - return (FD_ISSET(proxy -> getFd(), readSet)); + return (FD_ISSET(proxy -> getFd(), &readWorkSet)); } int enqueueData(const char *data, const int size) const diff --git a/nxcomp/Auth.cpp b/nxcomp/Auth.cpp index d8e999132..c52392a51 100644 --- a/nxcomp/Auth.cpp +++ b/nxcomp/Auth.cpp @@ -217,22 +217,31 @@ int Auth::getCookie() // // Use the nxauth command on Windows and the Mac, xauth - // on all the other platforms. On Windows and on the Mac - // we assume that the nxauth command is located under - // bin in the client installation directory. On all the + // on all the other platforms. On Windows we assume that + // the nxauth command is located under bin in the client + // installation directory. On Mac OS X we assume that the + // command is located directly in the client installation + // directory, to make bundle shipping easier. On all the // other platforms we use the default xauth command that // is in our path. // char command[DEFAULT_STRING_LIMIT]; - #if defined(__CYGWIN32__) || defined(__APPLE__) + #if defined(__CYGWIN32__) snprintf(command, DEFAULT_STRING_LIMIT - 1, "%s/bin/nxauth", control -> SystemPath); *(command + DEFAULT_STRING_LIMIT - 1) = '\0'; + #elif defined(__APPLE__) + + snprintf(command, DEFAULT_STRING_LIMIT - 1, + "%s/nxauth", control -> SystemPath); + + *(command + DEFAULT_STRING_LIMIT - 1) = '\0'; + #else strcpy(command, "xauth"); diff --git a/nxcomp/Loop.cpp b/nxcomp/Loop.cpp index 92b6fc28f..8069af598 100644 --- a/nxcomp/Loop.cpp +++ b/nxcomp/Loop.cpp @@ -952,6 +952,7 @@ static char listenHost[DEFAULT_STRING_LENGTH] = { 0 }; static char displayHost[DEFAULT_STRING_LENGTH] = { 0 }; static char authCookie[DEFAULT_STRING_LENGTH] = { 0 }; +static int loopbackBind = DEFAULT_LOOPBACK_BIND; static int proxyPort = DEFAULT_NX_PROXY_PORT; static int xPort = DEFAULT_NX_X_PORT; @@ -3959,7 +3960,14 @@ int SetupTcpSocket() tcpAddr.sin_family = AF_INET; tcpAddr.sin_port = htons(proxyPortTCP); - tcpAddr.sin_addr.s_addr = htonl(INADDR_ANY); + if ( loopbackBind ) + { + tcpAddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + } + else + { + tcpAddr.sin_addr.s_addr = htonl(INADDR_ANY); + } if (bind(tcpFD, (sockaddr *) &tcpAddr, sizeof(tcpAddr)) == -1) { @@ -4512,7 +4520,14 @@ int ListenConnection(int port, const char *label) tcpAddr.sin_family = AF_INET; tcpAddr.sin_port = htons(portTCP); - tcpAddr.sin_addr.s_addr = htonl(INADDR_ANY); + if ( loopbackBind ) + { + tcpAddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + } + else + { + tcpAddr.sin_addr.s_addr = htonl(INADDR_ANY); + } if (bind(newFD, (sockaddr *) &tcpAddr, sizeof(tcpAddr)) == -1) { @@ -5884,20 +5899,9 @@ void InstallSignal(int signal, int action) struct sigaction newAction; - newAction.sa_handler = HandleSignal; - - // - // This field doesn't exist on most OSes except - // Linux. We keep setting the field to NULL to - // avoid side-effects in the case the field is - // a value return. - // + memset(&newAction, 0, sizeof(newAction)); - #if defined(__linux__) - - newAction.sa_restorer = NULL; - - #endif + newAction.sa_handler = HandleSignal; sigemptyset(&(newAction.sa_mask)); @@ -6509,13 +6513,9 @@ void SetTimer(int value) struct sigaction action; - action.sa_handler = HandleTimer; - - #if defined(__linux__) - - action.sa_restorer = NULL; + memset(&action, 0, sizeof(action)); - #endif + action.sa_handler = HandleTimer; sigemptyset(&action.sa_mask); @@ -6695,7 +6695,14 @@ int WaitForRemote(int portNum) #ifdef __APPLE__ - tcpAddr.sin_addr.s_addr = htonl(INADDR_ANY); + if ( loopbackBind ) + { + tcpAddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + } + else + { + tcpAddr.sin_addr.s_addr = htonl(INADDR_ANY); + } #else @@ -8374,6 +8381,10 @@ int ParseEnvironmentOptions(const char *env, int force) listenPort = ValidateArg("local", name, value); } + else if (strcasecmp(name, "loopback") == 0) + { + loopbackBind = ValidateArg("local", name, value); + } else if (strcasecmp(name, "accept") == 0) { if (*connectHost != '\0') @@ -13750,7 +13761,14 @@ int ParseListenOption(int &address) } else { - address = htonl(INADDR_ANY); + if ( loopbackBind ) + { + address = htonl(INADDR_LOOPBACK); + } + else + { + address = htonl(INADDR_ANY); + } } } else diff --git a/nxcomp/Makefile.in b/nxcomp/Makefile.in index 434118b4e..5a8633281 100644 --- a/nxcomp/Makefile.in +++ b/nxcomp/Makefile.in @@ -64,10 +64,15 @@ exec_prefix = @exec_prefix@ bindir = @bindir@ man1dir = @mandir@/man1 VPATH = @srcdir@ +libdir = @libdir@ +includedir = @includedir@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ +INSTALL_LINK = cp -av +DESTDIR = +RM_FILE = rm -f # # This should be autodetected. @@ -264,16 +269,48 @@ depend.status: fi touch depend.status -install: install.bin install.man +install: install.bin install.lib install.man install.bin: +install.lib: all + ./mkinstalldirs $(DESTDIR)${libdir}/nx + ./mkinstalldirs $(DESTDIR)${includedir}/nx + $(INSTALL_DATA) $(LIBFULL) $(DESTDIR)${libdir}/nx + $(INSTALL_LINK) libXcomp.so.3 $(DESTDIR)${libdir}/nx + $(INSTALL_LINK) libXcomp.so $(DESTDIR)${libdir}/nx + $(INSTALL_DATA) libXcomp.a $(DESTDIR)${libdir}/nx + $(INSTALL_DATA) NX*.h $(DESTDIR)${includedir}/nx + $(INSTALL_DATA) MD5.h $(DESTDIR)${includedir}/nx + echo "Running ldconfig tool, this may take a while..." && ldconfig || true + install.man: +uninstall: uninstall.bin uninstall.lib uninstall.man + +uninstall.bin: + +uninstall.lib: + $(RM_FILE) $(DESTDIR)${libdir}/nx/$(LIBFULL) + $(RM_FILE) $(DESTDIR)${libdir}/nx/libXcomp.so.3 + $(RM_FILE) $(DESTDIR)${libdir}/nx/libXcomp.so + $(RM_FILE) $(DESTDIR)${libdir}/nx/libXcomp.a + $(RM_FILE) $(DESTDIR)${includedir}/nx/NXalert.h + $(RM_FILE) $(DESTDIR)${includedir}/nx/NX.h + $(RM_FILE) $(DESTDIR)${includedir}/nx/NXmitshm.h + $(RM_FILE) $(DESTDIR)${includedir}/nx/NXpack.h + $(RM_FILE) $(DESTDIR)${includedir}/nx/NXproto.h + $(RM_FILE) $(DESTDIR)${includedir}/nx/NXrender.h + $(RM_FILE) $(DESTDIR)${includedir}/nx/NXvars.h + $(RM_FILE) $(DESTDIR)${includedir}/nx/MD5.h + echo "Running ldconfig tool, this may take a while..." && ldconfig || true + +uninstall.man: + clean: -rm -f *~ *.o *.bak *.orig *.rej st?????? core core.* *.out.* \ @ALL@ distclean: clean -rm -rf autom4te.cache config.status config.log \ - config.cache depend.status Makefile tags + config.cache depend.status Makefile tags configure diff --git a/nxcomp/Message.cpp b/nxcomp/Message.cpp index 72d4fff3d..188ed9a0e 100644 --- a/nxcomp/Message.cpp +++ b/nxcomp/Message.cpp @@ -15,9 +15,9 @@ /* */ /**************************************************************************/ -#include <stdio.h> +#include <cstdio> #include <unistd.h> -#include <string.h> +#include <cstring> #include <algorithm> diff --git a/nxcomp/Misc.cpp b/nxcomp/Misc.cpp index 2c72259e3..0095eaa74 100644 --- a/nxcomp/Misc.cpp +++ b/nxcomp/Misc.cpp @@ -15,11 +15,11 @@ /* */ /**************************************************************************/ -#include <stdio.h> -#include <ctype.h> -#include <stdlib.h> +#include <cstdio> +#include <cctype> +#include <cstdlib> #include <unistd.h> -#include <signal.h> +#include <csignal> #include <errno.h> #include <string.h> @@ -42,6 +42,14 @@ #undef DEBUG // +// By default nxproxy binds to all network interfaces, setting +// DEFAULT_LOOPBACK_BIND to 1 enables binding to the loopback +// device only. +// + +const int DEFAULT_LOOPBACK_BIND = 0; + +// // TCP port offset applied to any NX port specification. // @@ -137,6 +145,8 @@ static const char UsageInfo[] = \n\ listen=n Local port used for accepting the proxy connection.\n\ \n\ + loopback=b Bind to the loopback device only.\n\ +\n\ accept=s Name or IP of host that can connect to the proxy.\n\ \n\ connect=s Name or IP of host that the proxy will connect to.\n\ diff --git a/nxcomp/Misc.h b/nxcomp/Misc.h index 200831757..21a503082 100644 --- a/nxcomp/Misc.h +++ b/nxcomp/Misc.h @@ -21,8 +21,8 @@ #include <iostream> #include <fstream> -#include <errno.h> -#include <string.h> +#include <cerrno> +#include <cstring> #ifdef __sun @@ -90,6 +90,14 @@ extern const int DEFAULT_NX_SLAVE_PORT_CLIENT_OFFSET; extern const int DEFAULT_NX_SLAVE_PORT_SERVER_OFFSET; // +// NX proxy binds to all network interfaces by default +// With the -loopback parameter, you can switch +// over to binding to the loopback device only. +// + +extern const int DEFAULT_LOOPBACK_BIND; + +// // Return strings containing various info. // diff --git a/nxcomp/Pgn.cpp b/nxcomp/Pgn.cpp index a68373441..af26724ef 100644 --- a/nxcomp/Pgn.cpp +++ b/nxcomp/Pgn.cpp @@ -414,7 +414,7 @@ int DecompressPng16(unsigned char *compressedData, int compressedLen, png_read_info(pngPtr, infoPtr); - if (infoPtr -> color_type == PNG_COLOR_TYPE_PALETTE) + if (png_get_color_type(pngPtr, infoPtr) == PNG_COLOR_TYPE_PALETTE) { png_set_expand(pngPtr); } @@ -565,7 +565,7 @@ int DecompressPng24(unsigned char *compressedData, int compressedLen, png_read_info( pngPtr, infoPtr ) ; - if (infoPtr -> color_type == PNG_COLOR_TYPE_PALETTE) + if (png_get_color_type(pngPtr, infoPtr) == PNG_COLOR_TYPE_PALETTE) { png_set_expand(pngPtr); } @@ -709,7 +709,7 @@ int DecompressPng32(unsigned char *compressedData, int compressedLen, png_read_info(pngPtr, infoPtr) ; - if (infoPtr -> color_type == PNG_COLOR_TYPE_PALETTE) + if (png_get_color_type(pngPtr, infoPtr) == PNG_COLOR_TYPE_PALETTE) { png_set_expand(pngPtr); } diff --git a/nxcomp/Proxy.cpp b/nxcomp/Proxy.cpp index 3b4df7eb6..d6c67e0e8 100644 --- a/nxcomp/Proxy.cpp +++ b/nxcomp/Proxy.cpp @@ -15,9 +15,9 @@ /* */ /**************************************************************************/ -#include <stdio.h> +#include <cstdio> #include <unistd.h> -#include <stdlib.h> +#include <cstdlib> #include <sys/types.h> #include <sys/stat.h> diff --git a/nxcomp/Split.cpp b/nxcomp/Split.cpp index 50627e793..35a4ed4a2 100644 --- a/nxcomp/Split.cpp +++ b/nxcomp/Split.cpp @@ -16,7 +16,7 @@ /**************************************************************************/ #include <unistd.h> -#include <string.h> +#include <cstring> #include <sys/stat.h> #include <sys/types.h> #include <utime.h> diff --git a/nxcomp/configure.in b/nxcomp/configure.in index e9ab81da8..6fa9757a7 100644 --- a/nxcomp/configure.in +++ b/nxcomp/configure.in @@ -7,8 +7,8 @@ AC_PREREQ(2.13) dnl Set our default compilation flags. -CXXFLAGS="-O3 -fno-rtti -fno-exceptions" -CFLAGS="-O3" +CXXFLAGS="$CXXFLAGS -O3 -fno-rtti -fno-exceptions" +CFLAGS="$CFLAGS -O3" dnl Reset default linking directives. |