diff options
Diffstat (limited to 'x11vnc/misc/enhanced_tightvnc_viewer/src/patches/stunnel-maxconn.patch')
-rw-r--r-- | x11vnc/misc/enhanced_tightvnc_viewer/src/patches/stunnel-maxconn.patch | 140 |
1 files changed, 36 insertions, 104 deletions
diff --git a/x11vnc/misc/enhanced_tightvnc_viewer/src/patches/stunnel-maxconn.patch b/x11vnc/misc/enhanced_tightvnc_viewer/src/patches/stunnel-maxconn.patch index 7067a7c..be20097 100644 --- a/x11vnc/misc/enhanced_tightvnc_viewer/src/patches/stunnel-maxconn.patch +++ b/x11vnc/misc/enhanced_tightvnc_viewer/src/patches/stunnel-maxconn.patch @@ -1,124 +1,56 @@ diff -Naur stunnel.orig/src/client.c stunnel/src/client.c ---- stunnel.orig/src/client.c 2005-10-24 14:00:56.000000000 -0400 -+++ stunnel/src/client.c 2006-07-31 21:51:37.000000000 -0400 -@@ -126,6 +126,10 @@ +--- stunnel.orig/src/client.c 2008-03-27 04:35:27.000000000 -0400 ++++ stunnel/src/client.c 2008-11-19 21:40:00.000000000 -0500 +@@ -191,6 +191,7 @@ + enter_critical_section(CRIT_CLIENTS); /* for multi-cpu machines */ s_log(LOG_DEBUG, "%s finished (%d left)", c->opt->servname, --num_clients); ++ if (getenv("STUNNEL_ONCE")) {fprintf(stderr, "stunnel: exiting.\n"); exit(0);} leave_critical_section(CRIT_CLIENTS); -+ if (num_clients <= 0 && options.maxconn > 0 && num_conn >= options.maxconn) { -+ s_log(LOG_NOTICE, "client() finished: exceeded maxconn"); -+ exit(0); -+ } #endif - free(c); - #ifdef DEBUG_STACK_SIZE + } diff -Naur stunnel.orig/src/network.c stunnel/src/network.c ---- stunnel.orig/src/network.c 2005-10-30 16:35:42.000000000 -0500 -+++ stunnel/src/network.c 2006-07-31 21:53:49.000000000 -0400 -@@ -329,6 +329,10 @@ +--- stunnel.orig/src/network.c 2008-03-27 05:28:16.000000000 -0400 ++++ stunnel/src/network.c 2008-11-19 21:39:41.000000000 -0500 +@@ -346,6 +346,7 @@ /* no logging is possible in a signal handler */ #ifdef USE_FORK - num_clients--; /* one client less */ -+ if (num_clients <= 0 && options.maxconn > 0 && num_conn >= options.maxconn) { -+ s_log(LOG_NOTICE, "sigchld_handler() finished: exceeded maxconn"); -+ exit(0); -+ } + --num_clients; /* one client less */ ++ if (getenv("STUNNEL_ONCE")) exit(0); #endif /* USE_FORK */ } #else /* __sgi */ -@@ -375,6 +379,10 @@ +@@ -432,9 +433,11 @@ + #ifdef HAVE_WAIT_FOR_PID + while((pid=wait_for_pid(-1, &status, WNOHANG))>0) { + --num_clients; /* one client less */ ++ if (getenv("STUNNEL_ONCE")) exit(0); + #else if((pid=wait(&status))>0) { - num_clients--; /* one client less */ + --num_clients; /* one client less */ ++ if (getenv("STUNNEL_ONCE")) exit(0); #endif -+ if (num_clients <= 0 && options.maxconn > 0 && num_conn >= options.maxconn) { -+ s_log(LOG_NOTICE, "client_status() finished: exceeded maxconn"); -+ exit(0); -+ } #ifdef WIFSIGNALED if(WIFSIGNALED(status)) { - s_log(LOG_DEBUG, "Process %d terminated on signal %d (%d left)", diff -Naur stunnel.orig/src/options.c stunnel/src/options.c ---- stunnel.orig/src/options.c 2005-10-20 03:12:07.000000000 -0400 -+++ stunnel/src/options.c 2006-07-31 22:49:57.000000000 -0400 -@@ -665,6 +665,24 @@ +--- stunnel.orig/src/options.c 2008-06-21 17:18:23.000000000 -0400 ++++ stunnel/src/options.c 2008-11-19 21:15:01.000000000 -0500 +@@ -465,6 +465,7 @@ + switch(cmd) { + case CMD_INIT: + options.option.syslog=1; ++ if (getenv("STUNNEL_NO_SYSLOG")) options.option.syslog=0; break; - } - -+ /* maxconn */ -+ switch(cmd) { -+ case CMD_INIT: -+ options.maxconn=0; -+ break; -+ case CMD_EXEC: -+ if(strcasecmp(opt, "maxconn")) -+ break; -+ options.maxconn=atoi(arg); -+ return NULL; /* OK */ -+ case CMD_DEFAULT: -+ log_raw("%-15s = 0", "maxconn"); -+ break; -+ case CMD_HELP: -+ log_raw("%-15s = maximum number of accepted connections", "maxconn"); -+ break; -+ } -+ - if(cmd==CMD_EXEC) - return option_not_found; - return NULL; /* OK */ -diff -Naur stunnel.orig/src/prototypes.h stunnel/src/prototypes.h ---- stunnel.orig/src/prototypes.h 2005-10-27 05:41:28.000000000 -0400 -+++ stunnel/src/prototypes.h 2006-07-31 22:49:36.000000000 -0400 -@@ -44,6 +44,7 @@ - /**************************************** Prototypes for stunnel.c */ - - extern int num_clients; -+extern int num_conn; - - void main_initialize(char *, char *); - void main_execute(void); -@@ -113,6 +114,7 @@ - long session_timeout; - int verify_level; - int verify_use_only_my; -+ int maxconn; - long ssl_options; - - /* some global data for stunnel.c */ + case CMD_EXEC: + if(strcasecmp(opt, "syslog")) diff -Naur stunnel.orig/src/stunnel.c stunnel/src/stunnel.c ---- stunnel.orig/src/stunnel.c 2005-11-02 15:18:42.000000000 -0500 -+++ stunnel/src/stunnel.c 2006-07-31 21:40:04.000000000 -0400 -@@ -53,6 +53,7 @@ - #endif - - int num_clients=0; /* Current number of clients */ -+int num_conn=0; /* Total number of connections */ - - /* Functions */ - -@@ -138,6 +139,7 @@ +--- stunnel.orig/src/stunnel.c 2008-06-21 17:32:45.000000000 -0400 ++++ stunnel/src/stunnel.c 2008-11-19 21:14:28.000000000 -0500 +@@ -301,6 +301,7 @@ } + #endif + #endif ++ if (getenv("STUNNEL_MAX_CLIENTS")) max_clients = atoi(getenv("STUNNEL_MAX_CLIENTS")); + } - num_clients=0; -+ num_conn=0; - - /* bind local ports */ - for(opt=local_options.next; opt; opt=opt->next) { -@@ -222,6 +224,18 @@ - return; /* error */ - } - } -+ num_conn++; -+fprintf(stderr, "num_conn: %d\n", num_conn); -+ if (options.maxconn > 0 && num_conn > options.maxconn) { -+ s_log(LOG_WARNING, "Connection rejected: exceeded maxconn (%d>%d)", -+ num_conn, options.maxconn); -+ closesocket(s); -+ if (num_clients == 0) { -+ s_log(LOG_WARNING, "Finished via maxconn."); -+ exit(0); -+ } -+ return; -+ } - s_ntop(from_address, &addr); - s_log(LOG_DEBUG, "%s accepted FD=%d from %s", - opt->servname, s, from_address); + #if !defined (USE_WIN32) && !defined (__vms) && !defined(USE_OS2) |