diff options
Diffstat (limited to 'plugins/check_smtp.c')
-rw-r--r-- | plugins/check_smtp.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index 6e0e22ed..c1e92dff 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; | |||
102 | int verbose = 0; | 103 | int verbose = 0; |
103 | int use_ssl = FALSE; | 104 | int use_ssl = FALSE; |
104 | short use_ehlo = FALSE; | 105 | short use_ehlo = FALSE; |
106 | short use_lhlo = FALSE; | ||
105 | short ssl_established = 0; | 107 | short ssl_established = 0; |
106 | char *localhostname = NULL; | 108 | char *localhostname = NULL; |
107 | int sd; | 109 | int 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; |
@@ -293,6 +297,7 @@ main (int argc, char **argv) | |||
293 | printf("%s", buffer); | 297 | printf("%s", buffer); |
294 | } | 298 | } |
295 | 299 | ||
300 | n = 0; | ||
296 | while (n < ncommands) { | 301 | while (n < ncommands) { |
297 | xasprintf (&cmd_str, "%s%s", commands[n], "\r\n"); | 302 | xasprintf (&cmd_str, "%s%s", commands[n], "\r\n"); |
298 | my_send(cmd_str, strlen(cmd_str)); | 303 | my_send(cmd_str, strlen(cmd_str)); |
@@ -469,6 +474,7 @@ process_arguments (int argc, char **argv) | |||
469 | {"use-ipv4", no_argument, 0, '4'}, | 474 | {"use-ipv4", no_argument, 0, '4'}, |
470 | {"use-ipv6", no_argument, 0, '6'}, | 475 | {"use-ipv6", no_argument, 0, '6'}, |
471 | {"help", no_argument, 0, 'h'}, | 476 | {"help", no_argument, 0, 'h'}, |
477 | {"lmtp", no_argument, 0, 'L'}, | ||
472 | {"starttls",no_argument,0,'S'}, | 478 | {"starttls",no_argument,0,'S'}, |
473 | {"certificate",required_argument,0,'D'}, | 479 | {"certificate",required_argument,0,'D'}, |
474 | {"ignore-quit-failure",no_argument,0,'q'}, | 480 | {"ignore-quit-failure",no_argument,0,'q'}, |
@@ -488,7 +494,7 @@ process_arguments (int argc, char **argv) | |||
488 | } | 494 | } |
489 | 495 | ||
490 | while (1) { | 496 | while (1) { |
491 | 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", |
492 | longopts, &option); | 498 | longopts, &option); |
493 | 499 | ||
494 | if (c == -1 || c == EOF) | 500 | if (c == -1 || c == EOF) |
@@ -615,6 +621,9 @@ process_arguments (int argc, char **argv) | |||
615 | use_ssl = TRUE; | 621 | use_ssl = TRUE; |
616 | use_ehlo = TRUE; | 622 | use_ehlo = TRUE; |
617 | break; | 623 | break; |
624 | case 'L': | ||
625 | use_lhlo = TRUE; | ||
626 | break; | ||
618 | case '4': | 627 | case '4': |
619 | address_family = AF_INET; | 628 | address_family = AF_INET; |
620 | break; | 629 | break; |
@@ -823,6 +832,8 @@ print_help (void) | |||
823 | printf (" %s\n", _("SMTP AUTH username")); | 832 | printf (" %s\n", _("SMTP AUTH username")); |
824 | printf (" %s\n", "-P, --authpass=STRING"); | 833 | printf (" %s\n", "-P, --authpass=STRING"); |
825 | 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")); | ||
826 | printf (" %s\n", "-q, --ignore-quit-failure"); | 837 | printf (" %s\n", "-q, --ignore-quit-failure"); |
827 | printf (" %s\n", _("Ignore failure when sending QUIT command to server")); | 838 | printf (" %s\n", _("Ignore failure when sending QUIT command to server")); |
828 | 839 | ||
@@ -835,7 +846,7 @@ print_help (void) | |||
835 | printf("\n"); | 846 | printf("\n"); |
836 | printf ("%s\n", _("Successul connects return STATE_OK, refusals and timeouts return")); | 847 | printf ("%s\n", _("Successul connects return STATE_OK, refusals and timeouts return")); |
837 | printf ("%s\n", _("STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful")); | 848 | printf ("%s\n", _("STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful")); |
838 | printf ("%s\n", _("connects, but incorrect reponse messages from the host result in")); | 849 | printf ("%s\n", _("connects, but incorrect response messages from the host result in")); |
839 | printf ("%s\n", _("STATE_WARNING return values.")); | 850 | printf ("%s\n", _("STATE_WARNING return values.")); |
840 | 851 | ||
841 | printf (UT_SUPPORT); | 852 | printf (UT_SUPPORT); |
@@ -849,6 +860,6 @@ print_usage (void) | |||
849 | printf ("%s\n", _("Usage:")); | 860 | printf ("%s\n", _("Usage:")); |
850 | 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); |
851 | 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"); |
852 | 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"); |
853 | } | 864 | } |
854 | 865 | ||