summaryrefslogtreecommitdiffstats
path: root/plugins/netutils.c
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2004-03-01 12:27:19 +0000
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2004-03-01 12:27:19 +0000
commit3c81964713e4114d7f40f95e9373c24b596d1efd (patch)
tree4c735cf76d5b94e246d60afb79969476379d9919 /plugins/netutils.c
parentf7c1eca1c45f77df548e426281569e0c7c0a6480 (diff)
downloadmonitoring-plugins-3c81964713e4114d7f40f95e9373c24b596d1efd.tar.gz
check_tcp was returning uninitialized string with user-defined refused outcome
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@833 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/netutils.c')
-rw-r--r--plugins/netutils.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/plugins/netutils.c b/plugins/netutils.c
index 5017eb9e..1fa69a35 100644
--- a/plugins/netutils.c
+++ b/plugins/netutils.c
@@ -252,11 +252,7 @@ my_connect (const char *host_name, int port, int *sd, int proto)
252 if (result < 0) { 252 if (result < 0) {
253 switch (errno) { 253 switch (errno) {
254 case ECONNREFUSED: 254 case ECONNREFUSED:
255 switch (econn_refuse_state) { 255 was_refused = TRUE;
256 case STATE_OK:
257 case STATE_WARNING:
258 was_refused = TRUE;
259 }
260 break; 256 break;
261 } 257 }
262 } 258 }
@@ -269,8 +265,21 @@ my_connect (const char *host_name, int port, int *sd, int proto)
269 265
270 if (result == 0) 266 if (result == 0)
271 return STATE_OK; 267 return STATE_OK;
272 else if (was_refused) 268 else if (was_refused) {
273 return econn_refuse_state; 269 switch (econn_refuse_state) { /* a user-defined expected outcome */
270 case STATE_OK:
271 case STATE_WARNING: /* user wants WARN or OK on refusal */
272 return econn_refuse_state;
273 break;
274 case STATE_CRITICAL: /* user did not set econn_refuse_state */
275 printf ("%s\n", strerror(errno));
276 return econn_refuse_state;
277 break;
278 default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */
279 return STATE_UNKNOWN;
280 break;
281 }
282 }
274 else { 283 else {
275 printf ("%s\n", strerror(errno)); 284 printf ("%s\n", strerror(errno));
276 return STATE_CRITICAL; 285 return STATE_CRITICAL;