diff --git a/428.patch b/428.patch new file mode 100644 index 0000000..cf3b8bf --- /dev/null +++ b/428.patch @@ -0,0 +1,96 @@ +From 91fb737675bb628ed95094d8310f4e3d76fcd26b Mon Sep 17 00:00:00 2001 +From: Patrick Uiterwijk +Date: Thu, 13 Dec 2018 18:24:53 +0100 +Subject: [PATCH] check_smtp: Add option to prefix PROXY header + +This enables checks of SMTP servers that expect the haproxy +PROXY protocol: -o smtpd_upstream_proxy_protocol=haproxy. + +Signed-off-by: Patrick Uiterwijk +--- + NEWS | 1 + + plugins/check_smtp.c | 17 ++++++++++++++++- + 2 files changed, 17 insertions(+), 1 deletion(-) + +diff --git a/NEWS b/NEWS +index d3b62cd4..fa5333c0 100644 +--- a/NEWS ++++ b/NEWS +@@ -20,6 +20,7 @@ This file documents the major additions and syntax changes between releases. + check_radius: Add calling-station-id (cejkar) + check_swap: Add --no-swap flag (Mario Trangoni) + ssl_utils: Added certificate expiry data in OK status (check_http, check_smtp, check_tcp) (Matt Capra) ++ check_smtp: Add --proxy flag for PROXY protocol (Patrick Uiterwijk) + + + 2.2.2 xxxx-xx-xx +diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c +index 33d11803..e05dae01 100644 +--- a/plugins/check_smtp.c ++++ b/plugins/check_smtp.c +@@ -52,6 +52,7 @@ int days_till_exp_warn, days_till_exp_crit; + enum { + SMTP_PORT = 25 + }; ++#define PROXY_PREFIX "PROXY TCP4 0.0.0.0 0.0.0.0 25 25\r\n" + #define SMTP_EXPECT "220" + #define SMTP_HELO "HELO " + #define SMTP_EHLO "EHLO " +@@ -106,6 +107,7 @@ double critical_time = 0; + int check_critical_time = FALSE; + int verbose = 0; + int use_ssl = FALSE; ++short use_proxy_prefix = FALSE; + short use_ehlo = FALSE; + short use_lhlo = FALSE; + short ssl_established = 0; +@@ -197,6 +199,13 @@ main (int argc, char **argv) + + if (result == STATE_OK) { /* we connected */ + ++ /* If requested, send PROXY header */ ++ if (use_proxy_prefix) { ++ if (verbose) ++ printf ("Sending header %s\n", PROXY_PREFIX); ++ send(sd, PROXY_PREFIX, strlen(PROXY_PREFIX), 0); ++ } ++ + /* watch for the SMTP connection string and */ + /* return a WARNING status if we couldn't read any data */ + if (recvlines(buffer, MAX_INPUT_BUFFER) <= 0) { +@@ -484,6 +493,7 @@ process_arguments (int argc, char **argv) + {"starttls",no_argument,0,'S'}, + {"certificate",required_argument,0,'D'}, + {"ignore-quit-failure",no_argument,0,'q'}, ++ {"proxy",no_argument,0,'r'}, + {0, 0, 0, 0} + }; + +@@ -500,7 +510,7 @@ process_arguments (int argc, char **argv) + } + + while (1) { +- c = getopt_long (argc, argv, "+hVv46Lt:p:f:e:c:w:H:C:R:SD:F:A:U:P:q", ++ c = getopt_long (argc, argv, "+hVv46Lrt:p:f:e:c:w:H:C:R:SD:F:A:U:P:q", + longopts, &option); + + if (c == -1 || c == EOF) +@@ -617,6 +627,9 @@ process_arguments (int argc, char **argv) + #else + usage (_("SSL support not available - install OpenSSL and recompile")); + #endif ++ case 'r': ++ use_proxy_prefix = TRUE; ++ break; + case 'S': + /* starttls */ + use_ssl = TRUE; +@@ -820,6 +833,8 @@ print_help (void) + printf (" %s\n", _("FROM-address to include in MAIL command, required by Exchange 2000")), + printf (" %s\n", "-F, --fqdn=STRING"); + printf (" %s\n", _("FQDN used for HELO")); ++ printf (" %s\n", "-r, --proxy-prefix"); ++ printf (" %s\n", _("Use PROXY protocol prefix for the connection.")); + #ifdef HAVE_SSL + printf (" %s\n", "-D, --certificate=INTEGER[,INTEGER]"); + printf (" %s\n", _("Minimum number of days a certificate has to be valid.")); diff --git a/nagios-plugins.spec b/nagios-plugins.spec index 88967e4..869d028 100644 --- a/nagios-plugins.spec +++ b/nagios-plugins.spec @@ -5,7 +5,7 @@ Name: nagios-plugins Version: 2.2.1 -Release: 14.20180725git3429dad%{?dist} +Release: 15.20180725git3429dad%{?dist} Summary: Host/service/network monitoring program plugins for Nagios Group: Applications/System @@ -21,6 +21,8 @@ Patch7: nagios-plugins-0007-Fix-the-use-lib-statement-and-the-external-ntp-comma Patch10: nagios-plugins-0010-include-mysql-version-header.patch Patch11: nagios-plugins-0011-fix-perl-shebang.patch +Patch100: https://patch-diff.githubusercontent.com/raw/nagios-plugins/nagios-plugins/pull/428.patch + BuildRequires: %{_bindir}/mailq BuildRequires: %{_bindir}/ps BuildRequires: %{_bindir}/ssh @@ -605,6 +607,7 @@ Provides check_wave support for Nagios. #%if 0%{?fedora} >27 || 0%{?rhel} > 7 %patch11 -p1 -b .fix_perl_shebang #%endif +%patch100 -p1 -b .check_smtp_proxy %build @@ -853,6 +856,9 @@ chmod 644 %{buildroot}/%{_libdir}/nagios/plugins/utils.pm %{_libdir}/nagios/plugins/check_wave %changelog +* Thu Dec 13 2018 Patrick Uiterwijk - 2.2.1-15.20180725git3429dad +- Add upstream PR #428 to add PROXY protocol support to check_smtp + * Wed Jul 25 2018 Stephen Smoogen - 2.2.1-14.20180725git3429dad - Update to latest git and fix release string to match - Fix BZ#1604915