ports/134175: [maintainer-update] net-mgmt/nagios*: Resolve embedded Perl segmentation faults

Jarrod Sayers jarrod at netleader.com.au
Sun May 3 03:20:02 UTC 2009


>Number:         134175
>Category:       ports
>Synopsis:       [maintainer-update] net-mgmt/nagios*: Resolve embedded Perl segmentation faults
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 03 03:20:00 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Jarrod Sayers
>Release:        FreeBSD 7.1-RELEASE-p3 i386
>Organization:
>Environment:
System: FreeBSD manhattan.netleader.com.au 7.1-RELEASE-p3 FreeBSD 7.1-RELEASE-p3 #12: Mon Mar 2 20:39:19 CST 2009 root at manhattan.netleader.com.au:/usr/obj/usr/src/sys/MANHATTAN i386
>Description:
[If possible, this PR should be assigned to wxs@]

The upgrade of Perl to 5.8.9 introduced a segmentation fault when Nagios was built
with the embedded Perl option, causing issues on a small number of installations.
This PR resolves ports/131993 and implements a common patch across all three Nagios
ports.

Many thanks to Sebastian for locating where the issue was.

Among the changes are some minor tweaks shifting DISTVERSION back to PORTVERSION
(a left over from the beta process) and including MAKE_JOBS_UNSAFE.

Files modified:
- ports/net-mgmt/nagios/Makefile
- ports/net-mgmt/nagios2/Makefile
- ports/net-mgmt/nagios-devel/Makefile

Files added:
- ports/net-mgmt/nagios/files/patch-base-utils.c
- ports/net-mgmt/nagios2/files/patch-base-utils.c
- ports/net-mgmt/nagios-devel/files/patch-base__utils.c
>How-To-Repeat:
>Fix:
Downloadable diff from:
http://www.netleader.com.au/~jarrod/FreeBSD/net-mgmt-nagios-base__utils.diff

--- net-mgmt-nagios-base__utils.diff begins here ---
diff -ruN ports/net-mgmt/nagios.orig/Makefile ports/net-mgmt/nagios/Makefile
--- ports/net-mgmt/nagios.orig/Makefile	2009-04-29 15:02:33.000000000 +0930
+++ ports/net-mgmt/nagios/Makefile	2009-05-03 12:09:16.000000000 +0930
@@ -6,7 +6,8 @@
 #
 
 PORTNAME=	nagios
-DISTVERSION=	3.0.6
+PORTVERSION=	3.0.6
+PORTREVISION=	1
 CATEGORIES=	net-mgmt
 MASTER_SITES=	SF
 
@@ -16,8 +17,6 @@
 LIB_DEPENDS=	gd.4:${PORTSDIR}/graphics/gd
 RUN_DEPENDS=	${LOCALBASE}/libexec/nagios/check_nagios:${PORTSDIR}/net-mgmt/nagios-plugins
 
-MAKE_JOBS_UNSAFE=	yes
-
 USE_ICONV=	yes
 USE_PERL5_BUILD=	yes
 USE_AUTOTOOLS=	autoconf:262 libltdl:15
@@ -68,6 +67,8 @@
 		LIBS="-L${LOCALBASE}/lib" \
 		PERL=${PERL}
 
+MAKE_JOBS_UNSAFE=	yes
+
 INSTALL_TARGET=	install install-commandmode install-config
 
 PLIST_SUB=	NAGIOSDIR=${NAGIOSDIR} \
@@ -86,7 +87,7 @@
 
 ### XXX: Subtle bug with removing PREFIX from here
 SUB_LIST=	PREFIX=${PREFIX} \
-			${PLIST_SUB}
+		${PLIST_SUB}
 
 .if defined(WITH_EMBEDDED_PERL)
 USE_PERL5=	5.8.0+
