2 patches to fix minor issues in Nagios 2.0
Christopher Gurnee
gurnec at gis.net
Mon Mar 15 22:31:30 CET 2004
First issue:
When a hostgroup is defined with no members, the last host definition to
have a "hostgroups" attribute which references the hostgroup is not
correctly added to the hostgroup, and causes an error. (Host definitions
in the config files are added to hostgroups in reverse order.)
*** ../nagios-orig/xdata/xodtemplate.c Mon Feb 16 20:59:32 2004
--- xdata/xodtemplate.c Mon Mar 15 14:38:01 2004
***************
*** 6408,6414 ****
/* add this list to the hostgroup members directive */
if(temp_hostgroup->members==NULL)
! temp_hostgroup->members=strdup(temp_ptr);
else{
new_members=(char *)realloc(temp_hostgroup->members,strlen(temp_hostgroup->members)+strlen(temp_host->host_name)+2);
if(new_members!=NULL){
--- 6408,6414 ----
/* add this list to the hostgroup members directive */
if(temp_hostgroup->members==NULL)
! temp_hostgroup->members=strdup(temp_host->host_name);
else{
new_members=(char *)realloc(temp_hostgroup->members,strlen(temp_hostgroup->members)+strlen(temp_host->host_name)+2);
if(new_members!=NULL){
Second issue:
The clean_macro_chars are stripped from handlers before they are
executed, but not from notifications as the docs suggest.
*** ../nagios-orig/base/notifications.c Tue Feb 10 23:48:47 2004
--- base/notifications.c Fri Mar 5 13:52:43 2004
***************
*** 577,582 ****
--- 577,583 ----
char temp_buffer[MAX_INPUT_BUFFER];
int early_timeout=FALSE;
double exectime;
+ int macro_options=STRIP_ILLEGAL_MACRO_CHARS|ESCAPE_MACRO_CHARS;
#ifdef DEBUG0
printf("notify_contact_of_service() start\n");
***************
*** 599,609 ****
command_name_ptr=strtok(command_name,"!");
/* get the raw command line */
! get_raw_command_line(temp_commandsmember->command,raw_command,sizeof(raw_command),0);
strip(raw_command);
/* process any macros contained in the argument */
! process_macros(raw_command,processed_command,sizeof(processed_command),0);
strip(processed_command);
/* run the notification command */
--- 600,610 ----
command_name_ptr=strtok(command_name,"!");
/* get the raw command line */
! get_raw_command_line(temp_commandsmember->command,raw_command,sizeof(raw_command),macro_options);
strip(raw_command);
/* process any macros contained in the argument */
! process_macros(raw_command,processed_command,sizeof(processed_command),macro_options);
strip(processed_command);
/* run the notification command */
***************
*** 1250,1257 ****
char processed_command[MAX_INPUT_BUFFER];
int early_timeout=FALSE;
double exectime;
-
#ifdef DEBUG0
printf("notify_contact_of_host() start\n");
#endif
--- 1251,1258 ----
char processed_command[MAX_INPUT_BUFFER];
int early_timeout=FALSE;
double exectime;
+ int macro_options=STRIP_ILLEGAL_MACRO_CHARS|ESCAPE_MACRO_CHARS;
#ifdef DEBUG0
printf("notify_contact_of_host() start\n");
#endif
***************
*** 1273,1289 ****
command_name_ptr=strtok(command_name,"!");
/* get the raw command line */
! get_raw_command_line(temp_commandsmember->command,raw_command,sizeof(raw_command),0);
strip(raw_command);
/* process any macros contained in the argument */
! process_macros(raw_command,processed_command,sizeof(processed_command),0);
strip(processed_command);
/* run the notification command */
if(strcmp(processed_command,"")){
-
#ifdef DEBUG4
printf("\tRaw Command: %s\n",raw_command);
printf("\tProcessed Command: %s\n",processed_command);
--- 1274,1289 ----
command_name_ptr=strtok(command_name,"!");
/* get the raw command line */
! get_raw_command_line(temp_commandsmember->command,raw_command,sizeof(raw_command),macro_options);
strip(raw_command);
/* process any macros contained in the argument */
! process_macros(raw_command,processed_command,sizeof(processed_command),macro_options);
strip(processed_command);
/* run the notification command */
if(strcmp(processed_command,"")){
#ifdef DEBUG4
printf("\tRaw Command: %s\n",raw_command);
printf("\tProcessed Command: %s\n",processed_command);
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
More information about the Developers
mailing list