diff options
Diffstat (limited to 'plugins/check_smtp.c')
-rw-r--r-- | plugins/check_smtp.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index 56040ff..587a724 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c | |||
@@ -59,10 +59,6 @@ enum { | |||
59 | #define SMTP_STARTTLS "STARTTLS\r\n" | 59 | #define SMTP_STARTTLS "STARTTLS\r\n" |
60 | #define SMTP_AUTH_LOGIN "AUTH LOGIN\r\n" | 60 | #define SMTP_AUTH_LOGIN "AUTH LOGIN\r\n" |
61 | 61 | ||
62 | #ifndef HOST_MAX_BYTES | ||
63 | #define HOST_MAX_BYTES 255 | ||
64 | #endif | ||
65 | |||
66 | #define EHLO_SUPPORTS_STARTTLS 1 | 62 | #define EHLO_SUPPORTS_STARTTLS 1 |
67 | 63 | ||
68 | int process_arguments (int, char **); | 64 | int process_arguments (int, char **); |
@@ -231,7 +227,7 @@ main (int argc, char **argv) | |||
231 | send(sd, SMTP_STARTTLS, strlen(SMTP_STARTTLS), 0); | 227 | send(sd, SMTP_STARTTLS, strlen(SMTP_STARTTLS), 0); |
232 | 228 | ||
233 | recvlines(buffer, MAX_INPUT_BUFFER); /* wait for it */ | 229 | recvlines(buffer, MAX_INPUT_BUFFER); /* wait for it */ |
234 | if (!strstr (buffer, server_expect)) { | 230 | if (!strstr (buffer, SMTP_EXPECT)) { |
235 | printf (_("Server does not support STARTTLS\n")); | 231 | printf (_("Server does not support STARTTLS\n")); |
236 | smtp_quit(); | 232 | smtp_quit(); |
237 | return STATE_UNKNOWN; | 233 | return STATE_UNKNOWN; |
@@ -239,8 +235,8 @@ main (int argc, char **argv) | |||
239 | result = np_net_ssl_init(sd); | 235 | result = np_net_ssl_init(sd); |
240 | if(result != STATE_OK) { | 236 | if(result != STATE_OK) { |
241 | printf (_("CRITICAL - Cannot create SSL context.\n")); | 237 | printf (_("CRITICAL - Cannot create SSL context.\n")); |
242 | np_net_ssl_cleanup(); | ||
243 | close(sd); | 238 | close(sd); |
239 | np_net_ssl_cleanup(); | ||
244 | return STATE_CRITICAL; | 240 | return STATE_CRITICAL; |
245 | } else { | 241 | } else { |
246 | ssl_established = 1; | 242 | ssl_established = 1; |
@@ -276,6 +272,7 @@ main (int argc, char **argv) | |||
276 | # ifdef USE_OPENSSL | 272 | # ifdef USE_OPENSSL |
277 | if ( check_cert ) { | 273 | if ( check_cert ) { |
278 | result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit); | 274 | result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit); |
275 | smtp_quit(); | ||
279 | my_close(); | 276 | my_close(); |
280 | return result; | 277 | return result; |
281 | } | 278 | } |
@@ -581,11 +578,6 @@ process_arguments (int argc, char **argv) | |||
581 | usage4 (_("Timeout interval must be a positive integer")); | 578 | usage4 (_("Timeout interval must be a positive integer")); |
582 | } | 579 | } |
583 | break; | 580 | break; |
584 | case 'S': | ||
585 | /* starttls */ | ||
586 | use_ssl = TRUE; | ||
587 | use_ehlo = TRUE; | ||
588 | break; | ||
589 | case 'D': | 581 | case 'D': |
590 | /* Check SSL cert validity */ | 582 | /* Check SSL cert validity */ |
591 | #ifdef USE_OPENSSL | 583 | #ifdef USE_OPENSSL |
@@ -607,9 +599,14 @@ process_arguments (int argc, char **argv) | |||
607 | days_till_exp_warn = atoi (optarg); | 599 | days_till_exp_warn = atoi (optarg); |
608 | } | 600 | } |
609 | check_cert = TRUE; | 601 | check_cert = TRUE; |
602 | ignore_send_quit_failure = TRUE; | ||
610 | #else | 603 | #else |
611 | usage (_("SSL support not available - install OpenSSL and recompile")); | 604 | usage (_("SSL support not available - install OpenSSL and recompile")); |
612 | #endif | 605 | #endif |
606 | case 'S': | ||
607 | /* starttls */ | ||
608 | use_ssl = TRUE; | ||
609 | use_ehlo = TRUE; | ||
613 | break; | 610 | break; |
614 | case '4': | 611 | case '4': |
615 | address_family = AF_INET; | 612 | address_family = AF_INET; |
@@ -763,10 +760,12 @@ recvlines(char *buf, size_t bufsize) | |||
763 | int | 760 | int |
764 | my_close (void) | 761 | my_close (void) |
765 | { | 762 | { |
763 | int result; | ||
764 | result = close(sd); | ||
766 | #ifdef HAVE_SSL | 765 | #ifdef HAVE_SSL |
767 | np_net_ssl_cleanup(); | 766 | np_net_ssl_cleanup(); |
768 | #endif | 767 | #endif |
769 | return close(sd); | 768 | return result; |
770 | } | 769 | } |
771 | 770 | ||
772 | 771 | ||