]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: log: fix config parse error logging on stdout/stderr or any raw fd
authorEmeric Brun <ebrun@haproxy.com>
Wed, 7 Apr 2021 12:26:44 +0000 (14:26 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 7 Apr 2021 13:01:00 +0000 (15:01 +0200)
The regression was introduced by commit previous commit 94aab06:
MEDIUM: log: support tcp or stream addresses on log lines.

This previous patch tries to retrieve the used protocol parsing
the address using the str2sa_range function but forgets that
the raw file descriptor adresses don't specify a protocol
and str2sa_range probes an error.

This patch re-work the str2sa_range function to stop
probing error if an authorized RAW_FD address is parsed
whereas the caller request also a protocol.

It also modify the code of parse_logsrv to switch on stream
logservers only if a protocol was detected.

src/log.c
src/tools.c

index e202462e31f70e813c31ad0072bf5c87cd27a854..2b4b8388d353ec316dcf5678033c58ad05c039a4 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -1051,7 +1051,7 @@ int parse_logsrv(char **args, struct list *logsrvs, int do_del, const char *file
                        set_host_port(&logsrv->addr, SYSLOG_PORT);
        }
 
-       if (proto->ctrl_type == SOCK_STREAM) {
+       if (proto && proto->ctrl_type == SOCK_STREAM) {
                static unsigned long ring_ids;
 
                /* Implicit sink buffer will be
index 9cb4e89fb2da722bbd6a683f683e7cf9a586d7b4..7bb9b05987cc34c27b8d795666d60189c67cf20e 100644 (file)
@@ -1218,7 +1218,8 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int
 
        if (proto || (opts & PA_O_CONNECT)) {
                /* Note: if the caller asks for a proto, we must find one,
-                * except if we return with an fqdn that will resolve later,
+                * except if we inherit from a raw FD (family == AF_CUST_EXISTING_FD)
+                * orif we return with an fqdn that will resolve later,
                 * in which case the address is not known yet (this is only
                 * for servers actually).
                 */
@@ -1226,7 +1227,7 @@ struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int
                                            sock_type == SOCK_DGRAM,
                                            ctrl_type == SOCK_DGRAM);
 
-               if (!new_proto && (!fqdn || !*fqdn)) {
+               if (!new_proto && (!fqdn || !*fqdn) && (ss.ss_family != AF_CUST_EXISTING_FD)) {
                        memprintf(err, "unsupported protocol family %d for address '%s'", ss.ss_family, str);
                        goto out;
                }