[Pkg-nagios-changes] [pkg-nsca] 11/11: Drop patches included upstream. Refresh remaining patches.

Bas Couwenberg sebastic at debian.org
Fri Dec 9 17:24:31 UTC 2016


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository pkg-nsca.

commit a317237689bd1b86e86c81b737a201358b0da6be
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Fri Dec 9 18:22:49 2016 +0100

    Drop patches included upstream. Refresh remaining patches.
---
 debian/changelog                                   |  10 +-
 debian/patches/01_send_nsca.cfg.patch              |  16 +-
 debian/patches/02_nsca_foreground.patch            |  82 +++----
 debian/patches/03_errors_to_stderr.patch           | 260 ++++++++++-----------
 debian/patches/05_spelling-errors.patch            |  18 +-
 debian/patches/06_open-arguments.patch             |  15 --
 debian/patches/07_signal-handler.patch             | 118 ----------
 ..._race-condition-when-opening-command-file.patch |  80 -------
 .../patches/09_reserved-identifier-violation.patch |  18 --
 ...sca-close-POLLNVAL-accept-bug-causes-hang.patch |  37 ---
 .../patches/11_fix-potential-buffer-overflow.patch |  20 +-
 debian/patches/series                              |   5 -
 12 files changed, 202 insertions(+), 477 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index e57a9b3..cb832eb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,10 @@ nsca (2.9.2-1) UNRELEASED; urgency=medium
 
   [ Bas Couwenberg ]
   * New upstream release.
