diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-03-10 09:56:05 +0100 |
|---|---|---|
| committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-03-10 09:56:05 +0100 |
| commit | c5f873aa7b74c26c985a81bc4ffeb8d5fd1ce8a9 (patch) | |
| tree | 071b4f6876b3e4fb8ec9248e232c6ee45a448f12 | |
| parent | acf57dba5233926a95fc746429f31f3009111b6f (diff) | |
| download | monitoring-plugins-c5f873aa7b74c26c985a81bc4ffeb8d5fd1ce8a9.tar.gz | |
check_smtp: small style fixes
| -rw-r--r-- | plugins/check_smtp.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index 1b36a22a..ac0aa45d 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c | |||
| @@ -28,7 +28,6 @@ | |||
| 28 | * | 28 | * |
| 29 | *****************************************************************************/ | 29 | *****************************************************************************/ |
| 30 | 30 | ||
| 31 | #include "states.h" | ||
| 32 | const char *progname = "check_smtp"; | 31 | const char *progname = "check_smtp"; |
| 33 | const char *copyright = "2000-2024"; | 32 | const char *copyright = "2000-2024"; |
| 34 | const char *email = "devel@monitoring-plugins.org"; | 33 | const char *email = "devel@monitoring-plugins.org"; |
| @@ -41,6 +40,7 @@ const char *email = "devel@monitoring-plugins.org"; | |||
| 41 | 40 | ||
| 42 | #include <ctype.h> | 41 | #include <ctype.h> |
| 43 | #include "check_smtp.d/config.h" | 42 | #include "check_smtp.d/config.h" |
| 43 | #include "../lib/states.h" | ||
| 44 | 44 | ||
| 45 | #define PROXY_PREFIX "PROXY TCP4 0.0.0.0 0.0.0.0 25 25\r\n" | 45 | #define PROXY_PREFIX "PROXY TCP4 0.0.0.0 0.0.0.0 25 25\r\n" |
| 46 | #define SMTP_HELO "HELO " | 46 | #define SMTP_HELO "HELO " |
| @@ -92,9 +92,6 @@ static int my_close(int /*socket_descriptor*/); | |||
| 92 | static int verbose = 0; | 92 | static int verbose = 0; |
| 93 | 93 | ||
| 94 | int main(int argc, char **argv) { | 94 | int main(int argc, char **argv) { |
| 95 | /* Catch pipe errors in read/write - sometimes occurs when writing QUIT */ | ||
| 96 | (void)signal(SIGPIPE, SIG_IGN); | ||
| 97 | |||
| 98 | setlocale(LC_ALL, ""); | 95 | setlocale(LC_ALL, ""); |
| 99 | bindtextdomain(PACKAGE, LOCALEDIR); | 96 | bindtextdomain(PACKAGE, LOCALEDIR); |
| 100 | textdomain(PACKAGE); | 97 | textdomain(PACKAGE); |
| @@ -123,6 +120,7 @@ int main(int argc, char **argv) { | |||
| 123 | exit(STATE_CRITICAL); | 120 | exit(STATE_CRITICAL); |
| 124 | } | 121 | } |
| 125 | } | 122 | } |
| 123 | |||
| 126 | char *helocmd = NULL; | 124 | char *helocmd = NULL; |
| 127 | if (config.use_lhlo) { | 125 | if (config.use_lhlo) { |
| 128 | xasprintf(&helocmd, "%s%s%s", SMTP_LHLO, localhostname, "\r\n"); | 126 | xasprintf(&helocmd, "%s%s%s", SMTP_LHLO, localhostname, "\r\n"); |
| @@ -137,7 +135,6 @@ int main(int argc, char **argv) { | |||
| 137 | } | 135 | } |
| 138 | 136 | ||
| 139 | char *mail_command = strdup("MAIL "); | 137 | char *mail_command = strdup("MAIL "); |
| 140 | |||
| 141 | char *cmd_str = NULL; | 138 | char *cmd_str = NULL; |
| 142 | /* initialize the MAIL command with optional FROM command */ | 139 | /* initialize the MAIL command with optional FROM command */ |
| 143 | xasprintf(&cmd_str, "%sFROM:<%s>%s", mail_command, config.from_arg, "\r\n"); | 140 | xasprintf(&cmd_str, "%sFROM:<%s>%s", mail_command, config.from_arg, "\r\n"); |
| @@ -146,6 +143,9 @@ int main(int argc, char **argv) { | |||
| 146 | printf("FROM CMD: %s", cmd_str); | 143 | printf("FROM CMD: %s", cmd_str); |
| 147 | } | 144 | } |
| 148 | 145 | ||
| 146 | /* Catch pipe errors in read/write - sometimes occurs when writing QUIT */ | ||
| 147 | (void)signal(SIGPIPE, SIG_IGN); | ||
| 148 | |||
| 149 | /* initialize alarm signal handling */ | 149 | /* initialize alarm signal handling */ |
| 150 | (void)signal(SIGALRM, socket_timeout_alarm_handler); | 150 | (void)signal(SIGALRM, socket_timeout_alarm_handler); |
| 151 | 151 | ||
| @@ -204,6 +204,7 @@ int main(int argc, char **argv) { | |||
| 204 | printf(_("recv() failed\n")); | 204 | printf(_("recv() failed\n")); |
| 205 | exit(STATE_WARNING); | 205 | exit(STATE_WARNING); |
| 206 | } | 206 | } |
| 207 | |||
| 207 | bool supports_tls = false; | 208 | bool supports_tls = false; |
| 208 | if (config.use_ehlo || config.use_lhlo) { | 209 | if (config.use_ehlo || config.use_lhlo) { |
| 209 | if (strstr(buffer, "250 STARTTLS") != NULL || strstr(buffer, "250-STARTTLS") != NULL) { | 210 | if (strstr(buffer, "250 STARTTLS") != NULL || strstr(buffer, "250-STARTTLS") != NULL) { |
| @@ -228,6 +229,7 @@ int main(int argc, char **argv) { | |||
| 228 | smtp_quit(config, buffer, socket_descriptor, ssl_established); | 229 | smtp_quit(config, buffer, socket_descriptor, ssl_established); |
| 229 | exit(STATE_UNKNOWN); | 230 | exit(STATE_UNKNOWN); |
| 230 | } | 231 | } |
| 232 | |||
| 231 | result = np_net_ssl_init_with_hostname(socket_descriptor, (config.use_sni ? config.server_address : NULL)); | 233 | result = np_net_ssl_init_with_hostname(socket_descriptor, (config.use_sni ? config.server_address : NULL)); |
| 232 | if (result != STATE_OK) { | 234 | if (result != STATE_OK) { |
| 233 | printf(_("CRITICAL - Cannot create SSL context.\n")); | 235 | printf(_("CRITICAL - Cannot create SSL context.\n")); |
| @@ -235,6 +237,7 @@ int main(int argc, char **argv) { | |||
| 235 | np_net_ssl_cleanup(); | 237 | np_net_ssl_cleanup(); |
| 236 | exit(STATE_CRITICAL); | 238 | exit(STATE_CRITICAL); |
| 237 | } | 239 | } |
| 240 | |||
| 238 | ssl_established = true; | 241 | ssl_established = true; |
| 239 | 242 | ||
| 240 | /* | 243 | /* |