diff -ruN ports/net-mgmt/nagios.orig/files/patch-base-utils.c ports/net-mgmt/nagios/files/patch-base-utils.c
--- ports/net-mgmt/nagios.orig/files/patch-base-utils.c	1970-01-01 09:30:00.000000000 +0930
+++ ports/net-mgmt/nagios/files/patch-base-utils.c	2009-05-03 11:51:53.000000000 +0930
@@ -0,0 +1,38 @@
+--- base/utils.c.orig	2008-12-01 03:52:58.000000000 +1030
++++ base/utils.c	2009-05-03 11:51:19.000000000 +0930
+@@ -3597,7 +3597,7 @@
+ /* initializes embedded perl interpreter */
+ int init_embedded_perl(char **env){
+ #ifdef EMBEDDEDPERL
+-	char *embedding[]={ "", "" };
++	char **embedding = NULL;
+ 	int exitstatus=0;
+ 	char *temp_buffer=NULL;
+ 	int argc=2;
+@@ -3613,6 +3613,17 @@
+ 
+ 	else{
+ 
++	  embedding = malloc(argc * sizeof(char *));
++	  if (embedding == NULL) {
++	    use_embedded_perl = FALSE;
++	    logit(NSLOG_RUNTIME_ERROR, TRUE, "Error: Unable to allocate memory for embedded Perl interpreter! (see ports/131993)\n");
++	  } else {
++	    embedding[0] = malloc(sizeof(char));
++	    if (embedding[0] == NULL) {
++	      use_embedded_perl = FALSE;
++	      logit(NSLOG_RUNTIME_ERROR, TRUE, "Error: Unable to allocate memory for embedded Perl interpreter! (see ports/131993)\n");
++	    } else {
++		*embedding[0] = '\0';
+ 		embedding[1]=p1_file;
+ 
+ 		use_embedded_perl=TRUE;
+@@ -3624,6 +3635,8 @@
+ 			logit(NSLOG_RUNTIME_ERROR,TRUE,"Error: Could not allocate memory for embedded Perl interpreter!\n");
+ 			}
+ 		}
++	    }
++	  }
+ 
+ 	/* a fatal error occurred... */
+ 	if(use_embedded_perl==FALSE){
diff -ruN ports/net-mgmt/nagios2.orig/Makefile ports/net-mgmt/nagios2/Makefile
--- ports/net-mgmt/nagios2.orig/Makefile	2009-01-16 10:30:22.000000000 +1030
+++ ports/net-mgmt/nagios2/Makefile	2009-05-03 12:07:11.000000000 +0930
@@ -7,7 +7,7 @@
 
 PORTNAME=	nagios
 PORTVERSION=	2.12
-PORTREVISION=	2
+PORTREVISION=	3
 CATEGORIES=	net-mgmt
 MASTER_SITES=	SF
 
@@ -72,6 +72,8 @@
 		LIBS="-L${LOCALBASE}/lib" \
 		PERL=${PERL}
 
+MAKE_JOBS_UNSAFE=	yes
+
 INSTALL_TARGET=	install install-commandmode install-config
 
 PLIST_SUB=	NAGIOSDIR=${NAGIOSDIR} \
diff -ruN ports/net-mgmt/nagios2.orig/files/patch-base-utils.c ports/net-mgmt/nagios2/files/patch-base-utils.c
--- ports/net-mgmt/nagios2.orig/files/patch-base-utils.c	1970-01-01 09:30:00.000000000 +0930
+++ ports/net-mgmt/nagios2/files/patch-base-utils.c	2009-05-03 11:58:38.000000000 +0930
@@ -0,0 +1,42 @@
+--- base/utils.c.orig	2008-02-11 03:50:10.000000000 +1030
++++ base/utils.c	2009-05-03 11:58:03.000000000 +0930
+@@ -4553,7 +4553,7 @@
+ /* initializes embedded perl interpreter */
+ int init_embedded_perl(char **env){
+ #ifdef EMBEDDEDPERL
+-	char *embedding[] = { "", "" };
++	char **embedding = NULL;
+ 	int exitstatus = 0;
+ 	char buffer[MAX_INPUT_BUFFER];
+ 	int argc = 2;
+@@ -4571,6 +4571,21 @@
+ 
+ 	else{
+ 
++	  embedding = malloc(argc * sizeof(char *));
++	  if (embedding == NULL) {
++	    use_embedded_perl = FALSE;
++	    snprintf(buffer, sizeof(buffer), "Error: Unable to allocate memory for embedded Perl interpreter! (see ports/131993)\n");
++	    buffer[sizeof(buffer) - 1] = '\0';
++	    write_to_logs_and_console(buffer, NSLOG_RUNTIME_ERROR, TRUE);
++	  } else {
++	    embedding[0] = malloc(sizeof(char));
++	    if (embedding[0] == NULL) {
++	      use_embedded_perl = FALSE;
++	      snprintf(buffer, sizeof(buffer), "Error: Unable to allocate memory for embedded Perl interpreter! (see ports/131993)\n");
++	      buffer[sizeof(buffer) - 1] = '\0';
++	      write_to_logs_and_console(buffer, NSLOG_RUNTIME_ERROR, TRUE);
++	    } else {
++		*embedding[0] = '\0';
+ 		embedding[1]=p1_file;
+ 
+ 		use_embedded_perl=TRUE;
+@@ -4584,6 +4599,8 @@
+ 			write_to_logs_and_console(buffer,NSLOG_RUNTIME_ERROR,TRUE);
+ 			}
+ 		}
++	    }
++	  }
+ 
+ 	/* a fatal error occurred... */
+ 	if(use_embedded_perl==FALSE){
diff -ruN ports/net-mgmt/nagios-devel.orig/Makefile ports/net-mgmt/nagios-devel/Makefile
--- ports/net-mgmt/nagios-devel.orig/Makefile	2009-02-26 10:27:03.000000000 +1030
+++ ports/net-mgmt/nagios-devel/Makefile	2009-05-03 12:09:40.000000000 +0930
@@ -6,7 +6,8 @@
 #
 
 PORTNAME=	nagios
-DISTVERSION=	3.1.0
+PORTVERSION=	3.1.0
+PORTREVISION=	1
 CATEGORIES=	net-mgmt
 MASTER_SITES=	SF
 PKGNAMESUFFIX=	-devel
@@ -71,6 +72,8 @@
 		LIBS="-L${LOCALBASE}/lib" \
 		PERL=${PERL}
 
+MAKE_JOBS_UNSAFE=	yes
+
 INSTALL_TARGET=	install install-commandmode install-config
 
 PLIST_SUB=	NAGIOSDIR=${NAGIOSDIR} \
diff -ruN ports/net-mgmt/nagios-devel.orig/files/patch-base__utils.c ports/net-mgmt/nagios-devel/files/patch-base__utils.c
--- ports/net-mgmt/nagios-devel.orig/files/patch-base__utils.c	1970-01-01 09:30:00.000000000 +0930
+++ ports/net-mgmt/nagios-devel/files/patch-base__utils.c	2009-05-03 11:59:44.000000000 +0930
@@ -0,0 +1,38 @@
+--- base/utils.c.orig	2009-01-26 01:12:34.000000000 +1030
++++ base/utils.c	2009-05-03 11:59:28.000000000 +0930
+@@ -3660,7 +3660,7 @@
+ /* initializes embedded perl interpreter */
+ int init_embedded_perl(char **env){
+ #ifdef EMBEDDEDPERL
+-	char *embedding[]={ "", "" };
++	char **embedding = NULL;
+ 	int exitstatus=0;
+ 	char *temp_buffer=NULL;
+ 	int argc=2;
+@@ -3676,6 +3676,17 @@
+ 
+ 	else{
+ 
++	  embedding = malloc(argc * sizeof(char *));
++	  if (embedding == NULL) {
++	    use_embedded_perl = FALSE;
++	    logit(NSLOG_RUNTIME_ERROR, TRUE, "Error: Unable to allocate memory for embedded Perl interpreter! (see ports/131993)\n");
++	  } else {
++	    embedding[0] = malloc(sizeof(char));
++	    if (embedding[0] == NULL) {
++	      use_embedded_perl = FALSE;
++	      logit(NSLOG_RUNTIME_ERROR, TRUE, "Error: Unable to allocate memory for embedded Perl interpreter! (see ports/131993)\n");
++	    } else {
++		*embedding[0] = '\0';
+ 		embedding[1]=p1_file;
+ 
+ 		use_embedded_perl=TRUE;
+@@ -3687,6 +3698,8 @@
+ 			logit(NSLOG_RUNTIME_ERROR,TRUE,"Error: Could not allocate memory for embedded Perl interpreter!\n");
+ 			}
+ 		}
++	    }
++	  }
+ 
+ 	/* a fatal error occurred... */
+ 	if(use_embedded_perl==FALSE){
--- net-mgmt-nagios-base__utils.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list