Skip to content

Commit

Permalink
RPM spec file fix for building on 64bit systems, possible fix for uni…
Browse files Browse the repository at this point in the history
…code html encoding errors in CGIs

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@1086 5f96b256-904b-4d8d-8c98-d829582c6739
  • Loading branch information
Ethan Galstad committed Oct 31, 2007
1 parent 3f311be commit 42ee00d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 25 deletions.
1 change: 1 addition & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Nagios 3.x Change Log
* Better error logging when failing to rename/move files
* Added $LASTHOSTSTATE$, $LASTHOSTSTATEID$, $LASTSERVICESTATE$, and $LASTSERVICESTATEID$ macros
* Addition of object pointers to event broker module data structures (may require event broker module rebuilds)
* Spec file changes to better support RPM builds on 64-bit systems



Expand Down
52 changes: 31 additions & 21 deletions base/notifications.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* NOTIFICATIONS.C - Service and host notification functions for Nagios
*
* Copyright (c) 1999-2007 Ethan Galstad ([email protected])
* Last Modified: 10-24-2007
* Last Modified: 10-31-2007
*
* License:
*
Expand Down Expand Up @@ -640,6 +640,7 @@ int notify_contact_of_service(contact *cntct, service *svc, int type, char *not_
char *raw_command=NULL;
char *processed_command=NULL;
char *temp_buffer=NULL;
char *processed_buffer=NULL;
int early_timeout=FALSE;
double exectime;
struct timeval start_time,end_time;
Expand Down Expand Up @@ -703,35 +704,39 @@ int notify_contact_of_service(contact *cntct, service *svc, int type, char *not_
if(log_notifications==TRUE){
switch(type){
case NOTIFICATION_CUSTOM:
asprintf(&temp_buffer,"SERVICE NOTIFICATION: %s;%s;%s;CUSTOM (%s);%s;%s;%s;%s\n",cntct->name,svc->host_name,svc->description,macro_x[MACRO_SERVICESTATE],command_name_ptr,macro_x[MACRO_SERVICEOUTPUT],macro_x[MACRO_NOTIFICATIONAUTHOR],macro_x[MACRO_NOTIFICATIONCOMMENT]);
asprintf(&temp_buffer,"SERVICE NOTIFICATION: %s;%s;%s;CUSTOM ($SERVICESTATE$);%s;$SERVICEOUTPUT$;$NOTIFICATIONAUTHOR$;$NOTIFICATIONCOMMENT$\n",cntct->name,svc->host_name,svc->description,command_name_ptr);
break;
case NOTIFICATION_ACKNOWLEDGEMENT:
asprintf(&temp_buffer,"SERVICE NOTIFICATION: %s;%s;%s;ACKNOWLEDGEMENT (%s);%s;%s;%s;%s\n",cntct->name,svc->host_name,svc->description,macro_x[MACRO_SERVICESTATE],command_name_ptr,macro_x[MACRO_SERVICEOUTPUT],macro_x[MACRO_NOTIFICATIONAUTHOR],macro_x[MACRO_NOTIFICATIONCOMMENT]);
asprintf(&temp_buffer,"SERVICE NOTIFICATION: %s;%s;%s;ACKNOWLEDGEMENT ($SERVICESTATE$);%s;$SERVICEOUTPUT$;$NOTIFICATIONAUTHOR$;$NOTIFICATIONCOMMENT$\n",cntct->name,svc->host_name,svc->description,command_name_ptr);
break;
case NOTIFICATION_FLAPPINGSTART:
asprintf(&temp_buffer,"SERVICE NOTIFICATION: %s;%s;%s;FLAPPINGSTART (%s);%s;%s\n",cntct->name,svc->host_name,svc->description,macro_x[MACRO_SERVICESTATE],command_name_ptr,macro_x[MACRO_SERVICEOUTPUT]);
asprintf(&temp_buffer,"SERVICE NOTIFICATION: %s;%s;%s;FLAPPINGSTART ($SERVICESTATE$);%s;$SERVICEOUTPUT$\n",cntct->name,svc->host_name,svc->description,command_name_ptr);
break;
case NOTIFICATION_FLAPPINGSTOP:
asprintf(&temp_buffer,"SERVICE NOTIFICATION: %s;%s;%s;FLAPPINGSTOP (%s);%s;%s\n",cntct->name,svc->host_name,svc->description,macro_x[MACRO_SERVICESTATE],command_name_ptr,macro_x[MACRO_SERVICEOUTPUT]);
asprintf(&temp_buffer,"SERVICE NOTIFICATION: %s;%s;%s;FLAPPINGSTOP ($SERVICESTATE$);%s;$SERVICEOUTPUT$\n",cntct->name,svc->host_name,svc->description,command_name_ptr);
break;
case NOTIFICATION_FLAPPINGDISABLED:
asprintf(&temp_buffer,"SERVICE NOTIFICATION: %s;%s;%s;FLAPPINGDISABLED (%s);%s;%s\n",cntct->name,svc->host_name,svc->description,macro_x[MACRO_SERVICESTATE],command_name_ptr,macro_x[MACRO_SERVICEOUTPUT]);
asprintf(&temp_buffer,"SERVICE NOTIFICATION: %s;%s;%s;FLAPPINGDISABLED ($SERVICESTATE$);%s;$SERVICEOUTPUT$\n",cntct->name,svc->host_name,svc->description,command_name_ptr);
break;
case NOTIFICATION_DOWNTIMESTART:
asprintf(&temp_buffer,"SERVICE NOTIFICATION: %s;%s;%s;DOWNTIMESTART (%s);%s;%s\n",cntct->name,svc->host_name,svc->description,macro_x[MACRO_SERVICESTATE],command_name_ptr,macro_x[MACRO_SERVICEOUTPUT]);
asprintf(&temp_buffer,"SERVICE NOTIFICATION: %s;%s;%s;DOWNTIMESTART ($SERVICESTATE$);%s;$SERVICEOUTPUT$\n",cntct->name,svc->host_name,svc->description,command_name_ptr);
break;
case NOTIFICATION_DOWNTIMEEND:
asprintf(&temp_buffer,"SERVICE NOTIFICATION: %s;%s;%s;DOWNTIMEEND (%s);%s;%s\n",cntct->name,svc->host_name,svc->description,macro_x[MACRO_SERVICESTATE],command_name_ptr,macro_x[MACRO_SERVICEOUTPUT]);
asprintf(&temp_buffer,"SERVICE NOTIFICATION: %s;%s;%s;DOWNTIMEEND ($SERVICESTATE$);%s;$SERVICEOUTPUT$\n",cntct->name,svc->host_name,svc->description,command_name_ptr);
break;
case NOTIFICATION_DOWNTIMECANCELLED:
asprintf(&temp_buffer,"SERVICE NOTIFICATION: %s;%s;%s;DOWNTIMECANCELLED (%s);%s;%s\n",cntct->name,svc->host_name,svc->description,macro_x[MACRO_SERVICESTATE],command_name_ptr,macro_x[MACRO_SERVICEOUTPUT]);
asprintf(&temp_buffer,"SERVICE NOTIFICATION: %s;%s;%s;DOWNTIMECANCELLED ($SERVICESTATE$);%s;$SERVICEOUTPUT$\n",cntct->name,svc->host_name,svc->description,command_name_ptr);
break;
default:
asprintf(&temp_buffer,"SERVICE NOTIFICATION: %s;%s;%s;%s;%s;%s\n",cntct->name,svc->host_name,svc->description,macro_x[MACRO_SERVICESTATE],command_name_ptr,macro_x[MACRO_SERVICEOUTPUT]);
asprintf(&temp_buffer,"SERVICE NOTIFICATION: %s;%s;%s;$SERVICESTATE$;%s;$SERVICEOUTPUT$\n",cntct->name,svc->host_name,svc->description,command_name_ptr);
break;
}
write_to_all_logs(temp_buffer,NSLOG_SERVICE_NOTIFICATION);

process_macros(temp_buffer,&processed_buffer,0);
write_to_all_logs(processed_buffer,NSLOG_SERVICE_NOTIFICATION);

my_free(temp_buffer);
my_free(processed_buffer);

/* run the command */
my_system(processed_command,notification_timeout,&early_timeout,&exectime,NULL,0);
Expand Down Expand Up @@ -1482,6 +1487,7 @@ int notify_contact_of_host(contact *cntct, host *hst, int type, char *not_author
char *command_name=NULL;
char *command_name_ptr=NULL;
char *temp_buffer=NULL;
char *processed_buffer=NULL;
char *raw_command=NULL;
char *processed_command=NULL;
int early_timeout=FALSE;
Expand Down Expand Up @@ -1549,35 +1555,39 @@ int notify_contact_of_host(contact *cntct, host *hst, int type, char *not_author
if(log_notifications==TRUE){
switch(type){
case NOTIFICATION_CUSTOM:
asprintf(&temp_buffer,"HOST NOTIFICATION: %s;%s;CUSTOM (%s);%s;%s;%s;%s\n",cntct->name,hst->name,macro_x[MACRO_HOSTSTATE],command_name_ptr,macro_x[MACRO_HOSTOUTPUT],macro_x[MACRO_NOTIFICATIONAUTHOR],macro_x[MACRO_NOTIFICATIONCOMMENT]);
asprintf(&temp_buffer,"HOST NOTIFICATION: %s;%s;CUSTOM ($HOSTSTATE$);%s;$HOSTOUTPUT$;$NOTIFICATIONAUTHOR$;$NOTIFICATIONCOMMENT$\n",cntct->name,hst->name,command_name_ptr);
break;
case NOTIFICATION_ACKNOWLEDGEMENT:
asprintf(&temp_buffer,"HOST NOTIFICATION: %s;%s;ACKNOWLEDGEMENT (%s);%s;%s;%s;%s\n",cntct->name,hst->name,macro_x[MACRO_HOSTSTATE],command_name_ptr,macro_x[MACRO_HOSTOUTPUT],macro_x[MACRO_NOTIFICATIONAUTHOR],macro_x[MACRO_NOTIFICATIONCOMMENT]);
asprintf(&temp_buffer,"HOST NOTIFICATION: %s;%s;ACKNOWLEDGEMENT ($HOSTSTATE$);%s;$HOSTOUTPUT$;$NOTIFICATIONAUTHOR$;$NOTIFICATIONCOMMENT$\n",cntct->name,hst->name,command_name_ptr);
break;
case NOTIFICATION_FLAPPINGSTART:
asprintf(&temp_buffer,"HOST NOTIFICATION: %s;%s;FLAPPINGSTART (%s);%s;%s\n",cntct->name,hst->name,macro_x[MACRO_HOSTSTATE],command_name_ptr,macro_x[MACRO_HOSTOUTPUT]);
asprintf(&temp_buffer,"HOST NOTIFICATION: %s;%s;FLAPPINGSTART ($HOSTSTATE$);%s;$HOSTOUTPUT$\n",cntct->name,hst->name,command_name_ptr);
break;
case NOTIFICATION_FLAPPINGSTOP:
asprintf(&temp_buffer,"HOST NOTIFICATION: %s;%s;FLAPPINGSTOP (%s);%s;%s\n",cntct->name,hst->name,macro_x[MACRO_HOSTSTATE],command_name_ptr,macro_x[MACRO_HOSTOUTPUT]);
asprintf(&temp_buffer,"HOST NOTIFICATION: %s;%s;FLAPPINGSTOP ($HOSTSTATE$);%s;$HOSTOUTPUT$\n",cntct->name,hst->name,command_name_ptr);
break;
case NOTIFICATION_FLAPPINGDISABLED:
asprintf(&temp_buffer,"HOST NOTIFICATION: %s;%s;FLAPPINGDISABLED (%s);%s;%s\n",cntct->name,hst->name,macro_x[MACRO_HOSTSTATE],command_name_ptr,macro_x[MACRO_HOSTOUTPUT]);
asprintf(&temp_buffer,"HOST NOTIFICATION: %s;%s;FLAPPINGDISABLED ($HOSTSTATE$);%s;$HOSTOUTPUT$\n",cntct->name,hst->name,command_name_ptr);
break;
case NOTIFICATION_DOWNTIMESTART:
asprintf(&temp_buffer,"HOST NOTIFICATION: %s;%s;DOWNTIMESTART (%s);%s;%s\n",cntct->name,hst->name,macro_x[MACRO_HOSTSTATE],command_name_ptr,macro_x[MACRO_HOSTOUTPUT]);
asprintf(&temp_buffer,"HOST NOTIFICATION: %s;%s;DOWNTIMESTART ($HOSTSTATE$);%s;$HOSTOUTPUT$\n",cntct->name,hst->name,command_name_ptr);
break;
case NOTIFICATION_DOWNTIMEEND:
asprintf(&temp_buffer,"HOST NOTIFICATION: %s;%s;DOWNTIMEEND (%s);%s;%s\n",cntct->name,hst->name,macro_x[MACRO_HOSTSTATE],command_name_ptr,macro_x[MACRO_HOSTOUTPUT]);
asprintf(&temp_buffer,"HOST NOTIFICATION: %s;%s;DOWNTIMEEND ($HOSTSTATE$);%s;$HOSTOUTPUT$\n",cntct->name,hst->name,command_name_ptr);
break;
case NOTIFICATION_DOWNTIMECANCELLED:
asprintf(&temp_buffer,"HOST NOTIFICATION: %s;%s;DOWNTIMECANCELLED (%s);%s;%s\n",cntct->name,hst->name,macro_x[MACRO_HOSTSTATE],command_name_ptr,macro_x[MACRO_HOSTOUTPUT]);
asprintf(&temp_buffer,"HOST NOTIFICATION: %s;%s;DOWNTIMECANCELLED ($HOSTSTATE$);%s;$HOSTOUTPUT$\n",cntct->name,hst->name,command_name_ptr);
break;
default:
asprintf(&temp_buffer,"HOST NOTIFICATION: %s;%s;%s;%s;%s\n",cntct->name,hst->name,macro_x[MACRO_HOSTSTATE],command_name_ptr,macro_x[MACRO_HOSTOUTPUT]);
asprintf(&temp_buffer,"HOST NOTIFICATION: %s;%s;$HOSTSTATE$;%s;$HOSTOUTPUT$\n",cntct->name,hst->name,command_name_ptr);
break;
}
write_to_all_logs(temp_buffer,NSLOG_HOST_NOTIFICATION);

process_macros(temp_buffer,&processed_buffer,0);
write_to_all_logs(processed_buffer,NSLOG_HOST_NOTIFICATION);

my_free(temp_buffer);
my_free(processed_buffer);

/* run the command */
my_system(processed_command,notification_timeout,&early_timeout,&exectime,NULL,0);
Expand Down
4 changes: 2 additions & 2 deletions cgi/cgiutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* CGIUTILS.C - Common utilities for Nagios CGIs
*
* Copyright (c) 1999-2007 Ethan Galstad ([email protected])
* Last Modified: 10-18-2007
* Last Modified: 10-31-2007
*
* License:
*
Expand Down Expand Up @@ -1427,7 +1427,7 @@ char * url_encode(char *input){
char * html_encode(char *input, int escape_newlines){
int len,output_len;
int x,y;
char temp_expansion[7];
char temp_expansion[10];

/* we need up to six times the space to do the conversion */
len=(int)strlen(input);
Expand Down
4 changes: 2 additions & 2 deletions nagios.spec
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ cp sample-config/httpd.conf ${RPM_BUILD_ROOT}/etc/httpd/conf.d/nagios.conf

# install CGIs
cd contrib
make INSTALL=install DESTDIR=${RPM_BUILD_ROOT} INSTALL_OPTS="" COMMAND_OPTS="" CGIDIR=%{_libdir}/nagios/cgi install
make INSTALL=install DESTDIR=${RPM_BUILD_ROOT} INSTALL_OPTS="" COMMAND_OPTS="" CGIDIR=%{_prefix}/lib/nagios/cgi install
#mv ${RPM_BUILD_ROOT}%{_prefix}/lib/nagios/cgi/convertcfg ${RPM_BUILD_ROOT}%{_prefix}/lib/nagios/
#mv ${RPM_BUILD_ROOT}%{_prefix}/lib/nagios/cgi/mini_epn ${RPM_BUILD_ROOT}%{_prefix}/sbin/
cd ..
Expand Down Expand Up @@ -321,7 +321,7 @@ rm -rf $RPM_BUILD_ROOT
%files www
%defattr(755,root,root)
%dir %{_prefix}/lib/nagios/cgi
%{_libdir}/nagios/cgi/*
%{_prefix}/lib/nagios/cgi/*
%dir %{_prefix}/share/nagios
%defattr(-,root,root)
%{_prefix}/share/nagios/*
Expand Down

0 comments on commit 42ee00d

Please sign in to comment.