summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorGeert Hendrickx <geert@hendrickx.be>2021-10-28 21:08:02 (GMT)
committerGeert Hendrickx <geert@hendrickx.be>2021-10-28 21:08:02 (GMT)
commit0bd45c200b64de1918ad4546e09083c529ea39a3 (patch)
tree1b613e2cc02072436dde6667c16c9a77b1ce5ec1 /plugins
parent7415eb2f065911b138e167e35d0f67cddb5718ef (diff)
downloadmonitoring-plugins-0bd45c200b64de1918ad4546e09083c529ea39a3.tar.gz
check_smtp: add -L flag to support LMTP (LHLO instead of HELO/EHLO).refs/pull/1715/head
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_smtp.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index d37c57c..c1e92df 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -55,6 +55,7 @@ enum {
55#define SMTP_EXPECT "220" 55#define SMTP_EXPECT "220"
56#define SMTP_HELO "HELO " 56#define SMTP_HELO "HELO "
57#define SMTP_EHLO "EHLO " 57#define SMTP_EHLO "EHLO "
58#define SMTP_LHLO "LHLO "
58#define SMTP_QUIT "QUIT\r\n" 59#define SMTP_QUIT "QUIT\r\n"
59#define SMTP_STARTTLS "STARTTLS\r\n" 60#define SMTP_STARTTLS "STARTTLS\r\n"
60#define SMTP_AUTH_LOGIN "AUTH LOGIN\r\n" 61#define SMTP_AUTH_LOGIN "AUTH LOGIN\r\n"
@@ -102,6 +103,7 @@ int check_critical_time = FALSE;
102int verbose = 0; 103int verbose = 0;
103int use_ssl = FALSE; 104int use_ssl = FALSE;
104short use_ehlo = FALSE; 105short use_ehlo = FALSE;
106short use_lhlo = FALSE;
105short ssl_established = 0; 107short ssl_established = 0;
106char *localhostname = NULL; 108char *localhostname = NULL;
107int sd; 109int sd;
@@ -152,7 +154,9 @@ main (int argc, char **argv)
152 return STATE_CRITICAL; 154 return STATE_CRITICAL;
153 } 155 }
154 } 156 }
155 if(use_ehlo) 157 if(use_lhlo)
158 xasprintf (&helocmd, "%s%s%s", SMTP_LHLO, localhostname, "\r\n");
159 else if(use_ehlo)
156 xasprintf (&helocmd, "%s%s%s", SMTP_EHLO, localhostname, "\r\n"); 160 xasprintf (&helocmd, "%s%s%s", SMTP_EHLO, localhostname, "\r\n");
157 else 161 else
158 xasprintf (&helocmd, "%s%s%s", SMTP_HELO, localhostname, "\r\n"); 162 xasprintf (&helocmd, "%s%s%s", SMTP_HELO, localhostname, "\r\n");
@@ -197,7 +201,7 @@ main (int argc, char **argv)
197 if (recvlines(buffer, MAX_INPUT_BUFFER) <= 0) { 201 if (recvlines(buffer, MAX_INPUT_BUFFER) <= 0) {
198 printf (_("recv() failed\n")); 202 printf (_("recv() failed\n"));
199 return STATE_WARNING; 203 return STATE_WARNING;
200 } else if(use_ehlo){ 204 } else if(use_ehlo || use_lhlo){
201 if(strstr(buffer, "250 STARTTLS") != NULL || 205 if(strstr(buffer, "250 STARTTLS") != NULL ||
202 strstr(buffer, "250-STARTTLS") != NULL){ 206 strstr(buffer, "250-STARTTLS") != NULL){
203 supports_tls=TRUE; 207 supports_tls=TRUE;
@@ -470,6 +474,7 @@ process_arguments (int argc, char **argv)
470 {"use-ipv4", no_argument, 0, '4'}, 474 {"use-ipv4", no_argument, 0, '4'},
471 {"use-ipv6", no_argument, 0, '6'}, 475 {"use-ipv6", no_argument, 0, '6'},
472 {"help", no_argument, 0, 'h'}, 476 {"help", no_argument, 0, 'h'},
477 {"lmtp", no_argument, 0, 'L'},
473 {"starttls",no_argument,0,'S'}, 478 {"starttls",no_argument,0,'S'},
474 {"certificate",required_argument,0,'D'}, 479 {"certificate",required_argument,0,'D'},
475 {"ignore-quit-failure",no_argument,0,'q'}, 480 {"ignore-quit-failure",no_argument,0,'q'},
@@ -489,7 +494,7 @@ process_arguments (int argc, char **argv)
489 } 494 }
490 495
491 while (1) { 496 while (1) {
492 c = getopt_long (argc, argv, "+hVv46t:p:f:e:c:w:H:C:R:SD:F:A:U:P:q", 497 c = getopt_long (argc, argv, "+hVv46Lt:p:f:e:c:w:H:C:R:SD:F:A:U:P:q",
493 longopts, &option); 498 longopts, &option);
494 499
495 if (c == -1 || c == EOF) 500 if (c == -1 || c == EOF)
@@ -616,6 +621,9 @@ process_arguments (int argc, char **argv)
616 use_ssl = TRUE; 621 use_ssl = TRUE;
617 use_ehlo = TRUE; 622 use_ehlo = TRUE;
618 break; 623 break;
624 case 'L':
625 use_lhlo = TRUE;
626 break;
619 case '4': 627 case '4':
620 address_family = AF_INET; 628 address_family = AF_INET;
621 break; 629 break;
@@ -824,6 +832,8 @@ print_help (void)
824 printf (" %s\n", _("SMTP AUTH username")); 832 printf (" %s\n", _("SMTP AUTH username"));
825 printf (" %s\n", "-P, --authpass=STRING"); 833 printf (" %s\n", "-P, --authpass=STRING");
826 printf (" %s\n", _("SMTP AUTH password")); 834 printf (" %s\n", _("SMTP AUTH password"));
835 printf (" %s\n", "-L, --lmtp");
836 printf (" %s\n", _("Send LHLO instead of HELO/EHLO"));
827 printf (" %s\n", "-q, --ignore-quit-failure"); 837 printf (" %s\n", "-q, --ignore-quit-failure");
828 printf (" %s\n", _("Ignore failure when sending QUIT command to server")); 838 printf (" %s\n", _("Ignore failure when sending QUIT command to server"));
829 839
@@ -850,6 +860,6 @@ print_usage (void)
850 printf ("%s\n", _("Usage:")); 860 printf ("%s\n", _("Usage:"));
851 printf ("%s -H host [-p port] [-4|-6] [-e expect] [-C command] [-R response] [-f from addr]\n", progname); 861 printf ("%s -H host [-p port] [-4|-6] [-e expect] [-C command] [-R response] [-f from addr]\n", progname);
852 printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout] [-q]\n"); 862 printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout] [-q]\n");
853 printf ("[-F fqdn] [-S] [-D warn days cert expire[,crit days cert expire]] [-v] \n"); 863 printf ("[-F fqdn] [-S] [-L] [-D warn days cert expire[,crit days cert expire]] [-v] \n");
854} 864}
855 865