]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: email-alert: Set the mailer port during alert initialization
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 27 Mar 2018 13:35:35 +0000 (15:35 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 4 Apr 2018 08:36:50 +0000 (10:36 +0200)
Since the commit 2f3a56b4f ("BUG/MINOR: tcp-check: use the server's service port
as a fallback"), email alerts stopped working because the mailer's port was
overriden by the server's port. Remember, email alerts are defined as checks
with specific tcp-check rules and triggered on demand to send alerts. So to send
an email, a check is executed. Because no specific port's was defined, the
server's one was used.

To fix the bug, the ports used for checks attached an email alert are explicitly
set using the mailer's port. So this port will be used instead of the server's
one.

In this patch, the assignement to a default port (587) when an email alert is
defined has been removed. Indeed, when a mailer is defined, the port must be
defined. So the default port was never used.

This patch must be backported in 1.8.

src/checks.c

index 8e4bc2ccf142ade5a9fe4136d2556de957c64f3d..80a9c70d2ae3d0a1b5b397dae00117063f7d8ed9 100644 (file)
@@ -3202,9 +3202,7 @@ int init_email_alert(struct mailers *mls, struct proxy *p, char **err)
 
                check->xprt = mailer->xprt;
                check->addr = mailer->addr;
-               if (!get_host_port(&mailer->addr))
-                       /* Default to submission port */
-                       check->port = 587;
+               check->port = get_host_port(&mailer->addr);
                //check->server = s;
 
                if ((t = task_new(MAX_THREADS_MASK)) == NULL) {