[icinga-checkins] icinga.org: icinga-core/test/cgis: core: avoid sending notifications to the wrong contact (Andreas Ericsson) #1654

git at icinga.org git at icinga.org
Tue Jul 5 21:38:12 CEST 2011


Module: icinga-core
Branch: test/cgis
Commit: f88cf48af246ff32120d0ac634a7da230bda8cde
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=f88cf48af246ff32120d0ac634a7da230bda8cde

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Thu Jun 16 17:42:10 2011 +0200

core: avoid sending notifications to the wrong contact (Andreas Ericsson) #1654

if a neb module blocks notifications due to recent changes
on the source, the notification_list wasn't cleared, causing
the next notification to hit all contacts for the blocked
notification as well as to all contacts for the current
notification.

clearing it on the neb module returns, and also prior to
filling it, as an empty NULLed least is not affecting
performance.

refs #1654

---

 Changelog            |    1 +
 base/notifications.c |   22 ++++++++++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/Changelog b/Changelog
index fd3e08f..2e30828 100644
--- a/Changelog
+++ b/Changelog
@@ -21,6 +21,7 @@ FIXES
 * core: make command_check_interval=-1 equal to 5s instead of 60s, targetting as often as possible (Andreas Ericsson) #1651
 * core: fix problem where acknowledgements were getting reset when a hard state change occurred (Ton Voon) #1618
 * core: avoid using global macros when sending notifications (Andreas Ericsson) #1653
+* core: avoid sending notifications to the wrong contact (Andreas Ericsson) #1654
 
 * classic ui: fix cross site scripting vulnerability in config.cgi on config expander arguments #1605
 * classic ui: remove sidebar.html inclusion in index.html causing troubles on reload #1632
diff --git a/base/notifications.c b/base/notifications.c
index 87a26c7..57ea817 100644
--- a/base/notifications.c
+++ b/base/notifications.c
@@ -138,10 +138,14 @@ int service_notification(service *svc, int type, char *not_author, char *not_dat
 	end_time.tv_sec=0L;
 	end_time.tv_usec=0L;
 	neb_result=broker_notification_data(NEBTYPE_NOTIFICATION_START,NEBFLAG_NONE,NEBATTR_NONE,SERVICE_NOTIFICATION,type,start_time,end_time,(void *)svc,not_author,not_data,escalated,0,NULL);
-	if(NEBERROR_CALLBACKCANCEL==neb_result)
+	if(NEBERROR_CALLBACKCANCEL==neb_result){
+		free_notification_list();
 		return ERROR;
-	else if(NEBERROR_CALLBACKOVERRIDE==neb_result)
+	}
+	else if(NEBERROR_CALLBACKOVERRIDE==neb_result){
+		free_notification_list();
 		return OK;
+	}
 #endif
 
 	/* XXX: crazy indent */
@@ -1115,6 +1119,9 @@ int create_notification_list_from_service(icinga_macros *mac, service *svc, int
 	/* set the escalation flag */
 	*escalated=escalate_notification;
 
+	/* make sure there aren't any leftover contacts */
+	free_notification_list();
+
 	/* set the escalation macro */
 	my_free(mac->x[MACRO_NOTIFICATIONISESCALATED]);
 	dummy=asprintf(&mac->x[MACRO_NOTIFICATIONISESCALATED],"%d",escalate_notification);
@@ -1260,10 +1267,14 @@ int host_notification(host *hst, int type, char *not_author, char *not_data, int
 	end_time.tv_sec=0L;
 	end_time.tv_usec=0L;
 	neb_result=broker_notification_data(NEBTYPE_NOTIFICATION_START,NEBFLAG_NONE,NEBATTR_NONE,HOST_NOTIFICATION,type,start_time,end_time,(void *)hst,not_author,not_data,escalated,0,NULL);
-	if(NEBERROR_CALLBACKCANCEL==neb_result)
+	if(NEBERROR_CALLBACKCANCEL==neb_result){
+		free_notification_list();
 		return ERROR;
-	else if(NEBERROR_CALLBACKOVERRIDE==neb_result)
+	}
+	else if(NEBERROR_CALLBACKOVERRIDE==neb_result){
+		free_notification_list();
 		return OK;
+	}
 #endif
 
 	/* XXX: crazy indent */
@@ -2090,6 +2101,9 @@ int create_notification_list_from_host(icinga_macros *mac, host *hst, int option
 	/* set the escalation flag */
 	*escalated=escalate_notification;
 
+	/* make sure there aren't any leftover contacts */
+	free_notification_list();
+
 	/* set the escalation macro */
 	my_free(mac->x[MACRO_NOTIFICATIONISESCALATED]);
 	dummy=asprintf(&mac->x[MACRO_NOTIFICATIONISESCALATED],"%d",escalate_notification);





More information about the icinga-checkins mailing list