--- config.c.orig 2009-05-15 16:02:47.000000000 +0200 +++ config.c 2010-08-31 15:40:37.000000000 +0200 @@ -65,6 +65,7 @@ #define DISPLAY_HOSTDEPENDENCIES 11 #define DISPLAY_HOSTESCALATIONS 12 #define DISPLAY_SERVICEGROUPS 15 +#define DISPLAY_COMMAND_EXPANSION 16211 void document_header(int); void document_footer(void); @@ -84,6 +85,7 @@ void display_serviceescalations(void); void display_hostdependencies(void); void display_hostescalations(void); +void display_command_expansion(void); void unauthorized_message(void); @@ -91,9 +93,24 @@ authdata current_authdata; int display_type=DISPLAY_NONE; +char to_expand[MAX_COMMAND_BUFFER]; +char hashed_color[8]; int embedded=FALSE; +void print_expand_input(int type){ + char *seldesc=""; + + if (type==DISPLAY_COMMAND_EXPANSION) return; /* Has its own form, w/ larger */ + else if (type==DISPLAY_SERVICES){ seldesc=" Services Named or on Host"; } + else if (type==DISPLAY_SERVICEDEPENDENCIES){ seldesc=" Dependencies with Host"; } + else if (type==DISPLAY_SERVICEESCALATIONS){ seldesc=" Escalations on Host"; } + else if (type==DISPLAY_HOSTDEPENDENCIES){ seldesc=" Dependencies on/of Host"; } + else if (type==DISPLAY_HOSTESCALATIONS){ seldesc=" Escalations for Host"; } + printf("
%s | \n",bg_class,url_encode(temp_host->name),temp_host->name); - printf("%s | \n",bg_class,temp_host->alias); - printf("%s | \n",bg_class,temp_host->address); + printf("%s | \n",bg_class, + url_encode(temp_host->name),CONFIG_CGI,url_encode(temp_host->name),html_encode(temp_host->name,FALSE)); + printf("%s | \n",bg_class,html_encode(temp_host->alias,FALSE)); + printf("%s | \n",bg_class,html_encode(temp_host->address,FALSE)); printf("",bg_class); for(temp_hostsmember=temp_host->parent_hosts;temp_hostsmember!=NULL;temp_hostsmember=temp_hostsmember->next){ @@ -494,7 +539,7 @@ if(temp_hostsmember!=temp_host->parent_hosts) printf(", "); - printf("%s\n",CONFIG_CGI,url_encode(temp_hostsmember->host_name),temp_hostsmember->host_name); + printf("%s\n",CONFIG_CGI,url_encode(temp_hostsmember->host_name),html_encode(temp_hostsmember->host_name,FALSE)); } if(temp_host->parent_hosts==NULL) printf(" "); @@ -512,14 +557,15 @@ if(temp_host->host_check_command==NULL) printf(" "); else - printf("%s | \n",CONFIG_CGI,url_encode(temp_host->host_check_command),html_encode(temp_host->host_check_command,FALSE)); + /* printf("%s\n",CONFIG_CGI,url_encode(strtok(temp_host->host_check_command,"!")),html_encode(temp_host->host_check_command,FALSE)); */ + printf("%s\n",CONFIG_CGI,url_encode(temp_host->host_check_command),html_encode(temp_host->host_check_command,FALSE)); printf("\n"); printf("",bg_class); if(temp_host->check_period==NULL) printf(" "); else - printf("%s",CONFIG_CGI,url_encode(temp_host->check_period),temp_host->check_period); + printf("%s",CONFIG_CGI,url_encode(temp_host->check_period),html_encode(temp_host->check_period,FALSE)); printf(" | \n"); printf("%s | \n",bg_class,(temp_host->obsess_over_host==TRUE)?"Yes":"No"); @@ -546,20 +592,20 @@ if(contact>1) printf(", "); - printf("%s\n",CONFIG_CGI,url_encode(temp_contactsmember->contact_name),temp_contactsmember->contact_name); + printf("%s\n",CONFIG_CGI,url_encode(temp_contactsmember->contact_name),html_encode(temp_contactsmember->contact_name,FALSE)); } for(temp_contactgroupsmember=temp_host->contact_groups;temp_contactgroupsmember!=NULL;temp_contactgroupsmember=temp_contactgroupsmember->next){ contact++; if(contact>1) printf(", "); - printf("%s\n",CONFIG_CGI,url_encode(temp_contactgroupsmember->group_name),temp_contactgroupsmember->group_name); + printf("%s\n",CONFIG_CGI,url_encode(temp_contactgroupsmember->group_name),html_encode(temp_contactgroupsmember->group_name,FALSE)); } if(contact==0) printf(" "); printf("\n"); get_interval_time_string(temp_host->notification_interval,time_string,sizeof(time_string)); - printf("%s | \n",bg_class,(temp_host->notification_interval==0)?"No Re-notification":time_string); + printf("%s | \n",bg_class,(temp_host->notification_interval==0)?"No Re-notification":html_encode(time_string,FALSE)); get_interval_time_string(temp_host->first_notification_delay,time_string,sizeof(time_string)); printf("%s | \n",bg_class,time_string); @@ -594,14 +640,15 @@ if(temp_host->notification_period==NULL) printf(" "); else - printf("%s",CONFIG_CGI,url_encode(temp_host->notification_period),temp_host->notification_period); + printf("%s",CONFIG_CGI,url_encode(temp_host->notification_period),html_encode(temp_host->notification_period,FALSE)); printf("\n"); printf("",bg_class); if(temp_host->event_handler==NULL) printf(" "); else - printf("%s | \n",CONFIG_CGI,url_encode(temp_host->event_handler),temp_host->event_handler); + /* printf("%s\n",CONFIG_CGI,url_encode(strtok(temp_host->event_handler,"!")),html_encode(temp_host->event_handler,FALSE)); */ + printf("%s\n",CONFIG_CGI,url_encode(temp_host->event_handler),html_encode(temp_host->event_handler,FALSE)); printf("\n"); printf("",bg_class); @@ -670,13 +717,13 @@ printf("%s\n",(temp_host->failure_prediction_enabled==TRUE)?"Yes":"No"); printf(" | \n"); - printf("%s | \n",bg_class,(temp_host->failure_prediction_options==NULL)?" ":temp_host->failure_prediction_options); + printf("%s | \n",bg_class,(temp_host->failure_prediction_options==NULL)?" ":html_encode(temp_host->failure_prediction_options,FALSE)); - printf("%s | ",bg_class,(temp_host->notes==NULL)?" ":temp_host->notes); + printf("%s | ",bg_class,(temp_host->notes==NULL)?" ":html_encode(temp_host->notes,FALSE)); - printf("%s | ",bg_class,(temp_host->notes_url==NULL)?" ":temp_host->notes_url); + printf("%s | ",bg_class,(temp_host->notes_url==NULL)?" ":html_encode(temp_host->notes_url,FALSE)); - printf("%s | ",bg_class,(temp_host->action_url==NULL)?" ":temp_host->action_url); + printf("%s | ",bg_class,(temp_host->action_url==NULL)?" ":html_encode(temp_host->action_url,FALSE)); if(temp_host->have_2d_coords==FALSE) printf("",bg_class); @@ -691,22 +738,22 @@ if(temp_host->statusmap_image==NULL) printf(" | ",bg_class); else - printf(" | ",bg_class); else - printf(" | ",bg_class); else{ process_macros(temp_host->icon_image,&processed_string,0); - printf(" | %s | ",bg_class,(temp_host->icon_image_alt==NULL)?" ":temp_host->icon_image_alt); + printf("%s | ",bg_class,(temp_host->icon_image_alt==NULL)?" ":html_encode(temp_host->icon_image_alt,FALSE)); printf("",bg_class);
options=0;
@@ -746,7 +793,8 @@
return;
}
- printf(" Host Groups \n");
+ printf("Host Group%s%s \n",
+ (*to_expand=='\0'?"s":" "),(*to_expand=='\0'?"":html_encode(to_expand,FALSE)));
printf("\n"); printf(" \n");
@@ -762,7 +810,7 @@
printf(" | |||||||||||||
%s | ",bg_class,temp_hostgroup->group_name); + printf("%s | ",bg_class,html_encode(temp_hostgroup->group_name,FALSE)); - printf("%s | \n",bg_class,temp_hostgroup->alias); + printf("%s | \n",bg_class,html_encode(temp_hostgroup->alias,FALSE)); printf("",bg_class); @@ -786,15 +834,15 @@ if(temp_hostsmember!=temp_hostgroup->members) printf(", "); - printf("%s\n",CONFIG_CGI,url_encode(temp_hostsmember->host_name),temp_hostsmember->host_name); + printf("%s\n",CONFIG_CGI,url_encode(temp_hostsmember->host_name),html_encode(temp_hostsmember->host_name,FALSE)); } printf(" | \n"); - printf("%s | ",bg_class,(temp_hostgroup->notes==NULL)?" ":temp_hostgroup->notes); + printf("%s | ",bg_class,(temp_hostgroup->notes==NULL)?" ":html_encode(temp_hostgroup->notes,FALSE)); - printf("%s | ",bg_class,(temp_hostgroup->notes_url==NULL)?" ":temp_hostgroup->notes_url); + printf("%s | ",bg_class,(temp_hostgroup->notes_url==NULL)?" ":html_encode(temp_hostgroup->notes_url,FALSE)); - printf("%s | ",bg_class,(temp_hostgroup->action_url==NULL)?" ":temp_hostgroup->action_url); + printf("%s | ",bg_class,(temp_hostgroup->action_url==NULL)?" ":html_encode(temp_hostgroup->action_url,FALSE)); printf("|||||||||||||||||||||||||||||||
%s | ",bg_class,temp_servicegroup->group_name); + printf("%s | ",bg_class,html_encode(temp_servicegroup->group_name,FALSE)); - printf("%s | \n",bg_class,temp_servicegroup->alias); + printf("%s | \n",bg_class,html_encode(temp_servicegroup->alias,FALSE)); printf("",bg_class); /* find all the services that are members of this servicegroup... */ for(temp_servicesmember=temp_servicegroup->members;temp_servicesmember!=NULL;temp_servicesmember=temp_servicesmember->next){ - printf("%s%s / ",(temp_servicesmember==temp_servicegroup->members)?"":", ",CONFIG_CGI,url_encode(temp_servicesmember->host_name),temp_servicesmember->host_name); + printf("%s%s / ",(temp_servicesmember==temp_servicegroup->members)?"":", ",CONFIG_CGI,url_encode(temp_servicesmember->host_name),html_encode(temp_servicesmember->host_name,FALSE)); - printf("%s\n",url_encode(temp_servicesmember->service_description),temp_servicesmember->service_description); + printf("%s\n",url_encode(temp_servicesmember->service_description),html_encode(temp_servicesmember->service_description,FALSE)); } printf(" | \n"); - printf("%s | ",bg_class,(temp_servicegroup->notes==NULL)?" ":temp_servicegroup->notes); + printf("%s | ",bg_class,(temp_servicegroup->notes==NULL)?" ":html_encode(temp_servicegroup->notes,FALSE)); - printf("%s | ",bg_class,(temp_servicegroup->notes_url==NULL)?" ":temp_servicegroup->notes_url); + printf("%s | ",bg_class,(temp_servicegroup->notes_url==NULL)?" ":html_encode(temp_servicegroup->notes_url,FALSE)); - printf("%s | ",bg_class,(temp_servicegroup->action_url==NULL)?" ":temp_servicegroup->action_url); + printf("%s | ",bg_class,(temp_servicegroup->action_url==NULL)?" ":html_encode(temp_servicegroup->action_url,FALSE)); printf("|||||||||||||||||||||||||||||||
%s | \n",bg_class,url_encode(temp_contact->name),temp_contact->name); - printf("%s | \n",bg_class,temp_contact->alias); - printf("%s | \n",bg_class,(temp_contact->email==NULL)?" ":temp_contact->email,(temp_contact->email==NULL)?" ":temp_contact->email); - printf("%s | \n",bg_class,(temp_contact->pager==NULL)?" ":temp_contact->pager); + printf("%s | \n",bg_class,url_encode(temp_contact->name),html_encode(temp_contact->name,FALSE)); + printf("%s | \n",bg_class,html_encode(temp_contact->alias,FALSE)); + printf("%s | \n",bg_class,(temp_contact->email==NULL)?" ":url_encode(temp_contact->email),(temp_contact->email==NULL)?" ":html_encode(temp_contact->email,FALSE)); + printf("%s | \n",bg_class,(temp_contact->pager==NULL)?" ":html_encode(temp_contact->pager,FALSE)); printf("",bg_class); options=0; @@ -998,14 +1048,14 @@ if(temp_contact->service_notification_period==NULL) printf(" "); else - printf("%s",CONFIG_CGI,url_encode(temp_contact->service_notification_period),temp_contact->service_notification_period); + printf("%s",CONFIG_CGI,url_encode(temp_contact->service_notification_period),html_encode(temp_contact->service_notification_period,FALSE)); printf(" | \n"); printf("\n",bg_class); if(temp_contact->host_notification_period==NULL) printf(" "); else - printf("%s",CONFIG_CGI,url_encode(temp_contact->host_notification_period),temp_contact->host_notification_period); + printf("%s",CONFIG_CGI,url_encode(temp_contact->host_notification_period),html_encode(temp_contact->host_notification_period,FALSE)); printf(" | \n"); printf("",bg_class);
@@ -1015,7 +1065,8 @@
if(temp_commandsmember!=temp_contact->service_notification_commands)
printf(", ");
- printf("%s",CONFIG_CGI,url_encode(temp_commandsmember->command),temp_commandsmember->command);
+ /* printf("%s",CONFIG_CGI,url_encode(strtok(temp_commandsmember->command,"!")),html_encode(temp_commandsmember->command,FALSE)); */
+ printf("%s",CONFIG_CGI,url_encode(temp_commandsmember->command),html_encode(temp_commandsmember->command,FALSE));
found=TRUE;
}
@@ -1030,7 +1081,8 @@
if(temp_commandsmember!=temp_contact->host_notification_commands)
printf(", ");
- printf("%s",CONFIG_CGI,url_encode(temp_commandsmember->command),temp_commandsmember->command);
+ /* printf("%s",CONFIG_CGI,url_encode(strtok(temp_commandsmember->command,"!")),html_encode(temp_commandsmember->command,FALSE)); */
+ printf("%s",CONFIG_CGI,url_encode(temp_commandsmember->command),html_encode(temp_commandsmember->command,FALSE));
found=TRUE;
}
@@ -1077,7 +1129,8 @@
}
- printf(" Contact Groups \n");
+ printf("Contact Group%s%s \n",
+ (*to_expand=='\0'?"s":" "),(*to_expand=='\0'?"":html_encode(to_expand,FALSE)));
printf("\n"); printf(" \n");
@@ -1091,7 +1144,7 @@
printf(" | |||||||||||||||||||||||||||||||
%s | \n",bg_class,url_encode(temp_contactgroup->group_name),temp_contactgroup->group_name); - printf("%s | \n",bg_class,temp_contactgroup->alias); + printf("%s | \n",bg_class,url_encode(temp_contactgroup->group_name),html_encode(temp_contactgroup->group_name,FALSE)); + printf("%s | \n",bg_class,html_encode(temp_contactgroup->alias,FALSE)); /* find all the contact who are members of this contact group... */ printf("",bg_class); @@ -1114,7 +1167,7 @@ if(temp_contactsmember!=temp_contactgroup->members) printf(", "); - printf("%s\n",CONFIG_CGI,url_encode(temp_contactsmember->contact_name),temp_contactsmember->contact_name); + printf("%s\n",CONFIG_CGI,url_encode(temp_contactsmember->contact_name),html_encode(temp_contactsmember->contact_name,FALSE)); } printf(" | \n"); @@ -1150,7 +1203,8 @@ return; } - printf("",url_encode(temp_service->description)); - printf("%s | \n",CONFIG_CGI,url_encode(temp_service->host_name),temp_service->host_name); + printf("%s\n",CONFIG_CGI,url_encode(temp_service->host_name),html_encode(temp_service->host_name,FALSE)); - printf("%s | \n",bg_class,temp_service->description); + printf("%s | \n",bg_class,html_encode(temp_service->description,FALSE)); printf("%d | \n",bg_class,temp_service->max_attempts); @@ -1230,14 +1285,16 @@ strncpy(command_line,temp_service->service_check_command,sizeof(command_line)); command_line[sizeof(command_line)-1]='\x0'; - command_name=strtok(command_line,"!"); + command_name=strtok(strdup(command_line),"!"); - printf("%s | \n",bg_class,CONFIG_CGI,url_encode(command_name),html_encode(temp_service->service_check_command,FALSE)); + /* printf("%s | \n",bg_class,CONFIG_CGI,url_encode(command_name),html_encode(command_line,FALSE)); */ + printf("%s | \n",bg_class,CONFIG_CGI,url_encode(command_line),html_encode(command_line,FALSE)); + free(command_name); printf("",bg_class); if(temp_service->check_period==NULL) printf(" "); else - printf("%s",CONFIG_CGI,url_encode(temp_service->check_period),temp_service->check_period); + printf("%s",CONFIG_CGI,url_encode(temp_service->check_period),html_encode(temp_service->check_period,FALSE)); printf(" | \n"); printf("%s | \n",bg_class,(temp_service->parallelize==TRUE)?"Yes":"No"); @@ -1265,13 +1322,13 @@ contact++; if(contact>1) printf(", "); - printf("%s",CONFIG_CGI,url_encode(temp_contactsmember->contact_name),temp_contactsmember->contact_name); + printf("%s",CONFIG_CGI,url_encode(temp_contactsmember->contact_name),html_encode(temp_contactsmember->contact_name,FALSE)); } for(temp_contactgroupsmember=temp_service->contact_groups;temp_contactgroupsmember!=NULL;temp_contactgroupsmember=temp_contactgroupsmember->next){ contact++; if(contact>1) printf(", "); - printf("%s\n",CONFIG_CGI,url_encode(temp_contactgroupsmember->group_name),temp_contactgroupsmember->group_name); + printf("%s\n",CONFIG_CGI,url_encode(temp_contactgroupsmember->group_name),html_encode(temp_contactgroupsmember->group_name,FALSE)); } if(contact==0) printf(" "); @@ -1282,7 +1339,7 @@ printf("\n"); get_interval_time_string(temp_service->notification_interval,time_string,sizeof(time_string)); - printf("%s | \n",bg_class,(temp_service->notification_interval==0)?"No Re-notification":time_string); + printf("%s | \n",bg_class,(temp_service->notification_interval==0)?"No Re-notification":html_encode(time_string,FALSE)); get_interval_time_string(temp_service->first_notification_delay,time_string,sizeof(time_string)); printf("%s | \n",bg_class,time_string); @@ -1320,13 +1377,14 @@ if(temp_service->notification_period==NULL) printf(" "); else - printf("%s",CONFIG_CGI,url_encode(temp_service->notification_period),temp_service->notification_period); + printf("%s",CONFIG_CGI,url_encode(temp_service->notification_period),html_encode(temp_service->notification_period,FALSE)); printf("\n"); printf("",bg_class); if(temp_service->event_handler==NULL) printf(" "); else - printf("%s",CONFIG_CGI,url_encode(temp_service->event_handler),temp_service->event_handler); + /* printf("%s",CONFIG_CGI,url_encode(strtok(temp_service->event_handler,"!")),html_encode(temp_service->event_handler,FALSE)); */ + printf("%s",CONFIG_CGI,url_encode(temp_service->event_handler),html_encode(temp_service->event_handler,FALSE)); printf(" | \n"); printf("",bg_class); @@ -1403,23 +1461,23 @@ printf("%s\n",(temp_service->failure_prediction_enabled==TRUE)?"Yes":"No"); printf(" | \n"); - printf("%s | \n",bg_class,(temp_service->failure_prediction_options==NULL)?" ":temp_service->failure_prediction_options); + printf("%s | \n",bg_class,(temp_service->failure_prediction_options==NULL)?" ":html_encode(temp_service->failure_prediction_options,FALSE)); - printf("%s | ",bg_class,(temp_service->notes==NULL)?" ":temp_service->notes); + printf("%s | ",bg_class,(temp_service->notes==NULL)?" ":html_encode(temp_service->notes,FALSE)); - printf("%s | ",bg_class,(temp_service->notes_url==NULL)?" ":temp_service->notes_url); + printf("%s | ",bg_class,(temp_service->notes_url==NULL)?" ":html_encode(temp_service->notes_url,FALSE)); - printf("%s | ",bg_class,(temp_service->action_url==NULL)?" ":temp_service->action_url); + printf("%s | ",bg_class,(temp_service->action_url==NULL)?" ":html_encode(temp_service->action_url,FALSE)); if(temp_service->icon_image==NULL) printf("",bg_class); else{ process_macros(temp_service->icon_image,&processed_string,0); - printf(" | %s | ",bg_class,(temp_service->icon_image_alt==NULL)?" ":temp_service->icon_image_alt); + printf("%s | ",bg_class,(temp_service->icon_image_alt==NULL)?" ":html_encode(temp_service->icon_image_alt,FALSE)); printf("",bg_class);
options=0;
@@ -1471,7 +1529,8 @@
return;
}
- printf(" Time Periods \n");
+ printf("Time Period%s%s \n",
+ (*to_expand=='\0'?"s":" "),(*to_expand=='\0'?"":html_encode(to_expand,FALSE)));
printf("\n"); printf(" \n");
@@ -1486,7 +1545,7 @@
printf("\n");
/* check all the time periods... */
- for(temp_timeperiod=timeperiod_list;temp_timeperiod!=NULL;temp_timeperiod=temp_timeperiod->next){
+ for(temp_timeperiod=timeperiod_list;temp_timeperiod!=NULL;temp_timeperiod=temp_timeperiod->next) if (((*to_expand)=='\0')||(!strcmp(to_expand,temp_timeperiod->name))){
if(odd){
odd=0;
@@ -1499,14 +1558,14 @@
printf(" %s | \n",bg_class,url_encode(temp_timeperiod->name),temp_timeperiod->name);
- printf("%s | \n",bg_class,temp_timeperiod->alias);
+ printf("%s | \n",bg_class,url_encode(temp_timeperiod->name),html_encode(temp_timeperiod->name,FALSE));
+ printf("%s | \n",bg_class,html_encode(temp_timeperiod->alias,FALSE));
printf("",bg_class);
item=0;
for(temp_timeperiodexclusion=temp_timeperiod->exclusions;temp_timeperiodexclusion!=NULL;temp_timeperiodexclusion=temp_timeperiodexclusion->next){
item++;
- printf("%s%s",(item==1)?"":", ",url_encode(temp_timeperiodexclusion->timeperiod_name),temp_timeperiodexclusion->timeperiod_name);
+ printf("%s%s",(item==1)?"":", ",url_encode(temp_timeperiodexclusion->timeperiod_name),html_encode(temp_timeperiodexclusion->timeperiod_name,FALSE));
}
printf(" | ");
@@ -1655,14 +1714,15 @@
return;
}
- printf("Commands \n");
+ printf("Command%s%s \n",
+ (*to_expand=='\0'?"s":" "),(*to_expand=='\0'?"":html_encode(to_expand,FALSE)));
printf("\n");
printf("
|