summaryrefslogtreecommitdiff
path: root/net-analyzer/nagios-core/files/nagios-4.4.2-pre.patch
blob: 6483b9df9f29097ccc4607998d25e0135829e95a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
diff --git a/Changelog b/Changelog
index 1e1bd9e2..8dd26fec 100644
--- a/Changelog
+++ b/Changelog
@@ -2,6 +2,18 @@
 Nagios Core 4 Change Log
 ########################
 
+4.4.2 - ??????????
+------------------
+FIXES
+* Fix comment data being duplicated after a `service nagios reload` or similar (Bryan Heden)
+* Fix check_interval and retry_interval not changing at the appropriate times (Scott Wilkerson)
+* Fixed passive checks sending recovery email when host was previously UP (Scott Wilkerson)
+* Fixed flapping comments duplication on nagios reload (Christian Jung)
+* Fix for CVE-2018-13441, CVE-2018-13458, CVE-2018-13457 null pointer dereference (Trevor McDonald)
+* Fixed syntax error in file: default-init.in (#558) (Christian Zettel)
+* Reset current notification number and state flags when the host recovers, reset all service variables when they recover fixes (#557) (Scott Wilkerson)
+* Fixed wrong counting of service status totals when showing servicegroup details (#548) (Christian Zettel, Bryan Heden)
+
 4.4.1 - 2018-06-25
 ------------------
 FIXES
diff --git a/base/checks.c b/base/checks.c
index 725dec9d..d45b6ac4 100644
--- a/base/checks.c
+++ b/base/checks.c
@@ -911,6 +911,11 @@ static inline void service_state_or_hard_state_type_change(service * svc, int st
 
 	if (state_or_type_change) {
 
+		/* check if service should go into downtime from flexible downtime */
+		if (svc->pending_flex_downtime > 0) {
+			check_pending_flex_service_downtime(svc);
+		}
+
 		/* reset notification times and suppression option */
 		svc->last_notification = (time_t)0;
 		svc->next_notification = (time_t)0;
@@ -941,7 +946,10 @@ static inline void host_state_or_hard_state_type_change(host * hst, int state_ch
 
 		log_debug_info(DEBUGL_CHECKS, 2, "Check type passive and passive host checks aren't false\n");
 		
-		hst->current_attempt = 1;
+		if (state_change == TRUE) {
+            hst->current_attempt = 1;
+        }
+        
 		hard_state_change = TRUE;
 	}
 
@@ -989,6 +997,9 @@ static inline void host_state_or_hard_state_type_change(host * hst, int state_ch
 
 	if (state_or_type_change) {
 
+		/* check if host should go into downtime from flexible downtime */
+		check_pending_flex_host_downtime(hst);
+
 		/* reset notification times and suppression option */
 		hst->last_notification = (time_t)0;
 		hst->next_notification = (time_t)0;
@@ -1228,7 +1239,7 @@ int handle_async_service_check_result(service *svc, check_result *cr)
 	next_check = (time_t)(svc->last_check + (svc->check_interval * interval_length));
 
 	/***********************************************/
-	/********** SCHEDULE HOST CHECK LOGIC **********/
+	/********** SCHEDULE SERVICE CHECK LOGIC **********/
 	/***********************************************/
 	if (svc->current_state == STATE_OK) {
 
@@ -1269,6 +1280,7 @@ int handle_async_service_check_result(service *svc, check_result *cr)
 
 			svc->host_problem_at_last_check = TRUE;
 		}
+        
 	}
 	else {
 
@@ -1368,6 +1380,9 @@ int handle_async_service_check_result(service *svc, check_result *cr)
 		else {
 
 			log_debug_info(DEBUGL_CHECKS, 1, "Service is a non-OK state (%s)!", service_state_name(svc->current_state));
+            
+            svc->state_type = SOFT_STATE;
+			svc->current_attempt = 1;
 
 			handle_event = TRUE;
 		}
@@ -1395,6 +1410,21 @@ int handle_async_service_check_result(service *svc, check_result *cr)
 
 				log_debug_info(DEBUGL_CHECKS, 1, "Service experienced a SOFT recovery.\n");				
 			}
+            
+            
+            /* reset all service variables because its okay now... */
+            svc->host_problem_at_last_check = FALSE;
+            svc->current_attempt = 1;
+            svc->state_type = HARD_STATE;
+            svc->last_hard_state = STATE_OK;
+            svc->last_notification = (time_t)0;
+            svc->next_notification = (time_t)0;
+            svc->current_notification_number = 0;
+            svc->problem_has_been_acknowledged = FALSE;
+            svc->acknowledgement_type = ACKNOWLEDGEMENT_NONE;
+            svc->notified_on = 0;
+            
+            hard_state_change = TRUE;
 		}
 
 		/***** SERVICE IS STILL IN PROBLEM STATE *****/
@@ -1418,6 +1448,14 @@ int handle_async_service_check_result(service *svc, check_result *cr)
 			}
 		}
 	}
+    
+    /* soft states should be using retry_interval */
+    if (svc->state_type == SOFT_STATE) {
+        
+            log_debug_info(DEBUGL_CHECKS, 2, "Service state type is soft, using retry_interval\n");
+            
+            next_check = (unsigned long) (current_time + svc->retry_interval * interval_length);
+    }
 
 	/* check for a state change */
 	if (svc->current_state != svc->last_state || (svc->current_state == STATE_OK && svc->state_type == SOFT_STATE)) {
@@ -1454,6 +1492,8 @@ int handle_async_service_check_result(service *svc, check_result *cr)
 	if (svc->current_attempt >= svc->max_attempts && svc->current_state != svc->last_hard_state) {
 
 		log_debug_info(DEBUGL_CHECKS, 2, "Service had a HARD STATE CHANGE!!\n");
+        
+        next_check = (unsigned long)(current_time + (svc->check_interval * interval_length));
 
 		hard_state_change = TRUE;
 
@@ -2197,6 +2237,9 @@ int handle_async_host_check_result(host *hst, check_result *cr)
 		else {
 
 			log_debug_info(DEBUGL_CHECKS, 1, "Host is no longer UP (%s)!\n", host_state_name(hst->current_state));
+            
+            hst->state_type = SOFT_STATE;
+            hst->current_attempt = 1;
 
 			/* propagate checks to immediate parents if they are UP */
 			host_propagate_checks_to_immediate_parents(hst, FALSE, current_time);
@@ -2276,7 +2319,9 @@ int handle_async_host_check_result(host *hst, check_result *cr)
 	if (hst->current_state != HOST_UP && (hst->check_type == CHECK_TYPE_ACTIVE || translate_passive_host_checks == TRUE)) {
 
 		hst->current_state = determine_host_reachability(hst);
-		next_check = (unsigned long)(current_time + (hst->retry_interval * interval_length));
+		if (hst->state_type == SOFT_STATE)
+            next_check = (unsigned long)(current_time + (hst->retry_interval * interval_length));
+        
 	}
 
 	/* check for state change */
@@ -2310,7 +2355,9 @@ int handle_async_host_check_result(host *hst, check_result *cr)
 
 		log_debug_info(DEBUGL_CHECKS, 2, "Host had a HARD STATE CHANGE!!\n");
 
-		hard_state_change = TRUE;
+		next_check = (unsigned long)(current_time + (hst->check_interval * interval_length));
+        
+        hard_state_change = TRUE;
 		send_notification = TRUE;
 	}
 
@@ -2372,6 +2419,12 @@ int handle_async_host_check_result(host *hst, check_result *cr)
 		}
 	}
 
+    /* the host recovered, so reset the current notification number and state flags (after the recovery notification has gone out) */
+    if(hst->current_state == HOST_UP && hst->state_type == HARD_STATE && hard_state_change == TRUE) {
+        hst->current_notification_number = 0;
+        hst->notified_on = 0;
+        }
+        
 	if (obsess_over_hosts == TRUE) {
 		obsessive_compulsive_host_check_processor(hst);
 	}
diff --git a/base/nagios.c b/base/nagios.c
index 520ba71e..24719647 100644
--- a/base/nagios.c
+++ b/base/nagios.c
@@ -878,6 +878,9 @@ int main(int argc, char **argv) {
 			/* clean up the scheduled downtime data */
 			cleanup_downtime_data();
 
+			/* clean up comment data */
+			free_comment_data();
+
 			/* clean up the status data if we are not restarting */
 			if(sigrestart == FALSE) {
 				cleanup_status_data(TRUE);
diff --git a/cgi/status.c b/cgi/status.c
index 20c4ed48..8b1c8b31 100644
--- a/cgi/status.c
+++ b/cgi/status.c
@@ -873,6 +873,11 @@ void show_service_status_totals(void) {
 				count_service = 1;
 			}
 		else if(display_type == DISPLAY_SERVICEGROUPS) {
+
+			if (is_service_member_of_servicegroup(find_servicegroup(servicegroup_name), temp_service) == FALSE) {
+				continue;
+			}
+
 			if(show_all_servicegroups == TRUE) {
 				count_service = 1;
 				}