+    - Replaced all instances of signal() with sigaction() + blocking.
+      (closes: 743493)
+    - Race condition when opening command file
+      (closes: #663047)
   * Add Vcs-* fields to control file.
   * Restructure control file with cme.
   * Add Homepage field to control file.
@@ -30,12 +34,6 @@ nsca (2.9.2-1) UNRELEASED; urgency=medium
   * Bump Standards-Version to 3.9.8, changes:
     Vcs-* fields, copyright-format 1.0.
   * Redirect update-rc.d output to /dev/null.
-  * Add upstream patch to fix signal handling.
-    (closes: #743493)
-  * Add upstream patch to fix race condition when opening command file.
-    (closes: #663047)
-  * Add upstream patch to fix reserved identifier violation.
-  * Add upstream patch to fix NSCA close/POLLNVAL/accept bug causing hang.
   * Use Icinga instead of Nagios (nagios3 removed from Debian).
     (closes: #846870)
   * Change nagios-plugins dependencies to monitoring-plugins.
diff --git a/debian/patches/01_send_nsca.cfg.patch b/debian/patches/01_send_nsca.cfg.patch
index 2af8840..c9a98f9 100644
--- a/debian/patches/01_send_nsca.cfg.patch
+++ b/debian/patches/01_send_nsca.cfg.patch
@@ -5,11 +5,11 @@ Forwarded: not-needed
 --- a/src/send_nsca.c
 +++ b/src/send_nsca.c
 @@ -25,7 +25,7 @@ time_t start_time,end_time;
- int server_port=DEFAULT_SERVER_PORT;
- char server_name[MAX_HOST_ADDRESS_LENGTH];
- char password[MAX_INPUT_BUFFER]="";
--char config_file[MAX_INPUT_BUFFER]="send_nsca.cfg";
-+char config_file[MAX_INPUT_BUFFER]="/etc/send_nsca.cfg";
- char delimiter[2]="\t";
- char block_delimiter[2]=BLOCK_DELIMITER;
- 
+ int server_port=DEFAULT_SERVER_PORT;
+ char server_name[MAX_HOST_ADDRESS_LENGTH];
+ char password[MAX_INPUT_BUFFER]="";
+-char config_file[MAX_INPUT_BUFFER]="send_nsca.cfg";
++char config_file[MAX_INPUT_BUFFER]="/etc/send_nsca.cfg";
+ char delimiter[2]="\t";
+ char block_delimiter[2]=BLOCK_DELIMITER;
+ 
diff --git a/debian/patches/02_nsca_foreground.patch b/debian/patches/02_nsca_foreground.patch
index edf76f4..2412eb1 100644
--- a/debian/patches/02_nsca_foreground.patch
+++ b/debian/patches/02_nsca_foreground.patch
@@ -7,44 +7,44 @@ Forwarded: https://github.com/NagiosEnterprises/nsca/pull/15
 --- a/src/nsca.c
 +++ b/src/nsca.c
 @@ -54,6 +54,8 @@ int     show_help=FALSE;
- int     show_license=FALSE;
- int     show_version=FALSE;
- 
-+int foreground=FALSE;
-+
- int     sigrestart=FALSE;
- int     sigshutdown=FALSE;
- 
-@@ -112,10 +114,11 @@ int main(int argc, char **argv){
- 	        }
- 
- 	if(result!=OK || show_help==TRUE){
--                printf("Usage: %s -c <config_file> [mode]\n",argv[0]);
-+                printf("Usage: %s -c <config_file> [-f] [mode]\n",argv[0]);
-                 printf("\n");
-                 printf("Options:\n");
- 		printf(" <config_file> = Name of config file to use\n");
-+		printf(" [-f]        = run in the foreground, do not fork\n");
- 		printf(" [mode]        = Determines how NSCA should run. Valid modes:\n");
-                 printf("   --inetd     = Run as a service under inetd or xinetd\n");
-                 printf("   --daemon    = Run as a standalone multi-process daemon\n");
-@@ -198,7 +201,7 @@ int main(int argc, char **argv){
- 		       V     */
- 
-                 /* daemonize and start listening for requests... */
--                if(fork()==0){
-+		if(foreground || fork()==0){
- 
-                         /* we're a daemon - set up a new process group */
-                         setsid();
-@@ -1375,6 +1378,10 @@ int process_arguments(int argc, char **a
- 		else if(!strcmp(argv[x-1],"-V") || !strcmp(argv[x-1],"--version"))
- 			show_version=TRUE;
- 
-+		/* run in the foreground */
-+		else if(!strcmp(argv[x-1],"-f"))
-+			foreground=TRUE;
-+
- 		else if(!strcmp(argv[x-1],"-d") || !strcmp(argv[x-1],"--daemon"))
-                         mode=MULTI_PROCESS_DAEMON;
- 
+ int     show_license=FALSE;
+ int     show_version=FALSE;
+ 
++int foreground=FALSE;
++
+ int     sigrestart=FALSE;
+ int     sigshutdown=FALSE;
+ 
+@@ -115,10 +117,11 @@ int main(int argc, char **argv){
+ 	        }
+ 
+ 	if(result!=OK || show_help==TRUE){
+-                printf("Usage: %s -c <config_file> [mode]\n",argv[0]);
++                printf("Usage: %s -c <config_file> [-f] [mode]\n",argv[0]);
+                 printf("\n");
+                 printf("Options:\n");
+ 		printf(" <config_file> = Name of config file to use\n");
++		printf(" [-f]        = run in the foreground, do not fork\n");
+ 		printf(" [mode]        = Determines how NSCA should run. Valid modes:\n");
+                 printf("   --inetd     = Run as a service under inetd or xinetd\n");
+                 printf("   --daemon    = Run as a standalone multi-process daemon\n");
+@@ -201,7 +204,7 @@ int main(int argc, char **argv){
+ 		       V     */
+ 
+                 /* daemonize and start listening for requests... */
+-                if(fork()==0){
++		if(foreground || fork()==0){
+ 
+                         /* we're a daemon - set up a new process group */
+                         setsid();
+@@ -1394,6 +1397,10 @@ int process_arguments(int argc, char **a
+ 		else if(!strcmp(argv[x-1],"-V") || !strcmp(argv[x-1],"--version"))
+ 			show_version=TRUE;
+ 
++		/* run in the foreground */
++		else if(!strcmp(argv[x-1],"-f"))
++			foreground=TRUE;
++
+ 		else if(!strcmp(argv[x-1],"-d") || !strcmp(argv[x-1],"--daemon"))
+                         mode=MULTI_PROCESS_DAEMON;
+ 
diff --git a/debian/patches/03_errors_to_stderr.patch b/debian/patches/03_errors_to_stderr.patch
index 50793e1..e606cf3 100644
--- a/debian/patches/03_errors_to_stderr.patch
+++ b/debian/patches/03_errors_to_stderr.patch
@@ -5,141 +5,141 @@ Forwarded: https://github.com/NagiosEnterprises/nsca/pull/16
 --- a/src/netutils.c
 +++ b/src/netutils.c
 @@ -61,7 +61,7 @@ int my_connect(char *host_name,int port,
- 		/* else do a DNS lookup */
- 		hp=gethostbyname((const char *)host_name);
- 		if(hp==NULL){
--			printf("Invalid host name '%s'\n",host_name);
-+			fprintf(stderr, "Invalid host name '%s'\n",host_name);
- 			return STATE_UNKNOWN;
- 		        }
- 
+ 		/* else do a DNS lookup */
+ 		hp=gethostbyname((const char *)host_name);
+ 		if(hp==NULL){
+-			printf("Invalid host name '%s'\n",host_name);
++			fprintf(stderr, "Invalid host name '%s'\n",host_name);
+ 			return STATE_UNKNOWN;
+ 		        }
+ 
 @@ -70,14 +70,14 @@ int my_connect(char *host_name,int port,
- 
- 	/* map transport protocol name to protocol number */
- 	if(((ptrp=getprotobyname(proto)))==NULL){
--		printf("Cannot map \"%s\" to protocol number\n",proto);
-+		fprintf(stderr, "Cannot map \"%s\" to protocol number\n",proto);
- 		return STATE_UNKNOWN;
- 	        }
- 
- 	/* create a socket */
- 	*sd=socket(PF_INET,(!strcmp(proto,"udp"))?SOCK_DGRAM:SOCK_STREAM,ptrp->p_proto);
- 	if(*sd<0){
--		printf("Socket creation failed\n");
-+		fprintf(stderr, "Socket creation failed\n");
- 		return STATE_UNKNOWN;
- 	        }
- 
+ 
+ 	/* map transport protocol name to protocol number */
+ 	if(((ptrp=getprotobyname(proto)))==NULL){
+-		printf("Cannot map \"%s\" to protocol number\n",proto);
++		fprintf(stderr, "Cannot map \"%s\" to protocol number\n",proto);
+ 		return STATE_UNKNOWN;
+ 	        }
+ 
+ 	/* create a socket */
+ 	*sd=socket(PF_INET,(!strcmp(proto,"udp"))?SOCK_DGRAM:SOCK_STREAM,ptrp->p_proto);
+ 	if(*sd<0){
+-		printf("Socket creation failed\n");
++		fprintf(stderr, "Socket creation failed\n");
+ 		return STATE_UNKNOWN;
+ 	        }
+ 
 @@ -86,16 +86,16 @@ int my_connect(char *host_name,int port,
- 	if(result<0){
- 		switch(errno){  
- 		case ECONNREFUSED:
--			printf("Connection refused by host\n");
-+			fprintf(stderr, "Connection refused by host\n");
- 			break;
- 		case ETIMEDOUT:
--			printf("Timeout while attempting connection\n");
-+			fprintf(stderr, "Timeout while attempting connection\n");
- 			break;
- 		case ENETUNREACH:
--			printf("Network is unreachable\n");
-+			fprintf(stderr, "Network is unreachable\n");
- 			break;
- 		default:
--			printf("Connection refused or timed out\n");
-+			fprintf(stderr, "Connection refused or timed out\n");
- 		        }
- 
- 		return STATE_CRITICAL;
+ 	if(result<0){
+ 		switch(errno){  
+ 		case ECONNREFUSED:
+-			printf("Connection refused by host\n");
++			fprintf(stderr, "Connection refused by host\n");
+ 			break;
+ 		case ETIMEDOUT:
+-			printf("Timeout while attempting connection\n");
++			fprintf(stderr, "Timeout while attempting connection\n");
+ 			break;
+ 		case ENETUNREACH:
+-			printf("Network is unreachable\n");
++			fprintf(stderr, "Network is unreachable\n");
+ 			break;
+ 		default:
+-			printf("Connection refused or timed out\n");
++			fprintf(stderr, "Connection refused or timed out\n");
+ 		        }
+ 
+ 		return STATE_CRITICAL;
 --- a/src/nsca.c
 +++ b/src/nsca.c
-@@ -92,7 +92,7 @@ int main(int argc, char **argv){
-         if(result!=OK || show_help==TRUE || show_license==TRUE || show_version==TRUE){
- 
- 		if(result!=OK)
--			printf("Incorrect command line arguments supplied\n");
-+			fprintf(stderr, "Incorrect command line arguments supplied\n");
-                 printf("\n");
-                 printf("NSCA - Nagios Service Check Acceptor\n");
- 		printf("Copyright (c) 2009 Nagios Core Development Team and Community Contributors\n");
+@@ -95,7 +95,7 @@ int main(int argc, char **argv){
+         if(result!=OK || show_help==TRUE || show_license==TRUE || show_version==TRUE){
+ 
+ 		if(result!=OK)
+-			printf("Incorrect command line arguments supplied\n");
++			fprintf(stderr, "Incorrect command line arguments supplied\n");
+                 printf("\n");
+                 printf("NSCA - Nagios Service Check Acceptor\n");
+ 		printf("Copyright (c) 2009 Nagios Core Development Team and Community Contributors\n");
 --- a/src/send_nsca.c
 +++ b/src/send_nsca.c
-@@ -80,7 +80,7 @@ int main(int argc, char **argv){
- 	if(result!=OK || show_help==TRUE || show_license==TRUE || show_version==TRUE){
- 
- 		if(result!=OK)
--			printf("Incorrect command line arguments supplied\n");
-+			fprintf(stderr, "Incorrect command line arguments supplied\n");
- 		printf("\n");
- 		printf("NSCA Client %s\n",PROGRAM_VERSION);
- 		printf("Copyright (c) 2000-2007 Ethan Galstad (www.nagios.org)\n");
-@@ -134,7 +134,7 @@ int main(int argc, char **argv){
- 
- 	/* exit if there are errors... */
- 	if(result==ERROR){
--		printf("Error: Config file '%s' contained errors...\n",config_file);
-+		fprintf(stderr, "Error: Config file '%s' contained errors...\n",config_file);
- 		do_exit(STATE_CRITICAL);
- 		}
- 
-@@ -154,7 +154,7 @@ int main(int argc, char **argv){
- 
- 	/* we couldn't connect */
- 	if(result!=STATE_OK){
--		printf("Error: Could not connect to host %s on port %d\n",server_name,server_port);
-+		fprintf(stderr, "Error: Could not connect to host %s on port %d\n",server_name,server_port);
- 		do_exit(STATE_CRITICAL);
- 	        }
- 
+@@ -83,7 +83,7 @@ int main(int argc, char **argv){
+ 	if(result!=OK || show_help==TRUE || show_license==TRUE || show_version==TRUE){
+ 
+ 		if(result!=OK)
+-			printf("Incorrect command line arguments supplied\n");
++			fprintf(stderr, "Incorrect command line arguments supplied\n");
+ 		printf("\n");
+ 		printf("NSCA Client %s\n",PROGRAM_VERSION);
+ 		printf("Copyright (c) 2000-2007 Ethan Galstad (www.nagios.org)\n");
+@@ -137,7 +137,7 @@ int main(int argc, char **argv){
+ 
+ 	/* exit if there are errors... */
+ 	if(result==ERROR){
+-		printf("Error: Config file '%s' contained errors...\n",config_file);
++		fprintf(stderr, "Error: Config file '%s' contained errors...\n",config_file);
+ 		do_exit(STATE_CRITICAL);
+ 		}
+ 
 @@ -165,7 +165,7 @@ int main(int argc, char **argv){
- 	/* read the initialization packet containing the IV and timestamp */
- 	result=read_init_packet(sd);
- 	if(result!=OK){
--		printf("Error: Could not read init packet from server\n");
-+		fprintf(stderr, "Error: Could not read init packet from server\n");
- 		close(sd);
- 		do_exit(STATE_CRITICAL);
- 	        }
+ 
+ 	/* we couldn't connect */
+ 	if(result!=STATE_OK){
+-		printf("Error: Could not connect to host %s on port %d\n",server_name,server_port);
++		fprintf(stderr, "Error: Could not connect to host %s on port %d\n",server_name,server_port);
+ 		do_exit(STATE_CRITICAL);
+ 	        }
+ 
 @@ -176,7 +176,7 @@ int main(int argc, char **argv){
- 
- 	/* initialize encryption/decryption routines with the IV we received from the server */
-         if(encrypt_init(password,encryption_method,received_iv,&CI)!=OK){
--		printf("Error: Failed to initialize encryption libraries for method %d\n",encryption_method);
-+		fprintf(stderr, "Error: Failed to initialize encryption libraries for method %d\n",encryption_method);
- 		close(sd);
- 		do_exit(STATE_CRITICAL);
- 	        }
-@@ -280,7 +280,7 @@ int main(int argc, char **argv){
- 
- 		/* there was an error sending the packet */
- 		if(rc==-1){
--			printf("Error: Could not send data to host\n");
-+			fprintf(stderr, "Error: Could not send data to host\n");
- 			close(sd);
- 			do_exit(STATE_UNKNOWN);
- 	                }
-@@ -353,13 +353,13 @@ int read_init_packet(int sock){
- 
-         /* recv() error or server disconnect */
-         if(rc<=0){
--                printf("Error: Server closed connection before init packet was received\n");
-+                fprintf(stderr, "Error: Server closed connection before init packet was received\n");
-                 return ERROR;
-                 }
- 
-         /* we couldn't read the correct amount of data, so bail out */
-         else if(bytes_to_recv!=sizeof(receive_packet)){
--                printf("Error: Init packet from server was too short (%d bytes received, %d expected)\n",bytes_to_recv,sizeof(receive_packet));
-+                fprintf(stderr, "Error: Init packet from server was too short (%d bytes received, %d expected)\n",bytes_to_recv,sizeof(receive_packet));
-                 return ERROR;
-                 }
- 
-@@ -468,7 +468,7 @@ int process_arguments(int argc, char **a
- /* handle timeouts */
- void alarm_handler(int sig){
- 
--	printf("Error: Timeout after %d seconds\n",socket_timeout);
-+	fprintf(stderr, "Error: Timeout after %d seconds\n",socket_timeout);
- 
- 	do_exit(STATE_CRITICAL);
-         }
+ 	/* read the initialization packet containing the IV and timestamp */
+ 	result=read_init_packet(sd);
+ 	if(result!=OK){
+-		printf("Error: Could not read init packet from server\n");
++		fprintf(stderr, "Error: Could not read init packet from server\n");
+ 		close(sd);
+ 		do_exit(STATE_CRITICAL);
+ 	        }
+@@ -187,7 +187,7 @@ int main(int argc, char **argv){
+ 
+ 	/* initialize encryption/decryption routines with the IV we received from the server */
+         if(encrypt_init(password,encryption_method,received_iv,&CI)!=OK){
+-		printf("Error: Failed to initialize encryption libraries for method %d\n",encryption_method);
++		fprintf(stderr, "Error: Failed to initialize encryption libraries for method %d\n",encryption_method);
+ 		close(sd);
+ 		do_exit(STATE_CRITICAL);
+ 	        }
+@@ -291,7 +291,7 @@ int main(int argc, char **argv){
+ 
+ 		/* there was an error sending the packet */
+ 		if(rc==-1){
+-			printf("Error: Could not send data to host\n");
++			fprintf(stderr, "Error: Could not send data to host\n");
+ 			close(sd);
+ 			do_exit(STATE_UNKNOWN);
+ 	                }
+@@ -364,13 +364,13 @@ int read_init_packet(int sock){
+ 
+         /* recv() error or server disconnect */
+         if(rc<=0){
+-                printf("Error: Server closed connection before init packet was received\n");
++                fprintf(stderr, "Error: Server closed connection before init packet was received\n");
+                 return ERROR;
+                 }
+ 
+         /* we couldn't read the correct amount of data, so bail out */
+         else if(bytes_to_recv!=sizeof(receive_packet)){
+-                printf("Error: Init packet from server was too short (%d bytes received, %d expected)\n",bytes_to_recv,sizeof(receive_packet));
++                fprintf(stderr, "Error: Init packet from server was too short (%d bytes received, %d expected)\n",bytes_to_recv,sizeof(receive_packet));
+                 return ERROR;
+                 }
+ 
+@@ -479,7 +479,7 @@ int process_arguments(int argc, char **a
+ /* handle timeouts */
+ void alarm_handler(int sig){
+ 	const char msg[] = "Error: Timeout after %d seconds\n";
+-	/* printf("Error: Timeout after %d seconds\n",socket_timeout); */
++	/* fprintf(stderr, "Error: Timeout after %d seconds\n",socket_timeout); */
+ 	write(STDOUT_FILENO, msg, sizeof(msg) - 1);
+ 
+ 	do_exit(STATE_CRITICAL);
diff --git a/debian/patches/05_spelling-errors.patch b/debian/patches/05_spelling-errors.patch
index b532e49..d488a89 100644
--- a/debian/patches/05_spelling-errors.patch
+++ b/debian/patches/05_spelling-errors.patch
@@ -5,12 +5,12 @@ Forwarded: https://github.com/NagiosEnterprises/nsca/pull/17
 
 --- a/src/send_nsca.c
 +++ b/src/send_nsca.c
-@@ -111,7 +111,7 @@ int main(int argc, char **argv){
- 		printf("This utility is used to send passive check results to the NSCA daemon.  Host and\n");
- 		printf("Service check data that is to be sent to the NSCA daemon is read from standard\n");
- 		printf("input. Input should be provided in the following format (tab-delimited unless\n");
--		printf("overriden with -d command line argument, one entry per line):\n");
-+		printf("overridden with -d command line argument, one entry per line):\n");
- 		printf("\n");
- 		printf("Service Checks:\n");
- 		printf("<host_name>[tab]<svc_description>[tab]<return_code>[tab]<plugin_output>[newline]\n\n");
+@@ -114,7 +114,7 @@ int main(int argc, char **argv){
+ 		printf("This utility is used to send passive check results to the NSCA daemon.  Host and\n");
+ 		printf("Service check data that is to be sent to the NSCA daemon is read from standard\n");
+ 		printf("input. Input should be provided in the following format (tab-delimited unless\n");
+-		printf("overriden with -d command line argument, one entry per line):\n");
++		printf("overridden with -d command line argument, one entry per line):\n");
+ 		printf("\n");
+ 		printf("Service Checks:\n");
+ 		printf("<host_name>[tab]<svc_description>[tab]<return_code>[tab]<plugin_output>[newline]\n\n");
diff --git a/debian/patches/06_open-arguments.patch b/debian/patches/06_open-arguments.patch
deleted file mode 100644
index d80e84f..0000000
--- a/debian/patches/06_open-arguments.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-Description: Fix missing argument in open calls.
-Author: Xavier Bachelot / John Frickson
-Origin: https://github.com/NagiosEnterprises/nsca/commit/b9f2c08dfdf31430f972a48781fc115c4af13cfe
-
---- a/src/nsca.c
-+++ b/src/nsca.c
-@@ -480,7 +480,7 @@ static int read_config_file(char *filena
-                             int checkresult_test_fd=-1;
-                             char *checkresult_test=NULL;
-                             asprintf(&checkresult_test,"%s/nsca.test.%i",check_result_path,getpid());
--                            checkresult_test_fd=open(checkresult_test,O_WRONLY|O_CREAT);
-+                            checkresult_test_fd=open(checkresult_test,O_WRONLY|O_CREAT,S_IWUSR);
-                             if (checkresult_test_fd>0){
-                                     unlink(checkresult_test);
-                                     }
diff --git a/debian/patches/07_signal-handler.patch b/debian/patches/07_signal-handler.patch
deleted file mode 100644
index 9b82689..0000000
--- a/debian/patches/07_signal-handler.patch
+++ /dev/null
@@ -1,118 +0,0 @@
-Description: NRPE uses signals unsafely, hangs, can bring down system
- Fix for issues:
- http://tracker.nagios.org/view.php?id=377
- http://tracker.nagios.org/view.php?id=548 (nagios dies on restart while sending command to cmd file)
- http://tracker.nagios.org/view.php?id=592 (send_nsca signal handling is undefined behaviour, causes SEGVs)
- .
- Replaced all instances of signal() with sigaction() and blocked all signals during
- signal processing using sigfillset(). This should prevent any reentrant problems during
- signal handling.
- .
- Also replaced as many unsafe function calls with safe ones (not very many, mainly some
- printf()s to write()s).
-Author: John C. Frickson <jfrickson at nagios.com>
-Origin: https://github.com/NagiosEnterprises/nsca/commit/a51cadfab5354f0257fa584cbf037c4f68b4a21c
-Bug-Debian: https://bugs.debian.org/743493
-
---- a/configure.in
-+++ b/configure.in
-@@ -104,7 +104,7 @@ AC_CHECK_LIB(wrap,main,[
- 	AC_DEFINE(HAVE_LIBWRAP,[1],[Have the TCP wrappers library])
- 	])
- AC_SUBST(LIBWRAPLIBS)
--AC_CHECK_FUNCS(strdup strstr strtoul)
-+AC_CHECK_FUNCS(strdup strstr strtoul sigaction)
- 
- dnl Define sig_atomic_t to int if it's not available.
- AC_CHECK_TYPE([sig_atomic_t],[],[
---- a/include/config.h.in
-+++ b/include/config.h.in
-@@ -42,6 +42,7 @@
- #undef HAVE_INITGROUPS
- #undef HAVE_LIMITS_H
- #undef HAVE_SYS_RESOURCE_H
-+#undef HAVE_SIGACTION
- 
- #undef HAVE_LIBWRAP
- 
---- a/src/nsca.c
-+++ b/src/nsca.c
-@@ -84,6 +84,9 @@ int main(int argc, char **argv){
-         int result;
-         uid_t uid=-1;
-         gid_t gid=-1;
-+#ifdef HAVE_SIGACTION
-+		struct sigaction sig_action;
-+#endif
- 
- 
- 	/* process command-line arguments */
-@@ -207,9 +210,19 @@ int main(int argc, char **argv){
-                         setsid();
- 
- 			/* handle signals */
-+#ifdef HAVE_SIGACTION
-+			sig_action.sa_sigaction = NULL;
-+			sig_action.sa_handler = sighandler;
-+			sigfillset(&sig_action.sa_mask);
-+			sig_action.sa_flags = SA_NODEFER|SA_RESTART;
-+			sigaction(SIGQUIT, &sig_action, NULL);
-+			sigaction(SIGTERM, &sig_action, NULL);
-+			sigaction(SIGHUP, &sig_action, NULL);
-+#else /* HAVE_SIGACTION */
- 			signal(SIGQUIT,sighandler);
- 			signal(SIGTERM,sighandler);
- 			signal(SIGHUP,sighandler);
-+#endif /* HAVE_SIGACTION */
- 
- 			/* close standard file descriptors */
-                         close(0);
---- a/src/send_nsca.c
-+++ b/src/send_nsca.c
-@@ -72,6 +72,9 @@ int main(int argc, char **argv){
- 	int16_t return_code;
- 	u_int32_t calculated_crc32;
- 	char *inputptr, *ptr1, *ptr2, *ptr3, *ptr4;
-+#ifdef HAVE_SIGACTION
-+	struct sigaction sig_action;
-+#endif
- 
- 
- 	/* process command-line arguments */
-@@ -142,7 +145,15 @@ int main(int argc, char **argv){
- 	generate_crc32_table();
- 
- 	/* initialize alarm signal handling */
-+#ifdef HAVE_SIGACTION
-+	sig_action.sa_sigaction = NULL;
-+	sig_action.sa_handler = alarm_handler;
-+	sigfillset(&sig_action.sa_mask);
-+	sig_action.sa_flags = SA_NODEFER|SA_RESTART;
-+	sigaction(SIGALRM, &sig_action, NULL);
-+#else
- 	signal(SIGALRM,alarm_handler);
-+#endif /* HAVE_SIGACTION */
- 
- 	/* set socket timeout */
- 	alarm(socket_timeout);
-@@ -318,7 +329,7 @@ static void do_exit(int return_code){
- 	alarm(0);
- 
- 	/* encryption/decryption routine cleanup */
--	encrypt_cleanup(encryption_method,CI);
-+	/* encrypt_cleanup(encryption_method,CI); */
- 
- #ifdef DEBUG
- 	printf("Cleaned up encryption routines\n");
-@@ -467,8 +478,9 @@ int process_arguments(int argc, char **a
- 
- /* handle timeouts */
- void alarm_handler(int sig){
--
--	fprintf(stderr, "Error: Timeout after %d seconds\n",socket_timeout);
-+	const char msg[] = "Error: Timeout after %d seconds\n";
-+	/* printf("Error: Timeout after %d seconds\n",socket_timeout); */
-+	write(STDOUT_FILENO, msg, sizeof(msg) - 1);
- 
- 	do_exit(STATE_CRITICAL);
-         }
diff --git a/debian/patches/08_race-condition-when-opening-command-file.patch b/debian/patches/08_race-condition-when-opening-command-file.patch
deleted file mode 100644
index 29d5fae..0000000
--- a/debian/patches/08_race-condition-when-opening-command-file.patch
+++ /dev/null
@@ -1,80 +0,0 @@
-Description: Race condition when opening command file
- Fix for issue http://tracker.nagios.org/view.php?id=296
-Author: John C. Frickson <jfrickson at nagios.com>
-Origin: https://github.com/NagiosEnterprises/nsca/commit/9c98a1527c342eeacaa5905980a1dff9454c8b32
-
---- a/src/nsca.c
-+++ b/src/nsca.c
-@@ -1317,42 +1317,45 @@ static int write_check_result(char *host
- 
- 
- /* opens the command file for writing */
--static int open_command_file(void){
--	struct stat statbuf;
-+static int open_command_file(void)
-+{
-+	int	fd;
- 
--        /* file is already open */
--        if(command_file_fp!=NULL && using_alternate_dump_file==FALSE)
--                return OK;
-+	/* file is already open */
-+	if(command_file_fp!=NULL && using_alternate_dump_file==FALSE)
-+		return OK;
-+
-+	do
-+		fd = open(command_file,O_WRONLY|((append_to_file==TRUE)?O_APPEND:0));
-+	while(fd < 0 && errno == EINTR);
- 
- 	/* command file doesn't exist - monitoring app probably isn't running... */
--	if(stat(command_file,&statbuf)){
--		
--		if(debug==TRUE)
--			syslog(LOG_ERR,"Command file '%s' does not exist, attempting to use alternate dump file '%s' for output",command_file,alternate_dump_file);
-+	if (fd < 0 && errno == ENOENT) {
-+
-+		if (debug == TRUE)
-+			syslog(LOG_ERR, "Command file '%s' does not exist, attempting to use alternate dump file '%s' for output", command_file, alternate_dump_file);
- 
- 		/* try and write checks to alternate dump file */
--		command_file_fp=fopen(alternate_dump_file,"a");
--		if(command_file_fp==NULL){
--			if(debug==TRUE)
--				syslog(LOG_ERR,"Could not open alternate dump file '%s' for appending",alternate_dump_file);
-+		command_file_fp = fopen(alternate_dump_file, "a");
-+		if (command_file_fp == NULL) {
-+			if(debug == TRUE)
-+				syslog(LOG_ERR, "Could not open alternate dump file '%s' for appending", alternate_dump_file);
- 			return ERROR;
--                        }
--		using_alternate_dump_file=TRUE;
-+		}
-+		using_alternate_dump_file = TRUE;
- 
- 		return OK;
--	        }
-+	}
- 
--        /* open the command file for writing or appending */
--        command_file_fp=fopen(command_file,(append_to_file==TRUE)?"a":"w");
--        if(command_file_fp==NULL){
--                if(debug==TRUE)
--                        syslog(LOG_ERR,"Could not open command file '%s' for %s",command_file,(append_to_file==TRUE)?"appending":"writing");
--                return ERROR;
--                }
--
--	using_alternate_dump_file=FALSE;
--        return OK;
--        }
-+	if (fd < 0 || (command_file_fp = fdopen(fd, (append_to_file == TRUE) ? "a" : "w")) == NULL) {
-+		if (debug == TRUE)
-+			syslog(LOG_ERR, "Could not open command file '%s' for %s", command_file, (append_to_file == TRUE) ? "appending" : "writing");
-+		return ERROR;
-+	}
-+
-+	using_alternate_dump_file = FALSE;
-+	return OK;
-+}
- 
- 
- 
diff --git a/debian/patches/09_reserved-identifier-violation.patch b/debian/patches/09_reserved-identifier-violation.patch
deleted file mode 100644
index 57314eb..0000000
--- a/debian/patches/09_reserved-identifier-violation.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-Description: Reserved identifier violation.
- Standardization of header fenced per http://tracker.nagios.org/view.php?id=326
-Author: John C. Frickson <jfrickson at nagios.com>
-Origin: https://github.com/NagiosEnterprises/nsca/commit/984196686b01a23fc7e3a0da6169f10068e858a5
-
---- a/include/utils.h
-+++ b/include/utils.h
-@@ -28,8 +28,8 @@
-  *
-  ********************************************************************************/
- 
--#ifndef _UTILS_H
--#define _UTILS_H
-+#ifndef NSCA_UTILS_H_INCLUDED
-+#define NSCA_UTILS_H_INCLUDED
- 
- #include "config.h"
- 
diff --git a/debian/patches/10_nsca-close-POLLNVAL-accept-bug-causes-hang.patch b/debian/patches/10_nsca-close-POLLNVAL-accept-bug-causes-hang.patch
deleted file mode 100644
index b1b1f90..0000000
--- a/debian/patches/10_nsca-close-POLLNVAL-accept-bug-causes-hang.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-Description: NSCA close/POLLNVAL/accept bug causes hang
- Fix for issue http://tracker.nagios.org/view.php?id=644
- .
- Incorporated patch sent by original reporter.
-Author: John C. Frickson <jfrickson at nagios.com>
-Origin: https://github.com/NagiosEnterprises/nsca/commit/98dc4795edaf2fd5c5fe123e53a8c9b3a2b0585c
-
---- a/src/nsca.c
-+++ b/src/nsca.c
-@@ -654,6 +654,7 @@ static void register_poll(short events,
- 
-         pfds[npfds].fd=fd;
-         pfds[npfds].events=events;
-+        pfds[npfds].revents=0;
-         npfds++;
-         }
- 
-@@ -777,7 +778,8 @@ static void handle_events(void){
-                         data=rhand[hand].data;
-                         rhand[hand].handler=NULL;
-                         rhand[hand].data=NULL;
--                        handler(pfds[i].fd,data);
-+						if((pfds[i].revents&POLLNVAL)==0)
-+	                        handler(pfds[i].fd,data);
-                         }
-                 if((pfds[i].events&POLLOUT) && (pfds[i].revents&(POLLOUT|POLLERR|POLLHUP|POLLNVAL))){
-                         pfds[i].events&=~POLLOUT;
-@@ -786,7 +788,8 @@ static void handle_events(void){
-                         data=whand[hand].data;
-                         whand[hand].handler=NULL;
-                         whand[hand].data=NULL;
--                        handler(pfds[i].fd,data);
-+						if((pfds[i].revents&POLLNVAL)==0)
-+	                        handler(pfds[i].fd,data);
-                         }
-                 }
- 
diff --git a/debian/patches/11_fix-potential-buffer-overflow.patch b/debian/patches/11_fix-potential-buffer-overflow.patch
index e8910c1..c862f78 100644
--- a/debian/patches/11_fix-potential-buffer-overflow.patch
+++ b/debian/patches/11_fix-potential-buffer-overflow.patch
@@ -6,13 +6,13 @@ Forwarded: https://github.com/NagiosEnterprises/nsca/pull/18
 --- a/src/send_nsca.c
 +++ b/src/send_nsca.c
 @@ -215,6 +215,10 @@ int main(int argc, char **argv){
- 			input_buffer[pos] = c;
- 			c = getc(stdin);
- 			pos++;
-+			if(pos>=MAX_INPUT_BUFFER-1){
-+				printf("Warning: packet[%d] truncated to %d bytes.\n",total_packets, MAX_INPUT_BUFFER);
-+				break;
-+			}
- 			}
- 		input_buffer[pos] = 0;
- 		strip(input_buffer);
+ 			input_buffer[pos] = c;
+ 			c = getc(stdin);
+ 			pos++;
++			if(pos>=MAX_INPUT_BUFFER-1){
++				printf("Warning: packet[%d] truncated to %d bytes.\n",total_packets, MAX_INPUT_BUFFER);
++				break;
++			}
+ 			}
+ 		input_buffer[pos] = 0;
+ 		strip(input_buffer);
diff --git a/debian/patches/series b/debian/patches/series
index 6b2f5db..12540fa 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -3,10 +3,5 @@
 03_errors_to_stderr.patch
 04_nsca.cfg_nagios_vs_nagios.patch
 05_spelling-errors.patch
-06_open-arguments.patch
-07_signal-handler.patch
-08_race-condition-when-opening-command-file.patch
-09_reserved-identifier-violation.patch
-10_nsca-close-POLLNVAL-accept-bug-causes-hang.patch
 11_fix-potential-buffer-overflow.patch
 12_pid-directory.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-nagios/pkg-nsca.git



More information about the Pkg-nagios-changes mailing list