------=_Part_1966_32718089.1224081049661
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Hi,
Some days ago somebody here point an issue on status.cgi plugin_output treatment when the output contains a backslash in the end, so I had the same problem again. As instance you can see below a service status directly from status.log:
servicestatus {
host_name=SPO-PONTE109
service_description=Lotus_DATABASE_Fatal
plugin_output=Monitor.Last.DATABASE COMPACTOR.FatalText = Error compacting mail\
}
Reading the above from status.log, status.cgi brokes with a SIGSEGV. We patch the source to eliminate these undesirable backslashes, the patch follow this mail.
The ideal solution is prevent nagios from store these backslashes in status.log, anybody here can point me where to look to achieve this "ideal solution"? The patch attached can broke something that I can't see?
-rm
------=_Part_1966_32718089.1224081049661
Content-Type: text/x-patch; name=backslash.diff
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=backslash.diff
diff -Naur b/cgi/cgiutils.c a/cgi/cgiutils.c
--- b/cgi/cgiutils.c 2008-06-23 17:47:44.000000000 -0300
+++ a/cgi/cgiutils.c 2008-10-15 10:59:52.000000000 -0300
@@ -732,6 +732,16 @@
**********************************************************/
+void strip_end_backslash(char *buffer){
+
+ int y;
+ y=(int)strlen(buffer);
+ y--;
+ if(buffer[y] == '\\')
+ buffer[y] = '\x0';
+
+}
+
/* strip newline, carriage return, and tab characters from beginning and end of a string */
void strip(char *buffer){
register int x;
diff -Naur b/xdata/xsddefault.c a/xdata/xsddefault.c
--- b/xdata/xsddefault.c 2008-02-28 16:27:56.000000000 -0300
+++ a/xdata/xsddefault.c 2008-10-15 11:01:36.000000000 -0300
@@ -1024,10 +1024,12 @@
else if(!strcmp(var,"last_hard_state"))
temp_hoststatus->last_hard_state=atoi(val);
else if(!strcmp(var,"plugin_output")){
+ strip_end_backslash(val);
temp_hoststatus->plugin_output=(char *)strdup(val);
unescape_newlines(temp_hoststatus->plugin_output);
}
else if(!strcmp(var,"long_plugin_output")){
+ strip_end_backslash(val);
temp_hoststatus->long_plugin_output=(char *)strdup(val);
unescape_newlines(temp_hoststatus->long_plugin_output);
}
@@ -1144,10 +1146,12 @@
else if(!strcmp(var,"last_time_critical"))
temp_servicestatus->last_time_critical=strtoul(val,NULL,10);
else if(!strcmp(var,"plugin_output")){
+ strip_end_backslash(val);
temp_servicestatus->plugin_output=(char *)strdup(val);
unescape_newlines(temp_servicestatus->plugin_output);
}
else if(!strcmp(var,"long_plugin_output")){
+ strip_end_backslash(val);
temp_servicestatus->long_plugin_output=(char *)strdup(val);
unescape_newlines(temp_servicestatus->long_plugin_output);
}
------=_Part_1966_32718089.1224081049661--
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]