summaryrefslogtreecommitdiffstats
path: root/plugins/check_smtp.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_smtp.c')
-rw-r--r--plugins/check_smtp.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index 494bc2cd..0af50e32 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -41,7 +41,7 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
41 41
42#ifdef HAVE_SSL 42#ifdef HAVE_SSL
43int check_cert = FALSE; 43int check_cert = FALSE;
44int days_till_exp; 44int days_till_exp_warn, days_till_exp_crit;
45# define my_recv(buf, len) ((use_ssl && ssl_established) ? np_net_ssl_read(buf, len) : read(sd, buf, len)) 45# define my_recv(buf, len) ((use_ssl && ssl_established) ? np_net_ssl_read(buf, len) : read(sd, buf, len))
46# define my_send(buf, len) ((use_ssl && ssl_established) ? np_net_ssl_write(buf, len) : send(sd, buf, len, 0)) 46# define my_send(buf, len) ((use_ssl && ssl_established) ? np_net_ssl_write(buf, len) : send(sd, buf, len, 0))
47#else /* ifndef HAVE_SSL */ 47#else /* ifndef HAVE_SSL */
@@ -275,7 +275,7 @@ main (int argc, char **argv)
275 275
276# ifdef USE_OPENSSL 276# ifdef USE_OPENSSL
277 if ( check_cert ) { 277 if ( check_cert ) {
278 result = np_net_ssl_check_cert(days_till_exp); 278 result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit);
279 my_close(); 279 my_close();
280 return result; 280 return result;
281 } 281 }
@@ -454,6 +454,7 @@ int
454process_arguments (int argc, char **argv) 454process_arguments (int argc, char **argv)
455{ 455{
456 int c; 456 int c;
457 char* temp;
457 458
458 int option = 0; 459 int option = 0;
459 static struct option longopts[] = { 460 static struct option longopts[] = {
@@ -600,12 +601,26 @@ process_arguments (int argc, char **argv)
600 case 'D': 601 case 'D':
601 /* Check SSL cert validity */ 602 /* Check SSL cert validity */
602#ifdef USE_OPENSSL 603#ifdef USE_OPENSSL
603 if (!is_intnonneg (optarg)) 604 if ((temp=strchr(optarg,','))!=NULL) {
604 usage2 ("Invalid certificate expiration period",optarg); 605 *temp='\0';
605 days_till_exp = atoi (optarg); 606 if (!is_intnonneg (temp))
606 check_cert = TRUE; 607 usage2 ("Invalid certificate expiration period", optarg);
608 days_till_exp_warn = atoi(optarg);
609 *temp=',';
610 temp++;
611 if (!is_intnonneg (temp))
612 usage2 (_("Invalid certificate expiration period"), temp);
613 days_till_exp_crit = atoi (temp);
614 }
615 else {
616 days_till_exp_crit=0;
617 if (!is_intnonneg (optarg))
618 usage2 ("Invalid certificate expiration period", optarg);
619 days_till_exp_warn = atoi (optarg);
620 }
621 check_cert = TRUE;
607#else 622#else
608 usage (_("SSL support not available - install OpenSSL and recompile")); 623 usage (_("SSL support not available - install OpenSSL and recompile"));
609#endif 624#endif
610 break; 625 break;
611 case '4': 626 case '4':
@@ -802,7 +817,7 @@ print_help (void)
802 printf (" %s\n", "-F, --fqdn=STRING"); 817 printf (" %s\n", "-F, --fqdn=STRING");
803 printf (" %s\n", _("FQDN used for HELO")); 818 printf (" %s\n", _("FQDN used for HELO"));
804#ifdef HAVE_SSL 819#ifdef HAVE_SSL
805 printf (" %s\n", "-D, --certificate=INTEGER"); 820 printf (" %s\n", "-D, --certificate=INTEGER[,INTEGER]");
806 printf (" %s\n", _("Minimum number of days a certificate has to be valid.")); 821 printf (" %s\n", _("Minimum number of days a certificate has to be valid."));
807 printf (" %s\n", "-S, --starttls"); 822 printf (" %s\n", "-S, --starttls");
808 printf (" %s\n", _("Use STARTTLS for the connection.")); 823 printf (" %s\n", _("Use STARTTLS for the connection."));
@@ -838,8 +853,8 @@ void
838print_usage (void) 853print_usage (void)
839{ 854{
840 printf ("%s\n", _("Usage:")); 855 printf ("%s\n", _("Usage:"));
841 printf ("%s -H host [-p port] [-e expect] [-C command] [-f from addr]", progname); 856 printf ("%s -H host [-p port] [-4|-6] [-e expect] [-C command] [-f from addr]", progname);
842 printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout]\n"); 857 printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout] [-q]\n");
843 printf ("[-F fqdn] [-S] [-D days] [-v] [-4|-6] [-q]\n"); 858 printf ("[-F fqdn] [-S] [-D warn days cert expire[,crit days cert expire]] [-v] \n");
844} 859}
845 860