diff options
Diffstat (limited to 'plugins/check_smtp.c')
-rw-r--r-- | plugins/check_smtp.c | 102 |
1 files changed, 50 insertions, 52 deletions
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index 986c3e1..e6369e6 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * Monitoring check_smtp plugin | 3 | * Monitoring check_smtp plugin |
4 | * | 4 | * |
5 | * License: GPL | 5 | * License: GPL |
6 | * Copyright (c) 2000-2023 Monitoring Plugins Development Team | 6 | * Copyright (c) 2000-2024 Monitoring Plugins Development Team |
7 | * | 7 | * |
8 | * Description: | 8 | * Description: |
9 | * | 9 | * |
@@ -29,7 +29,7 @@ | |||
29 | *****************************************************************************/ | 29 | *****************************************************************************/ |
30 | 30 | ||
31 | const char *progname = "check_smtp"; | 31 | const char *progname = "check_smtp"; |
32 | const char *copyright = "2000-2007"; | 32 | const char *copyright = "2000-2024"; |
33 | const char *email = "devel@monitoring-plugins.org"; | 33 | const char *email = "devel@monitoring-plugins.org"; |
34 | 34 | ||
35 | #include "common.h" | 35 | #include "common.h" |
@@ -40,8 +40,8 @@ const char *email = "devel@monitoring-plugins.org"; | |||
40 | #include <ctype.h> | 40 | #include <ctype.h> |
41 | 41 | ||
42 | #ifdef HAVE_SSL | 42 | #ifdef HAVE_SSL |
43 | bool check_cert = false; | 43 | static bool check_cert = false; |
44 | int days_till_exp_warn, days_till_exp_crit; | 44 | static int days_till_exp_warn, days_till_exp_crit; |
45 | # define my_recv(buf, len) (((use_starttls || use_ssl) && ssl_established) ? np_net_ssl_read(buf, len) : read(sd, buf, len)) | 45 | # define my_recv(buf, len) (((use_starttls || use_ssl) && ssl_established) ? np_net_ssl_read(buf, len) : read(sd, buf, len)) |
46 | # define my_send(buf, len) (((use_starttls || use_ssl) && ssl_established) ? np_net_ssl_write(buf, len) : send(sd, buf, len, 0)) | 46 | # define my_send(buf, len) (((use_starttls || 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 */ |
@@ -64,61 +64,59 @@ enum { | |||
64 | 64 | ||
65 | #define EHLO_SUPPORTS_STARTTLS 1 | 65 | #define EHLO_SUPPORTS_STARTTLS 1 |
66 | 66 | ||
67 | int process_arguments (int, char **); | 67 | static int process_arguments (int, char **); |
68 | int validate_arguments (void); | 68 | static int validate_arguments (void); |
69 | void print_help (void); | 69 | static void print_help (void); |
70 | void print_usage (void); | 70 | void print_usage (void); |
71 | void smtp_quit(void); | 71 | static void smtp_quit(void); |
72 | int recvline(char *, size_t); | 72 | static int recvline(char *, size_t); |
73 | int recvlines(char *, size_t); | 73 | static int recvlines(char *, size_t); |
74 | int my_close(void); | 74 | static int my_close(void); |
75 | 75 | ||
76 | #include "regex.h" | 76 | #include "regex.h" |
77 | char regex_expect[MAX_INPUT_BUFFER] = ""; | 77 | static regex_t preg; |
78 | regex_t preg; | 78 | static regmatch_t pmatch[10]; |
79 | regmatch_t pmatch[10]; | 79 | static char errbuf[MAX_INPUT_BUFFER]; |
80 | char timestamp[20] = ""; | 80 | static int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE; |
81 | char errbuf[MAX_INPUT_BUFFER]; | 81 | static int eflags = 0; |
82 | int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE; | 82 | static int errcode, excode; |
83 | int eflags = 0; | 83 | |
84 | int errcode, excode; | 84 | static int server_port = SMTP_PORT; |
85 | 85 | static int server_port_option = 0; | |
86 | int server_port = SMTP_PORT; | 86 | static char *server_address = NULL; |
87 | int server_port_option = 0; | 87 | static char *server_expect = NULL; |
88 | char *server_address = NULL; | 88 | static char *mail_command = NULL; |
89 | char *server_expect = NULL; | 89 | static char *from_arg = NULL; |
90 | char *mail_command = NULL; | 90 | static int send_mail_from=0; |
91 | char *from_arg = NULL; | 91 | static int ncommands=0; |
92 | int send_mail_from=0; | 92 | static int command_size=0; |
93 | int ncommands=0; | 93 | static int nresponses=0; |
94 | int command_size=0; | 94 | static int response_size=0; |
95 | int nresponses=0; | 95 | static char **commands = NULL; |
96 | int response_size=0; | 96 | static char **responses = NULL; |
97 | char **commands = NULL; | 97 | static char *authtype = NULL; |
98 | char **responses = NULL; | 98 | static char *authuser = NULL; |
99 | char *authtype = NULL; | 99 | static char *authpass = NULL; |
100 | char *authuser = NULL; | 100 | static double warning_time = 0; |
101 | char *authpass = NULL; | 101 | static bool check_warning_time = false; |
102 | double warning_time = 0; | 102 | static double critical_time = 0; |
103 | bool check_warning_time = false; | 103 | static bool check_critical_time = false; |
104 | double critical_time = 0; | 104 | static int verbose = 0; |
105 | bool check_critical_time = false; | 105 | static bool use_ssl = false; |
106 | int verbose = 0; | 106 | static bool use_starttls = false; |
107 | bool use_ssl = false; | 107 | static bool use_sni = false; |
108 | bool use_starttls = false; | 108 | static bool use_proxy_prefix = false; |
109 | bool use_sni = false; | 109 | static bool use_ehlo = false; |
110 | bool use_proxy_prefix = false; | 110 | static bool use_lhlo = false; |
111 | bool use_ehlo = false; | 111 | static bool ssl_established = false; |
112 | bool use_lhlo = false; | 112 | static char *localhostname = NULL; |
113 | bool ssl_established = false; | 113 | static int sd; |
114 | char *localhostname = NULL; | 114 | static char buffer[MAX_INPUT_BUFFER]; |
115 | int sd; | ||
116 | char buffer[MAX_INPUT_BUFFER]; | ||
117 | enum { | 115 | enum { |
118 | TCP_PROTOCOL = 1, | 116 | TCP_PROTOCOL = 1, |
119 | UDP_PROTOCOL = 2, | 117 | UDP_PROTOCOL = 2, |
120 | }; | 118 | }; |
121 | bool ignore_send_quit_failure = false; | 119 | static bool ignore_send_quit_failure = false; |
122 | 120 | ||
123 | 121 | ||
124 | int | 122 | int |