[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bugfixes for icinga-core



Hi, 

I know I'm late.. But we discovered some bugs in icinga 1.0.2 which would be
nice to get fixed for squeeze. So we backported the fixes and I attached them
to this mail. It would be nice if I could do a bugfix upload for icinga. 

0001-fix-image-urls-555.patch: This patch fixes some image urls which were
borken in 1.0.2. This patch is more or less cosmetic, but it prevents several
404 in the apache log. 

0002-fix-copy-paste-error-569.patch: If the configuration file lists
temp_path before check_result_path the former gets overwritten. This patch
fixes that behaviour (https://dev.icinga.org/issues/569)

0003-modify-execv-to-execvp-accepting-4096-cmd-args-for-b.patch,
0004-execvp-searches-in-PATH-too-like-popen-and-returns-i.patch:
1.0.2 included a new heuristic to detect if a check could be executed without
a shell to speed up things. Unfortunatly that heuristic had some critical
bugs. One of the is that a command can only have 20-1 arguments which often
is not enough. The second of the patches fixes PATH lookups for check
commands. 

0005-fix-wrong-is_volatile-conditions-causing-wrong-servi.patch:
The volatile check was wrong and caused wrong service alerts 

0006-fix-multiurl-action-status-icon-macro-processing-fix.patch:
fixes a bug in macro processing and an invalid pointer in extinfo.cgi.

Thanks in advance 

Alex

From cf91d96c70e1b3c3dcaa8b1cd4066d88e4967965 Mon Sep 17 00:00:00 2001
From: Christoph Maser <cmr@financial.com>
Date: Sun, 4 Jul 2010 19:23:33 +0200
Subject: [PATCH 1/6] fix image urls #555

---
 html/stylesheets/avail.css            |    4 ++--
 html/stylesheets/checksanity.css      |    4 ++--
 html/stylesheets/extinfo.css          |    6 +++---
 html/stylesheets/histogram.css        |    4 ++--
 html/stylesheets/history.css          |    6 +++---
 html/stylesheets/interface/common.css |    4 ++--
 html/stylesheets/interface/menu.css   |   10 +++++-----
 html/stylesheets/ministatus.css       |    6 +++---
 html/stylesheets/notifications.css    |    4 ++--
 html/stylesheets/status.css           |    4 ++--
 html/stylesheets/statusmap.css        |    4 ++--
 html/stylesheets/summary.css          |    6 +++---
 html/stylesheets/trends.css           |    4 ++--
 13 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/html/stylesheets/avail.css b/html/stylesheets/avail.css
index ba20bbd..95d2f09 100644
--- a/html/stylesheets/avail.css
+++ b/html/stylesheets/avail.css
@@ -17,8 +17,8 @@ a.homepageURL:Hover { color: #ff3300; }
 
 .linkBox { border: 0; }
 table.linkBox { margin-top: 20px; }
-td.linkBox a { margin-left: 5px; padding-left: 10px; background: url(../../images/interface/menu_li1.gif) 0 0.35em no-repeat;  }
-td.linkBox a:hover { background: url(../../images/interface/menu_li2.gif) 0 0.35em no-repeat;  }
+td.linkBox a { margin-left: 5px; padding-left: 10px; background: url(../images/interface/menu_li1.gif) 0 0.35em no-repeat;  }
+td.linkBox a:hover { background: url(../images/interface/menu_li2.gif) 0 0.35em no-repeat;  }
 
 .reportRange { text-align: center; font-weight: bold; }
 .reportDuration { text-align: center; }
diff --git a/html/stylesheets/checksanity.css b/html/stylesheets/checksanity.css
index d03ba69..b87e8b4 100644
--- a/html/stylesheets/checksanity.css
+++ b/html/stylesheets/checksanity.css
@@ -18,8 +18,8 @@ a.homepageURL:Hover { color: #ff3300; }
 
 .linkBox { border: 0; }
 table.linkBox { margin-top: 20px; }
-td.linkBox a { margin-left: 5px;  padding-left: 10px;  background: url(../../images/interface/menu_li1.gif) 0 0.35em no-repeat;  }
-td.linkBox a:hover { background: url(../../images/interface/menu_li2.gif) 0 0.35em no-repeat;  }
+td.linkBox a { margin-left: 5px;  padding-left: 10px;  background: url(../images/interface/menu_li1.gif) 0 0.35em no-repeat;  }
+td.linkBox a:hover { background: url(../images/interface/menu_li2.gif) 0 0.35em no-repeat;  }
 
 .Title { text-align: center; font-weight: bold; font-size: 10pt; }
 .SectionTitle { text-align: center; font-weight: bold; }
diff --git a/html/stylesheets/extinfo.css b/html/stylesheets/extinfo.css
index a5cffa0..ba8c239 100644
--- a/html/stylesheets/extinfo.css
+++ b/html/stylesheets/extinfo.css
@@ -17,8 +17,8 @@ td { font-size: 8pt; border: 0; }
 a.homepageURL:Hover { color: #ff3300; }
 
 table.linkBox { margin-top: 20px; border: 0; }
-td.linkBox a { margin-left: 5px;  padding-left: 10px;  background: url(../../images/interface/menu_li1.gif) 0 0.35em no-repeat;  }
-td.linkBox a:hover { background: url(../../images/interface/menu_li2.gif) 0 0.35em no-repeat;  }
+td.linkBox a { margin-left: 5px;  padding-left: 10px;  background: url(../images/interface/menu_li1.gif) 0 0.35em no-repeat;  }
+td.linkBox a:hover { background: url(../images/interface/menu_li2.gif) 0 0.35em no-repeat;  }
 
 div.dataTitle { text-align: center; font-weight: bold; font-size: 10pt; margin-bottom: 15px; }
 div.data { text-align: center; font-size: 10pt; }
@@ -111,4 +111,4 @@ th.queue { text-align: left; font-size: 10pt; background-color: #707677; color:
 .queueOdd { background-color: #ededed; }
 .queueEven { background-color: #e9e9e9; }
 .queueENABLED { text-align: center; color: #fff; background-color: #00cc33; }
-.queueDISABLED { text-align: center; color: #fff; background-color: #ff3300; }
\ No newline at end of file
+.queueDISABLED { text-align: center; color: #fff; background-color: #ff3300; }
diff --git a/html/stylesheets/histogram.css b/html/stylesheets/histogram.css
index da4deb0..7e34b64 100644
--- a/html/stylesheets/histogram.css
+++ b/html/stylesheets/histogram.css
@@ -20,8 +20,8 @@ a.homepageURL:Hover { color: #ff3300; }
 
 .linkBox { border: 0; }
 table.linkBox { margin-top: 20px; }
-td.linkBox a { margin-left: 5px; padding-left: 10px; background: url(../../images/interface/menu_li1.gif) 0 0.35em no-repeat; }
-td.linkBox a:hover { background: url(../../images/interface/menu_li2.gif) 0 0.35em no-repeat; }
+td.linkBox a { margin-left: 5px; padding-left: 10px; background: url(../images/interface/menu_li1.gif) 0 0.35em no-repeat; }
+td.linkBox a:hover { background: url(../images/interface/menu_li2.gif) 0 0.35em no-repeat; }
 
 .dataTitle { text-align: center; font-weight: bold; font-size: 10pt; }
 
diff --git a/html/stylesheets/history.css b/html/stylesheets/history.css
index 8e23d39..5f34984 100644
--- a/html/stylesheets/history.css
+++ b/html/stylesheets/history.css
@@ -19,8 +19,8 @@ a.homepageURL:Hover { color: #ff3300; }
 
 .linkBox { border: 0; }
 table.linkBox { margin-top: 20px; }
-td.linkBox a { margin-left: 5px; padding-left: 10px; background: url(../../images/interface/menu_li1.gif) 0 0.35em no-repeat; }
-td.linkBox a:hover { background: url(../../images/interface/menu_li2.gif) 0 0.35em no-repeat; }
+td.linkBox a { margin-left: 5px; padding-left: 10px; background: url(../images/interface/menu_li1.gif) 0 0.35em no-repeat; }
+td.linkBox a:hover { background: url(../images/interface/menu_li2.gif) 0 0.35em no-repeat; }
 
 .dataTitle { text-align: center; font-weight: bold; font-size: 10pt; }
 
@@ -28,4 +28,4 @@ td.linkBox a:hover { background: url(../../images/interface/menu_li2.gif) 0 0.35
 .navBoxItem { color: #707677 }
 .navBoxFile { color: #707677; font-weight: bold; text-align: center; }
 
-.dateTimeBreak { font-size: 10pt; font-weight: bold; background-color: #ededed; color: #707677; }
\ No newline at end of file
+.dateTimeBreak { font-size: 10pt; font-weight: bold; background-color: #ededed; color: #707677; }
diff --git a/html/stylesheets/interface/common.css b/html/stylesheets/interface/common.css
index 40c9314..a5fc559 100644
--- a/html/stylesheets/interface/common.css
+++ b/html/stylesheets/interface/common.css
@@ -70,14 +70,14 @@ ul {
         width: 100%;
         height: 26px;
         line-height: 26px;
-        background: #ededed url(../../images/interface/bar.gif) top left repeat-x;
+        background: #ededed url(../images/interface/bar.gif) top left repeat-x;
 }
 
 #banner {
 	width: 100%;
 	height: 55px;
 	line-height: 55px;
-	background: #ededed url(../../images/interface/Icinga_Header_Webinterface_Pixel.jpg) top left repeat-x;
+	background: #ededed url(../images/interface/Icinga_Header_Webinterface_Pixel.jpg) top left repeat-x;
 }
 
 #navigation p {
diff --git a/html/stylesheets/interface/menu.css b/html/stylesheets/interface/menu.css
index de391ef..178dafa 100644
--- a/html/stylesheets/interface/menu.css
+++ b/html/stylesheets/interface/menu.css
@@ -7,7 +7,7 @@ body {
 	font-family: Verdana, Arial, Helvetica, sans-serif;
 	font-size: 0.7em;
 	color: #000;
-	background: #ededed url(../../images/interface/menu_body.gif) top left repeat-y;
+	background: #ededed url(../images/interface/menu_body.gif) top left repeat-y;
 }
 
 img {
@@ -27,7 +27,7 @@ ul {
 	padding: 0 5px;
 	height: 26px;
 	color: #ef9f1b;
-	background: #ededed url(../../images/interface/bar.gif) top left repeat-x;
+	background: #ededed url(../images/interface/bar.gif) top left repeat-x;
 	border-bottom: 1px solid #fff;
 	line-height: 26px;
 	font-size: 1em;
@@ -49,7 +49,7 @@ ul {
 
 #menu ul li a {
 	padding-left: 12px;
-	background: url(../../images/interface/menu_li1.gif) 0 0.35em no-repeat;
+	background: url(../images/interface/menu_li1.gif) 0 0.35em no-repeat;
 }
 
 #menu ul li a:link, #menu ul li a:active, #menu ul li a:visited {
@@ -58,7 +58,7 @@ ul {
 }
 
 #menu ul li a:hover {
-	background: url(../../images/interface/menu_li2.gif) 0 0.35em no-repeat;
+	background: url(../images/interface/menu_li2.gif) 0 0.35em no-repeat;
 	color: #000;
 }
 
@@ -72,7 +72,7 @@ ul {
 
 #menu a.flag {
 	padding-left: 12px;
-	background: url(../../images/interface/menu_blank.gif) 0 0.35em no-repeat;
+	background: url(../images/interface/menu_blank.gif) 0 0.35em no-repeat;
 }
 
 #menu div.flag {
diff --git a/html/stylesheets/ministatus.css b/html/stylesheets/ministatus.css
index a2a232d..bfc1922 100644
--- a/html/stylesheets/ministatus.css
+++ b/html/stylesheets/ministatus.css
@@ -18,8 +18,8 @@ a.homepageURL:Hover { color: #ff3300; }
 
 .linkBox { border: 0; }
 table.linkBox { margin-top: 20px; }
-td.linkBox a { margin-left: 5px; padding-left: 10px; background: url(../../images/interface/menu_li1.gif) 0 0.35em no-repeat;  }
-td.linkBox a:hover { background: url(../../images/interface/menu_li2.gif) 0 0.35em no-repeat;  }
+td.linkBox a { margin-left: 5px; padding-left: 10px; background: url(../images/interface/menu_li1.gif) 0 0.35em no-repeat;  }
+td.linkBox a:hover { background: url(../images/interface/menu_li2.gif) 0 0.35em no-repeat;  }
 
 .filter { border: 0; }
 .filterTitle { font-size: 10pt; font-weight: bold; }
@@ -92,4 +92,4 @@ a.hostTotals:hover { color: #000; }
 .miniStatusDOWN { background-color: #ff3300; text-align: center; }
 .miniStatusUNREACHABLE { background-color: #bf44b2; text-align: center; }
 .miniStatusUP a, .miniStatusDOWN a, .miniStatusUNREACHABLE a { color: #000; }
-.miniStatusUP a:hover, .miniStatusDOWN a:hover, .miniStatusUNREACHABLE a:hover { color: #fff; }
\ No newline at end of file
+.miniStatusUP a:hover, .miniStatusDOWN a:hover, .miniStatusUNREACHABLE a:hover { color: #fff; }
diff --git a/html/stylesheets/notifications.css b/html/stylesheets/notifications.css
index 5c47590..70aefb1 100644
--- a/html/stylesheets/notifications.css
+++ b/html/stylesheets/notifications.css
@@ -17,8 +17,8 @@ a.homepageURL:Hover { color: #ff3300; }
 
 .linkBox { border: 0; }
 table.linkBox { margin-top: 20px; }
-td.linkBox a { margin-left: 5px; padding-left: 10px; background: url(../../images/interface/menu_li1.gif) 0 0.35em no-repeat; }
-td.linkBox a:hover { background: url(../../images/interface/menu_li2.gif) 0 0.35em no-repeat; }
+td.linkBox a { margin-left: 5px; padding-left: 10px; background: url(../images/interface/menu_li1.gif) 0 0.35em no-repeat; }
+td.linkBox a:hover { background: url(../images/interface/menu_li2.gif) 0 0.35em no-repeat; }
 
 .dataTitle { text-align: center; font-weight: bold; font-size: 10pt; }
 
diff --git a/html/stylesheets/status.css b/html/stylesheets/status.css
index 44566b8..0a0345e 100644
--- a/html/stylesheets/status.css
+++ b/html/stylesheets/status.css
@@ -18,8 +18,8 @@ a.homepageURL:Hover { color: #ff3300; }
 
 .linkBox { border: 0; }
 table.linkBox { margin-top: 20px; }
-td.linkBox a { margin-left: 5px; padding-left: 10px; background: url(../../images/interface/menu_li1.gif) 0 0.35em no-repeat; }
-td.linkBox a:hover { background: url(../../images/interface/menu_li2.gif) 0 0.35em no-repeat; }
+td.linkBox a { margin-left: 5px; padding-left: 10px; background: url(../images/interface/menu_li1.gif) 0 0.35em no-repeat; }
+td.linkBox a:hover { background: url(../images/interface/menu_li2.gif) 0 0.35em no-repeat; }
 
 .filter { border: 0; }
 .filterTitle { font-size: 10pt; font-weight: bold; }
diff --git a/html/stylesheets/statusmap.css b/html/stylesheets/statusmap.css
index a553734..cec0061 100644
--- a/html/stylesheets/statusmap.css
+++ b/html/stylesheets/statusmap.css
@@ -17,8 +17,8 @@ a.homepageURL:Hover { font-family: arial,serif; color: #ff3300; }
 
 .linkBox { border: 0; }
 table.linkBox { margin-top: 20px; }
-td.linkBox a { margin-left: 5px; padding-left: 10px; background: url(../../images/interface/menu_li1.gif) 0 0.35em no-repeat; }
-td.linkBox a:hover { background: url(../../images/interface/menu_li2.gif) 0 0.35em no-repeat; }
+td.linkBox a { margin-left: 5px; padding-left: 10px; background: url(../images/interface/menu_li1.gif) 0 0.35em no-repeat; }
+td.linkBox a:hover { background: url(../images/interface/menu_li2.gif) 0 0.35em no-repeat; }
 
 .optBox { font-size: 10pt; font-weight: bold; }
 
diff --git a/html/stylesheets/summary.css b/html/stylesheets/summary.css
index 1a4dc21..64bce8f 100644
--- a/html/stylesheets/summary.css
+++ b/html/stylesheets/summary.css
@@ -18,8 +18,8 @@ a.homepageURL:Hover { color: #ff3300; }
 
 .linkBox { border: 0; }
 table.linkBox { margin-top: 20px; }
-td.linkBox a { margin-left: 5px; padding-left: 10px; background: url(../../images/interface/menu_li1.gif) 0 0.35em no-repeat; }
-td.linkBox a:hover { background: url(../../images/interface/menu_li2.gif) 0 0.35em no-repeat; }
+td.linkBox a { margin-left: 5px; padding-left: 10px; background: url(../images/interface/menu_li1.gif) 0 0.35em no-repeat; }
+td.linkBox a:hover { background: url(../images/interface/menu_li2.gif) 0 0.35em no-repeat; }
 
 .reportRange { text-align: center; font-weight: bold; }
 .reportDuration { text-align: center; }
@@ -60,4 +60,4 @@ tr.dataOdd td.serviceOK, tr.dataOdd td.serviceWARNING, tr.dataOdd td.serviceUNKN
 .reportSelectTip { font-style: italic; }
 
 .reportSelectTitle { text-align: center; font-weight: bold; font-size: 10pt; }
-.reportSelectSubTitle { text-align: right; }
\ No newline at end of file
+.reportSelectSubTitle { text-align: right; }
diff --git a/html/stylesheets/trends.css b/html/stylesheets/trends.css
index 6e2b93d..e3bd5c5 100644
--- a/html/stylesheets/trends.css
+++ b/html/stylesheets/trends.css
@@ -18,8 +18,8 @@ a.homepageURL:Hover { color: #ff3300; }
 
 .linkBox { border: 0; }
 table.linkBox { margin-top: 20px; }
-td.linkBox a { margin-left: 5px; padding-left: 10px; background: url(../../images/interface/menu_li1.gif) 0 0.35em no-repeat; }
-td.linkBox a:hover { background: url(../../images/interface/menu_li2.gif) 0 0.35em no-repeat; }
+td.linkBox a { margin-left: 5px; padding-left: 10px; background: url(../images/interface/menu_li1.gif) 0 0.35em no-repeat; }
+td.linkBox a:hover { background: url(../images/interface/menu_li2.gif) 0 0.35em no-repeat; }
 
 .helpfulHints { text-align: center; }
 
-- 
1.7.1

From 4b3d3765302eb6c9d7e93961f0c6e6ff722b0afc Mon Sep 17 00:00:00 2001
From: Christoph Maser <cmr@financial.com>
Date: Sun, 4 Jul 2010 20:41:11 +0200
Subject: [PATCH 2/6] fix copy paste error  #569

---
 base/config.c |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/base/config.c b/base/config.c
index a2ec628..104853d 100644
--- a/base/config.c
+++ b/base/config.c
@@ -446,16 +446,13 @@ int read_main_config_file(char *main_config_file){
 				}
 			closedir(tmpdir);
 
-			my_free(temp_path);
-			if((temp_path=(char *)strdup(value))){
-				strip(temp_path);
+			my_free(check_result_path);
+			if((check_result_path=(char *)strdup(value))){
+				strip(check_result_path);
 				/* make sure we don't have a trailing slash */
-				if(temp_path[strlen(temp_path)-1]=='/')
-					temp_path[strlen(temp_path)-1]='\x0';
+				if(check_result_path[strlen(check_result_path)-1]=='/')
+					check_result_path[strlen(check_result_path)-1]='\x0';
 			        }
-
-			my_free(check_result_path);
-			check_result_path=(char *)strdup(temp_path);
 			}
 
 		else if(!strcmp(variable,"max_check_result_file_age"))
-- 
1.7.1

From 9d265f32c94fef864f110660c44cd0d828390832 Mon Sep 17 00:00:00 2001
From: Michael Friedrich <michael.friedrich@univie.ac.at>
Date: Tue, 13 Jul 2010 16:04:50 +0200
Subject: [PATCH 3/6] modify execv to execvp, accepting 4096 cmd args, for both host and service checks with adapted error handling

the previous version only allowed 20-1 chld args, and was limited on the
error output. it is now a combined diff from Hiren, Christoph and Matthieu,
having all features applied and several bugs fixed (pipe returns -1 on error)

Furthermore, it's also applied for host checks.

execvp searches in path too, e.g. if plugin path is not set correctly but
is in PATH.

The run check procedure still falls back on popen execution, if the plugin
command contains shell meta characters. (Can be compared to Perl's exec vs
system)

kudos to Hiren Patel, Christoph Maser and Matthieu Kermagoret

refs #436
---
 Changelog        |   45 ++++++---
 base/checks.c    |  301 ++++++++++++++++++++++++++++++------------------------
 include/icinga.h |    3 +-
 3 files changed, 201 insertions(+), 148 deletions(-)

diff --git a/Changelog b/Changelog
index e2a3f70..9de507c 100644
--- a/Changelog
+++ b/Changelog
@@ -2,6 +2,23 @@
 Icinga 1.0.x Change Log
 #######################
 
+1.0.3 - 18/08/2010
+
+ENHANCEMENTS
+
+FIXES
+* core: check permissions before calling execv on a command
+* core: fix temp_path overwritten by check_result_path in base/config.c
+* core: modify execv to execvp, accepting 4096 cmd args, for both host and service checks with adapted error handling
+
+* classic ui: fix image urls ins stylesheets
+
+* install: fix api not installed using make install-unstripped
+* install: enable debuginfo in spec file
+
+* idoutils: adapt oracle-drop.sql for current schema
+
+
 1.0.2 - 30/06/2010
 
 ENHANCEMENTS
@@ -9,7 +26,7 @@ ENHANCEMENTS
 * core: check if icinga running before starting; if died remove lockfile first
 * core: add in sync retention facility (Ton Voon, Opsera Ltd)
 * core: add new is_volatile setting of 2 for services, which respects the re-notification interval for notifications (Ton Voon)
-* core: add Icinga option -S functions much like -s but will dump the entire scheduling queue is it would run, 
+* core: add Icinga option -S functions much like -s but will dump the entire scheduling queue is it would run,
         in addition to providing the summary data (Steven (Steven D. Morrey)
 * core: icinga can send log messages to syslogd using a local facility instead of the default one
 * core: enhanced diagnostic output when a regular expression fails to compile (Max Schubert)
@@ -107,7 +124,7 @@ ENHANCEMENTS
 * core: add service_check_timeout_state	configuration variable
 	This setting determines the state Icinga will report when a
 	service check times out - it does not respond within
-	service_check_timeout seconds.  
+	service_check_timeout seconds.
 	c - Critical (default)
 	u - Unknown
 	w - Warning
@@ -119,7 +136,7 @@ ENHANCEMENTS
 	escalation_condition <condition> ( [ & / | ] <condition> )*
 	where <condition> is either host hostname = [u,d,o] or
 	service hostname.service_description] = [w,u,c,o].
-	The escalation_condition accepts a list of one or more conditions 
+	The escalation_condition accepts a list of one or more conditions
 	separated by & (logical AND) or | (logical OR).
 	w = WARNING
 	u = UNKNOWN
@@ -149,7 +166,7 @@ ENHANCEMENTS
 		- dynamic binded procedure for DELETE on table by instance_id called at startup
 		  for cleaning config/status
 		- dynamic binded procedure for DELETE on tably by instance_id, field<time called
-		  during periodic cleanup in threaded housekeeper 
+		  during periodic cleanup in threaded housekeeper
 		- all other queries are prepared with their own statement handler
 			 4x DELETE
 			 52x MERGE
@@ -171,7 +188,7 @@ ENHANCEMENTS
 * idoutils: add initial debug output for idomod (to be set in idomod.cfg)
 * idoutils: add database name in connection msg to syslog
 * idoutils: change mysql db engine to innodb (no table locking, better transcations)
-* idoutils: add --with-oracle-lib=/path/to/instantclient for runtime export of 
+* idoutils: add --with-oracle-lib=/path/to/instantclient for runtime export of
 	LD_LIBRARY_PATH if instantclient not installed to path
 * idoutils: add max_logentries_age and max_acknowledgements_age to ido2db (check ido2db.cfg)
 
@@ -181,7 +198,7 @@ FIXES
 * core: fix event broker callback function self de-registering for callbacks (Sean Millichamp)
 * core: add missing sound.js provided by scriptaculous
 * core: string replaces for icinga
-* core: typo fix in mrtg.cfg (Dennis van Zuijlekom) 
+* core: typo fix in mrtg.cfg (Dennis van Zuijlekom)
 * core: add init info as required by LSB
 * core: fix perl tests
 * core: fix missing clean & distclean against tap/ directory
@@ -195,7 +212,7 @@ FIXES
 * core: fix idomod doesn't de-initialize after config error
 * core: fix make fullinstall/idoutils without enabled idoutils during configure
 * core: fix sending two identical service_status events to neb module
-* core: fix segmentation fault crash when a non-existant host or service is passed to the command pipe 
+* core: fix segmentation fault crash when a non-existant host or service is passed to the command pipe
 * core: add check for NULL for event_list_high
 
 * idoutils: modify string escaping for mysql and pgsql
@@ -320,7 +337,7 @@ FIXES
 * idoutils: add insert-or-update functions in dbqueries.c, prepared for more rdbms
 * idoutils: modify insert-or-update queries, build data array for functions
 * idoutils: fix string escaping for postgresql
-* idoutils: fix last insert id for postgresql - needs defined sequence id for table 
+* idoutils: fix last insert id for postgresql - needs defined sequence id for table
 * idoutils: modify command_line in commands table to varchar(1024)
 * idoutils: add more debug output
 * idoutils: Support 8192 chars of perfdata
@@ -371,7 +388,7 @@ FIXES
 Nagios 3.x Change Log
 #####################
 
-This is an archived Changelog, all changes on the Icinga Core will be marked and 
+This is an archived Changelog, all changes on the Icinga Core will be marked and
 referenced through issues marking on dev.icinga.org regarding their origin.
 
 Look at www.nagios.org for an actual changelog of Nagios Core.
@@ -493,7 +510,7 @@ WARNINGS
 
 3.0.5 - 11/04/2008
 ------------------
-* Security fix for Cross Site Request Forgery (CSRF) bug reported by Tim Starling. 
+* Security fix for Cross Site Request Forgery (CSRF) bug reported by Tim Starling.
 * Sample audio files for CGIs removed from distribution
 * Fix for mutliline config file continuation bug
 * Minor fix to RPM spec file
@@ -622,7 +639,7 @@ WARNINGS
 * Fix for compilation bug on systems that don't support setenv() (e.g. Solaris)
 * Support for line continuation/breaks in config files - end lines with one backslash (\) to continue on next line
 * Fixed bug with not deleting old check result files that contained results for invalid host/service
-* Fixed bug with init script option to check Nagios config 
+* Fixed bug with init script option to check Nagios config
 * Auto-filled comment/author fields for acknowledging problems through WAP interface
 * Fixed bug with processing of CONTACTGROUPNAMES, NOTES, NOTESURL, and ACTIONURL macros
 * Doc fix regarding soft state dependencies
@@ -704,7 +721,7 @@ WARNINGS
 * New macros: $HOSTGROUPMEMBERS$, $HOSTGROUPNOTES$, $HOSTGROUPNOTESURL$, $HOSTGROUPACTIONURL$, $SERVICEGROUPMEMBERS$, $SERVICEGROUPNOTES$, $SERVICEGROUPNOTESURL$, $SERVICEGROUPACTIONURL$, $CONTACTGROUPALIAS$, $CONTACTGROUPMEMBERS$, $NOTIFICATIONRECIPIENTS$, $NOTIFICATIONAUTHOR$, $NOTIFICATIONAUTHORNAME$, $NOTIFICATIONAUTHORALIAS$, $NOTIFICATIONCOMMENT$
 * Removed host/service downtime author/comment macros introduced in 3.0b2 in favor of more generic $NOTIFICATION...$ macros
 * Fix for segfault when cancelling active scheduled host downtime
-* Macro code cleanup 
+* Macro code cleanup
 * Added on-demand contact and contactgroup macro support
 * More complete (but still partial) support for macros in CGIs ($xNOTES$, $xNOTESURL$, and $xACTIONURL$ macros)
 * Fixed bug in config CGI with displaying incorrect notification interval for escalations
@@ -723,7 +740,7 @@ WARNINGS
 ------------------
 * Minor bug fix for debug logging of macros
 * Version number is now printed in CGI pages
-* HTML documentation cleanup (HTML Tidy, link checking, etc.) 
+* HTML documentation cleanup (HTML Tidy, link checking, etc.)
 * Fixed bug where notifications would not be sent out host/service contact group members
 
 
@@ -963,5 +980,5 @@ Here are all the changes since Nagios 2.x:
        and $SERVICEACKAUTHORALIAS$ macros
 
 
- 
+
 
diff --git a/base/checks.c b/base/checks.c
index 9f63052..d863a58 100644
--- a/base/checks.c
+++ b/base/checks.c
@@ -121,8 +121,166 @@ extern unsigned long max_debug_file_size;
 extern int      use_embedded_perl;
 #endif
 
+/******************************************************************/
+/********************* MISCELLANEOUS FUNCTIONS ********************/
+/******************************************************************/
+
+/* extract check result */
+static void extract_check_result(FILE *fp,dbuf *checkresult_dbuf){
+	char output_buffer[MAX_INPUT_BUFFER]="";
+	char *temp_buffer;
+
+	/* initialize buffer */
+	strcpy(output_buffer,"");
+
+	/* get all lines of plugin output - escape newlines */
+	while(fgets(output_buffer,sizeof(output_buffer)-1,fp)){
+		temp_buffer=escape_newlines(output_buffer);
+		dbuf_strcat(checkresult_dbuf,temp_buffer);
+		my_free(temp_buffer);
+	}
+}
+
+/* convert a command line to an array of arguments, suitable for exec* functions */
+static int parse_command_line(char *cmd, char *argv[MAX_CMD_ARGS]){
+	unsigned int argc=0;
+	char *parsed_cmd;
+
+	/* Skip initial white-space characters. */
+	for(parsed_cmd=cmd;isspace(*cmd);++cmd)
+		;
+
+	/* Parse command line. */
+	while(*cmd&&(argc<MAX_CMD_ARGS-1)){
+		argv[argc++]=parsed_cmd;
+
+		switch(*cmd){
+			case '\'':
+				while((*cmd)&&(*cmd!='\''))
+					*(parsed_cmd++)=*(cmd++);
+				if(*cmd)
+					++cmd;
+				break;
+			case '"':
+				while((*cmd)&&(*cmd!='"')){
+					if((*cmd=='\\')&&cmd[1]&&strchr("\"\\\n",cmd[1]))
+						++cmd;
+					*(parsed_cmd++)=*(cmd++);
+				}
+				if(*cmd)
+					++cmd;
+				break;
+			default:
+				while((*cmd)&&!isspace(*cmd)){
+					if((*cmd=='\\')&&cmd[1])
+						++cmd;
+					*(parsed_cmd++)=*(cmd++);
+				}
+		}
+
+		while(isspace(*cmd))
+			++cmd;
+
+		if(argc>=MAX_CMD_ARGS-1){
+			logit(NSLOG_RUNTIME_WARNING,TRUE,"overlimit args for command %s\n",argv[0]);
+			_exit(STATE_UNKNOWN);
+		}
+		else
+			*(parsed_cmd++)='\0';
+	}
+
+	argv[argc]=NULL;
+
+	return OK;
+}
+
+/* run a check */
+static int run_check(char *processed_command,dbuf *checkresult_dbuf){
+	char *argv[MAX_CMD_ARGS];
+	FILE *fp;
+	pid_t pid;
+	int pipefds[2];
+	int retval;
+
+	/* check for check execution method (shell or execvp) */
+	if(!has_shell_metachars(processed_command)){
+
+		if(pipe(pipefds)<0){
+			logit(NSLOG_RUNTIME_WARNING,TRUE,"error creating pipe: %s\n", strerror(errno));
+			_exit(STATE_UNKNOWN);
+		}
+		if((pid=fork())<0){
+			logit(NSLOG_RUNTIME_WARNING,TRUE,"fork error\n");
+			_exit(STATE_UNKNOWN);
+		}
+		else if(!pid){
+			/* child replaces stdout/stderr with output of the pipe */
+			if((dup2(pipefds[1],STDOUT_FILENO)<0)||(dup2(pipefds[1],STDERR_FILENO)<0)){
+				logit(NSLOG_RUNTIME_WARNING,TRUE,"dup2 error\n");
+				_exit(STATE_UNKNOWN);
+			}
+
+			/* close unused half of pipe */
+			close(pipefds[1]);
+
+			/* extract command args for execv */
+			parse_command_line(processed_command,argv);
+
+			if(!argv[0])
+				_exit(STATE_UNKNOWN);
+
+			/* check if plugin there/executable */
+			if (access(argv[0], R_OK) !=0 ) {
+				fprintf(stdout,"plugin %s does not exist or is not readable\n",argv[0]);
+				logit(NSLOG_RUNTIME_WARNING,TRUE,"plugin %s does not exists or is not readable\n",argv[0]);
+				_exit(STATE_UNKNOWN);
+			}
+
+			if (access(argv[0], X_OK) != 0  ) {
+				fprintf(stdout,"wrong execution permissions on plugin %s\n",argv[0]);
+				logit(NSLOG_RUNTIME_WARNING,TRUE,"wrong execution permissions on plugin %s\n",argv[0]);
+				_exit(STATE_UNKNOWN);
+			}
 
+			log_debug_info(DEBUGL_CHECKS,0,"running process %s via execv\n",processed_command);
+			execvp(argv[0], argv); /* instead of execvp since we don't use path */
+			_exit(STATE_UNKNOWN);
+		}
+
+		/* prepare pipe reading */
+		close(pipefds[1]);
+		fp=fdopen(pipefds[0],"r");
+		if(!fp){
+			logit(NSLOG_RUNTIME_WARNING,TRUE,"fdopen error\n");
+			_exit(STATE_UNKNOWN);
+		}
 
+		/* extract check result */
+		extract_check_result(fp,checkresult_dbuf);
+
+		/* close the process */
+		fclose(fp);
+		close(pipefds[0]);
+
+		if(waitpid(pid,&retval,0)!=pid)
+			retval=-1;
+	}
+	else{
+		log_debug_info(DEBUGL_CHECKS,0,"running process %s via popen\n",processed_command);
+		fp=popen(processed_command,"r");
+
+		if(fp==NULL)
+			_exit(STATE_UNKNOWN);
+
+		/* extract check result */
+		extract_check_result(fp,checkresult_dbuf);
+
+		/* close the process */
+		retval=pclose(fp);
+	}
+
+	return retval;
+}
 
 
 /******************************************************************/
@@ -330,14 +488,12 @@ int run_scheduled_service_check(service *svc, int check_options, double latency)
 int run_async_service_check(service *svc, int check_options, double latency, int scheduled_check, int reschedule_check, int *time_is_valid, time_t *preferred_time){
 	char *raw_command=NULL;
 	char *processed_command=NULL;
-	char output_buffer[MAX_INPUT_BUFFER]="";
 	char *temp_buffer=NULL;
 	struct timeval start_time,end_time;
 	pid_t pid=0;
 	int fork_error=FALSE;
 	int wait_result=0;
 	host *temp_host=NULL;
-	FILE *fp=NULL, *chldfp;
 	int pclose_result=0;
 	mode_t new_umask=077;
 	mode_t old_umask;
@@ -346,7 +502,6 @@ int run_async_service_check(service *svc, int check_options, double latency, int
 	dbuf checkresult_dbuf;
 	int dbuf_chunk=1024;
 	int pipefds[2], chldstatus, i;
-	char *chldargs[MAXCHLDARGS];
 	char *s , *p;
 
 #ifdef USE_EVENT_BROKER
@@ -557,7 +712,7 @@ int run_async_service_check(service *svc, int check_options, double latency, int
 		else
 			args[3]=processed_command+strlen(fname)+1;
 
-		ENTER; 
+		ENTER;
 		SAVETMPS;
 		PUSHMARK(SP);
 		XPUSHs(sv_2mortal(newSVpv(args[0],0)));
@@ -610,7 +765,7 @@ int run_async_service_check(service *svc, int check_options, double latency, int
 				fprintf(check_result_info.output_file_fp,"early_timeout=%d\n",check_result_info.early_timeout);
 				fprintf(check_result_info.output_file_fp,"exited_ok=%d\n",check_result_info.exited_ok);
 				fprintf(check_result_info.output_file_fp,"return_code=%d\n",check_result_info.return_code);
-				fprintf(check_result_info.output_file_fp,"output=%s\n",(checkresult_dbuf.buf==NULL)?"(null)":checkresult_dbuf.buf); 
+				fprintf(check_result_info.output_file_fp,"output=%s\n",(checkresult_dbuf.buf==NULL)?"(null)":checkresult_dbuf.buf);
 
 				/* close the temp file */
 				fclose(check_result_info.output_file_fp);
@@ -702,7 +857,7 @@ int run_async_service_check(service *svc, int check_options, double latency, int
 				/* execute our previously compiled script - from call_pv("Embed::Persistent::eval_file",..) */
 				/* NB. args[2] is _now_ a code ref (to the Perl subroutine corresp to the plugin) returned by eval_file() */
 
-				ENTER; 
+				ENTER;
 				SAVETMPS;
 				PUSHMARK(SP);
 
@@ -751,11 +906,11 @@ int run_async_service_check(service *svc, int check_options, double latency, int
 					fprintf(check_result_info.output_file_fp,"early_timeout=%d\n",check_result_info.early_timeout);
 					fprintf(check_result_info.output_file_fp,"exited_ok=%d\n",check_result_info.exited_ok);
 					fprintf(check_result_info.output_file_fp,"return_code=%d\n",check_result_info.return_code);
-					fprintf(check_result_info.output_file_fp,"output=%s\n",(checkresult_dbuf.buf==NULL)?"(null)":checkresult_dbuf.buf); 
+					fprintf(check_result_info.output_file_fp,"output=%s\n",(checkresult_dbuf.buf==NULL)?"(null)":checkresult_dbuf.buf);
 
 					/* close the temp file */
 					fclose(check_result_info.output_file_fp);
-					
+
 					/* move check result to queue directory */
 					move_check_result_to_queue(check_result_info.output_file);
 					}
@@ -772,111 +927,10 @@ int run_async_service_check(service *svc, int check_options, double latency, int
 #endif
 			/******** END EMBEDDED PERL INTERPRETER EXECUTION ********/
 
-     
-			/* run the plugin check command */
-
-            		if (!has_shell_metachars(processed_command)){
-                		if (pipe(pipefds) == -1){
-                    			logit(NSLOG_RUNTIME_WARNING,TRUE,"error creating pipe: %s\n",strerror(errno));
-                    			_exit(STATE_UNKNOWN);
-                		}
-
-
-                		pid = fork();
-                		if (pid == -1){
-                    			logit(NSLOG_RUNTIME_WARNING,TRUE,"fork error\n");
-                    			_exit(STATE_UNKNOWN);
-                		}
-
-	                     if (pid == 0){
-	                     close(pipefds[0]);
-	 
-	                     if (dup2(pipefds[1],STDOUT_FILENO) == -1){
-	                         logit(NSLOG_RUNTIME_WARNING,TRUE,"dup2 error\n");
-	                         _exit(EXIT_FAILURE);
-	                     }
-	 
-	                     if (dup2(pipefds[1],STDERR_FILENO) == -1){
-	                         logit(NSLOG_RUNTIME_WARNING,TRUE,"dup2 error\n");
-	                         _exit(EXIT_FAILURE);
-	                     }
-	                     close(pipefds[0]);
-	 
-	                     s = strchr(processed_command,' ');
-	                     if (s){
-	                         *s = '\0';
-	                         p = s+1;
-				 for(;isspace(*p);p++)
-					;
-	 
-	                         chldargs[0] = processed_command;
-	                         for(i=1;i<MAXCHLDARGS-2;i++){
-	                             s = strchr(p,' ');
-	                             chldargs[i] = p;
-	 
-	                             if (s){
-	                                 *s = '\0';
-	                                 p = s+1;
-					 for(;isspace(*p);p++)
-						;
-	                             }
-	 
-	                             if (!s)
-	                                 break;
-	                         }
-	 
-	                         if (i >= MAXCHLDARGS-2){
-	                             logit(NSLOG_RUNTIME_WARNING,TRUE,"overlimit args for command %s\n",chldargs[0]);
-	                             _exit(EXIT_FAILURE);
-	                         }
-	                         else
-	                             chldargs[++i] = '\0';
-	                     }
-	                     else{
-	                         chldargs[0] = processed_command;
-	                         chldargs[1] = '\0';
-	                     }
-	 
-	                     log_debug_info(DEBUGL_CHECKS,0,"running process %s via execv\n",processed_command);
-	                     execv(chldargs[0],chldargs);
-                     	    _exit(EXIT_FAILURE);
-			}
 
+			/* run the plugin check command */
+			pclose_result=run_check(processed_command,&checkresult_dbuf);
 
-	               	close(pipefds[1]);
-	
-	                chldfp = fdopen(pipefds[0],"r");
-	                if (chldfp == NULL){
-	                    logit(NSLOG_RUNTIME_WARNING,TRUE,"fdopen error\n");
-	                    _exit(EXIT_FAILURE);
-	                }
-	
-	                while(fgets(output_buffer,sizeof(output_buffer)-1,chldfp)){
-	                    temp_buffer=escape_newlines(output_buffer);
-	                    dbuf_strcat(&checkresult_dbuf,temp_buffer);
-	                    my_free(temp_buffer);
-	                }
-	
-	                fclose(chldfp);
-	                waitpid(pid,&chldstatus,0);
-	                pclose_result=chldstatus;
-	            }
-	            else{
-	                log_debug_info(DEBUGL_CHECKS,0,"running process %s via popen\n",processed_command);
-	                fp=popen(processed_command,"r");
-	                if(fp==NULL)
-	                    _exit(STATE_UNKNOWN);
-	    
-	                strcpy(output_buffer,"");
-	    
-	                while(fgets(output_buffer,sizeof(output_buffer)-1,fp)){
-	                    temp_buffer=escape_newlines(output_buffer);
-	                    dbuf_strcat(&checkresult_dbuf,temp_buffer);
-	                    my_free(temp_buffer);
-	                    }
-	    
-	                pclose_result=pclose(fp);
-	            }
 			/* reset the alarm */
 			alarm(0);
 
@@ -1045,7 +1099,7 @@ int handle_async_service_check_result(service *temp_service, check_result *queue
 
 	/* DISCARD INVALID FRESHNESS CHECK RESULTS */
 	/* If a services goes stale, Icinga will initiate a forced check in order to freshen it.  There is a race condition whereby a passive check
-	   could arrive between the 1) initiation of the forced check and 2) the time when the forced check result is processed here.  This would 
+	   could arrive between the 1) initiation of the forced check and 2) the time when the forced check result is processed here.  This would
 	   make the service fresh again, so we do a quick check to make sure the service is still stale before we accept the check result. */
 	if((queued_check_result->check_options & CHECK_OPTION_FRESHNESS_CHECK) && is_service_result_fresh(temp_service,current_time,FALSE)==TRUE){
 		log_debug_info(DEBUGL_CHECKS,0,"Discarding service freshness check result because the service is currently fresh (race condition avoided).\n");
@@ -2946,13 +3000,11 @@ int run_scheduled_host_check_3x(host *hst, int check_options, double latency){
 int run_async_host_check_3x(host *hst, int check_options, double latency, int scheduled_check, int reschedule_check, int *time_is_valid, time_t *preferred_time){
 	char *raw_command=NULL;
 	char *processed_command=NULL;
-	char output_buffer[MAX_INPUT_BUFFER]="";
 	char *temp_buffer=NULL;
 	struct timeval start_time,end_time;
 	pid_t pid=0;
 	int fork_error=FALSE;
 	int wait_result=0;
-	FILE *fp=NULL;
 	int pclose_result=0;
 	mode_t new_umask=077;
 	mode_t old_umask;
@@ -3176,22 +3228,7 @@ int run_async_host_check_3x(host *hst, int check_options, double latency, int sc
 			max_debug_file_size=0L;
 
 			/* run the plugin check command */
-			fp=popen(processed_command,"r");
-			if(fp==NULL)
-				_exit(STATE_UNKNOWN);
-
-			/* initialize buffer */
-			strcpy(output_buffer,"");
-
-			/* get all lines of plugin output - escape newlines */
-			while(fgets(output_buffer,sizeof(output_buffer)-1,fp)){
-				temp_buffer=escape_newlines(output_buffer);
-				dbuf_strcat(&checkresult_dbuf,temp_buffer);
-				my_free(temp_buffer);
-				}
-
-			/* close the process */
-			pclose_result=pclose(fp);
+			pclose_result=run_check(processed_command,&checkresult_dbuf);
 
 			/* reset the alarm */
 			alarm(0);
@@ -3223,7 +3260,7 @@ int run_async_host_check_3x(host *hst, int check_options, double latency, int sc
 				fprintf(check_result_info.output_file_fp,"early_timeout=%d\n",check_result_info.early_timeout);
 				fprintf(check_result_info.output_file_fp,"exited_ok=%d\n",check_result_info.exited_ok);
 				fprintf(check_result_info.output_file_fp,"return_code=%d\n",check_result_info.return_code);
-				fprintf(check_result_info.output_file_fp,"output=%s\n",(checkresult_dbuf.buf==NULL)?"(null)":checkresult_dbuf.buf); 
+				fprintf(check_result_info.output_file_fp,"output=%s\n",(checkresult_dbuf.buf==NULL)?"(null)":checkresult_dbuf.buf);
 
 				/* close the temp file */
 				fclose(check_result_info.output_file_fp);
@@ -3342,7 +3379,7 @@ int handle_async_host_check_result_3x(host *temp_host, check_result *queued_chec
 
 	/* DISCARD INVALID FRESHNESS CHECK RESULTS */
 	/* If a host goes stale, Icinga will initiate a forced check in order to freshen it.  There is a race condition whereby a passive check
-	   could arrive between the 1) initiation of the forced check and 2) the time when the forced check result is processed here.  This would 
+	   could arrive between the 1) initiation of the forced check and 2) the time when the forced check result is processed here.  This would
 	   make the host fresh again, so we do a quick check to make sure the host is still stale before we accept the check result. */
 	if((queued_check_result->check_options & CHECK_OPTION_FRESHNESS_CHECK) && is_host_result_fresh(temp_host,current_time,FALSE)==TRUE){
 		log_debug_info(DEBUGL_CHECKS,0,"Discarding host freshness check result because the host is currently fresh (race condition avoided).\n");
diff --git a/include/icinga.h b/include/icinga.h
index 7b9d413..b63265c 100644
--- a/include/icinga.h
+++ b/include/icinga.h
@@ -46,8 +46,7 @@ extern "C" {
    command file. EG 10/19/07
 */
 #define MAX_PLUGIN_OUTPUT_LENGTH                8192    /* max length of plugin output (including perf data) */
-#define MAXCHLDARGS    20
-
+#define MAX_CMD_ARGS 				4096	/* max number of arguments for command call on plugin */
 
 
 /******************* DEFAULT VALUES *******************/
-- 
1.7.1

From 741601406428ca7666b8936b04d672561c49ce30 Mon Sep 17 00:00:00 2001
From: Michael Friedrich <michael.friedrich@univie.ac.at>
Date: Fri, 16 Jul 2010 16:05:23 +0200
Subject: [PATCH 4/6] execvp searches in PATH too like popen, and returns if an error occurs, outputting the error string

revamped the previous attempt a bit. there might be discussions about
allowing PATH or not PATH env variables. But by completely breaking
compatibility this won't be nice.

the current attempt only checks if the first argument is set and then
calling execvp - this looks in $PATH if there is no trailing slash set
on the executable.
In case of an error, execvp returns -1 and this is where the error is
put into syslog, exiting with state unknown. (a further adaption would be
setting the output of the plugin like popen behaves)

if you consider not using the PATH for that, you can simply change execvp to
execv and recompile the code. The checks on executable/there are still valid,
except PATH lookups.

refs #436
refs #617
---
 Changelog     |    3 ++-
 base/checks.c |   21 +++++++--------------
 2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/Changelog b/Changelog
index 9de507c..59f6066 100644
--- a/Changelog
+++ b/Changelog
@@ -7,9 +7,9 @@ Icinga 1.0.x Change Log
 ENHANCEMENTS
 
 FIXES
-* core: check permissions before calling execv on a command
 * core: fix temp_path overwritten by check_result_path in base/config.c
 * core: modify execv to execvp, accepting 4096 cmd args, for both host and service checks with adapted error handling
+* core: execvp searches in PATH too like popen, and returns if error, outputting the errno string
 
 * classic ui: fix image urls ins stylesheets
 
@@ -17,6 +17,7 @@ FIXES
 * install: enable debuginfo in spec file
 
 * idoutils: adapt oracle-drop.sql for current schema
+* idoutils: fix binding null values to prepared statements in oracle
 
 
 1.0.2 - 30/06/2010
diff --git a/base/checks.c b/base/checks.c
index d863a58..8f0bdbf 100644
--- a/base/checks.c
+++ b/base/checks.c
@@ -226,24 +226,17 @@ static int run_check(char *processed_command,dbuf *checkresult_dbuf){
 			/* extract command args for execv */
 			parse_command_line(processed_command,argv);
 
-			if(!argv[0])
-				_exit(STATE_UNKNOWN);
-
-			/* check if plugin there/executable */
-			if (access(argv[0], R_OK) !=0 ) {
-				fprintf(stdout,"plugin %s does not exist or is not readable\n",argv[0]);
-				logit(NSLOG_RUNTIME_WARNING,TRUE,"plugin %s does not exists or is not readable\n",argv[0]);
+			if(!argv[0]){
+				logit(NSLOG_RUNTIME_WARNING,TRUE,"plugin command definition empty\n");
 				_exit(STATE_UNKNOWN);
 			}
 
-			if (access(argv[0], X_OK) != 0  ) {
-				fprintf(stdout,"wrong execution permissions on plugin %s\n",argv[0]);
-				logit(NSLOG_RUNTIME_WARNING,TRUE,"wrong execution permissions on plugin %s\n",argv[0]);
+			log_debug_info(DEBUGL_CHECKS,0,"running command %s via execvp\n",processed_command);
+
+			if(execvp(argv[0], argv)<0){ /* execvp only returns in case of an error */
+				logit(NSLOG_RUNTIME_WARNING,TRUE,"error executing command '%s': %s. Make sure that the file actually exists (in PATH, if set) and is executable!\n",processed_command, strerror(errno));
 				_exit(STATE_UNKNOWN);
 			}
-
-			log_debug_info(DEBUGL_CHECKS,0,"running process %s via execv\n",processed_command);
-			execvp(argv[0], argv); /* instead of execvp since we don't use path */
 			_exit(STATE_UNKNOWN);
 		}
 
@@ -266,7 +259,7 @@ static int run_check(char *processed_command,dbuf *checkresult_dbuf){
 			retval=-1;
 	}
 	else{
-		log_debug_info(DEBUGL_CHECKS,0,"running process %s via popen\n",processed_command);
+		log_debug_info(DEBUGL_CHECKS,0,"running command %s via popen\n",processed_command);
 		fp=popen(processed_command,"r");
 
 		if(fp==NULL)
-- 
1.7.1

From 818346b3323df25c442a24c418d71237ee92b230 Mon Sep 17 00:00:00 2001
From: Michael Friedrich <michael.friedrich@univie.ac.at>
Date: Wed, 28 Jul 2010 20:22:02 +0200
Subject: [PATCH 5/6] fix wrong is_volatile conditions causing wrong service alerts in the logs

fixes #650
---
 Changelog     |    1 +
 base/checks.c |    4 ++--
 cgi/config.c  |    2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Changelog b/Changelog
index 59f6066..ebdc6db 100644
--- a/Changelog
+++ b/Changelog
@@ -10,6 +10,7 @@ FIXES
 * core: fix temp_path overwritten by check_result_path in base/config.c
 * core: modify execv to execvp, accepting 4096 cmd args, for both host and service checks with adapted error handling
 * core: execvp searches in PATH too like popen, and returns if error, outputting the errno string
+* core: fix wrong is_volatile conditions causing wrong service alerts in the logs
 
 * classic ui: fix image urls ins stylesheets
 
diff --git a/base/checks.c b/base/checks.c
index 8f0bdbf..190a895 100644
--- a/base/checks.c
+++ b/base/checks.c
@@ -1647,7 +1647,7 @@ int handle_async_service_check_result(service *temp_service, check_result *queue
 			        }
 
 			/* else log the problem (again) if this service is flagged as being volatile */
-			else if(temp_service->is_volatile==FALSE){
+			else if(temp_service->is_volatile!=FALSE){
 				log_service_event(temp_service);
 				state_was_logged=TRUE;
 			        }
@@ -1673,7 +1673,7 @@ int handle_async_service_check_result(service *temp_service, check_result *queue
 			service_notification(temp_service,NOTIFICATION_NORMAL,NULL,NULL,NOTIFICATION_OPTION_NONE);
 
 			/* run the service event handler if we changed state from the last hard state or if this service is flagged as being volatile */
-			if(hard_state_change==TRUE || temp_service->is_volatile==FALSE)
+			if(hard_state_change==TRUE || temp_service->is_volatile!=FALSE)
 				handle_service_event(temp_service);
 
 			/* save the last hard state */
diff --git a/cgi/config.c b/cgi/config.c
index 09adff6..0226d16 100644
--- a/cgi/config.c
+++ b/cgi/config.c
@@ -1249,7 +1249,7 @@ void display_services(void){
 
 		printf("<TD CLASS='%s'>%s</TD>\n",bg_class,(temp_service->parallelize==TRUE)?"Yes":"No");
 
-		printf("<TD CLASS='%s'>%s</TD>\n",bg_class,(temp_service->is_volatile==FALSE)?"Yes":"No");
+		printf("<TD CLASS='%s'>%s</TD>\n",bg_class,(temp_service->is_volatile!=FALSE)?"Yes":"No");
 
 		printf("<TD CLASS='%s'>%s</TD>\n",bg_class,(temp_service->obsess_over_service==TRUE)?"Yes":"No");
 
-- 
1.7.1

From 64467e690032583d2a5b77545d12e002bb584255 Mon Sep 17 00:00:00 2001
From: Michael Friedrich <michael.friedrich@univie.ac.at>
Date: Tue, 3 Aug 2010 17:27:59 +0200
Subject: [PATCH 6/6] fix multiurl action/status icon+macro processing; fix invalid pointer in extinfo.cgi

---
 Changelog       |    2 ++
 cgi/extinfo.c   |    3 ---
 cgi/status.c    |    4 ++--
 common/macros.c |    8 +++++++-
 4 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/Changelog b/Changelog
index ebdc6db..8b4c30b 100644
--- a/Changelog
+++ b/Changelog
@@ -13,6 +13,8 @@ FIXES
 * core: fix wrong is_volatile conditions causing wrong service alerts in the logs
 
 * classic ui: fix image urls ins stylesheets
+* classic ui: fix invalid pointer in extinfo.cgi type=7
+fix macro processing (Jochen Bern)
 
 * install: fix api not installed using make install-unstripped
 * install: enable debuginfo in spec file
diff --git a/cgi/extinfo.c b/cgi/extinfo.c
index 55fc382..63cf8dd 100644
--- a/cgi/extinfo.c
+++ b/cgi/extinfo.c
@@ -2975,8 +2975,6 @@ void show_scheduling_queue(void){
 			printf("&service=%s%s'><img src='%s%s' border=0 ALT='Re-schedule This Service Check' TITLE='Re-schedule This Service Check'></a>\n",url_encode(temp_svcstatus->description),(temp_svcstatus->checks_enabled==TRUE)?"&force_check":"",url_images_path,DELAY_ICON);
 			printf("</TD>\n");
 
-			free(temp_host);
-			free(temp_service);
 		        }
 
 		/* get the host status */
@@ -3027,7 +3025,6 @@ void show_scheduling_queue(void){
 			printf("'><img src='%s%s' border=0 ALT='Re-schedule This Host Check' TITLE='Re-schedule This Host Check'></a>\n",url_images_path,DELAY_ICON);
 			printf("</TD>\n");
 
-			free(temp_host);
 		        }
 
 		printf("</TR>\n");
diff --git a/cgi/status.c b/cgi/status.c
index 3e70fa7..ee91a19 100644
--- a/cgi/status.c
+++ b/cgi/status.c
@@ -1731,7 +1731,7 @@ void show_service_detail(void){
 				printf("<A HREF='");
 				printf("%s",processed_string);
 				printf("' TARGET='%s'>",(notes_url_target==NULL)?"_blank":notes_url_target);
-				printf("<IMG SRC='%s%s%s' BORDER=0 WIDTH=%d HEIGHT=%d ALT='%s' TITLE='%s'>",url_images_path,NOTES_ICON,MU_iconstr,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"View Extra Service Notes","View Extra Service Notes");
+				printf("<IMG SRC='%s%s%s' BORDER=0 WIDTH=%d HEIGHT=%d ALT='%s' TITLE='%s'>",url_images_path,MU_iconstr,NOTES_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"View Extra Service Notes","View Extra Service Notes");
 				printf("</A>");
 				printf("</TD>\n");
 				END_MULTIURL_LOOP
@@ -1744,7 +1744,7 @@ void show_service_detail(void){
 				printf("<A HREF='");
 				printf("%s",processed_string);
 				printf("' TARGET='%s'>",(action_url_target==NULL)?"_blank":action_url_target);
-				printf("<IMG SRC='%s%s%s' BORDER=0 WIDTH=%d HEIGHT=%d ALT='%s' TITLE='%s'>",url_images_path,ACTION_ICON,MU_iconstr,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"Perform Extra Service Actions","Perform Extra Service Actions");
+				printf("<IMG SRC='%s%s%s' BORDER=0 WIDTH=%d HEIGHT=%d ALT='%s' TITLE='%s'>",url_images_path,MU_iconstr,ACTION_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"Perform Extra Service Actions","Perform Extra Service Actions");
 				printf("</A>");
 				printf("</TD>\n");
 				END_MULTIURL_LOOP
diff --git a/common/macros.c b/common/macros.c
index 149b338..01e54fe 100644
--- a/common/macros.c
+++ b/common/macros.c
@@ -77,6 +77,7 @@ contactgroup    *macro_contactgroup_ptr=NULL;
 /* replace macros in notification commands with their values */
 int process_macros(char *input_buffer, char **output_buffer, int options){
 	char *temp_buffer=NULL;
+	char *save_buffer=NULL;
 	char *buf_ptr=NULL;
 	char *delim_ptr=NULL;
 	int in_macro=FALSE;
@@ -107,7 +108,9 @@ int process_macros(char *input_buffer, char **output_buffer, int options){
 	log_debug_info(DEBUGL_MACROS,1,"**** BEGIN MACRO PROCESSING ***********\n");
 	log_debug_info(DEBUGL_MACROS,1,"Processing: '%s'\n",input_buffer);
 
-	buf_ptr=input_buffer;
+        /* save original input_buffer ptr for later free'ing */
+        save_buffer=buf_ptr=(input_buffer?strdup(input_buffer):NULL);
+
 	while(buf_ptr){
 
 		/* save pointer to this working part of buffer */
@@ -240,6 +243,9 @@ int process_macros(char *input_buffer, char **output_buffer, int options){
 	log_debug_info(DEBUGL_MACROS,1,"  Done.  Final output: '%s'\n",*output_buffer);
 	log_debug_info(DEBUGL_MACROS,1,"**** END MACRO PROCESSING *************\n");
 
+        if (save_buffer)
+                free(save_buffer);
+
 	return OK;
 	}
 
-- 
1.7.1


Reply to: