On Fri, 22 May 2020 21:29:43 +0200, Alexander Bluhm wrote:
> On Fri, May 22, 2020 at 07:38:30AM -0600, Todd C. Miller wrote:
> > I'm a little confused by the protocol handling in cfline.
> >
> > if (strcmp(proto, "udp") == 0) {
> > if (fd_udp == -1)
> > proto = "udp6";
> > if (fd_udp6 == -1)
> > proto = "udp4";
> > ipproto = proto;
> > }
> >
> > Doesn't that mean that in the default case if a syslog server is
> > not reachable, proto will end up being set to "udp4" and not "udp"?
> > If so, then your diff will only retry udp4 on SIGHUP instead of
> > both udp4 and udp6.
>
> What do you mean by "not reachable"? As we do not connect(2) and
> ignore most errors of sendto(2), syslogd(8) knows nothing about
> reachabiliy. I guess you mean "if DNS lookup fails".
Sorry, yes, I meant if the DNS lookup fails.
> fd_udp and fd_udp6 should never become -1 as we cannot reopen them.
> If fd_udp6 is -1 we have to restrict ourselves to "udp4". But it
> is better to move this code out of the big if else block. Then we
> get the "no udp4" warning if something went wrong.
>
> There was another problem with my diff. If DNS server switches
> between A and AAAA answers after SIGHUP, the wrong socket has been
> closed. It is better to close the sockets based only on configuration,
> not on runtime DNS. Note that when the config file changes, syslogd
> re-execs itself and we start with fresh sockets.
>
> New diff, move the send_udp = 1 a bit up to the config logic.
OK millert@
- todd