From 26754901e9338050339e00266ee0130a68f76eb9 Mon Sep 17 00:00:00 2001 From: Emeric Brun Date: Wed, 7 Apr 2021 14:26:44 +0200 Subject: [PATCH] BUG/MEDIUM: log: fix config parse error logging on stdout/stderr or any raw fd 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 | 2 +- src/tools.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/log.c b/src/log.c index e202462e3..2b4b8388d 100644 --- 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 diff --git a/src/tools.c b/src/tools.c index 9cb4e89fb..7bb9b0598 100644 --- a/src/tools.c +++ b/src/tools.c @@ -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; }