socket: add function to check supported family

Don't log error when an IPv6 socket cannot be opened and chronyd was
built without IPv6 support.

Reported-by: Lonnie Abelbeck <lonnie@abelbeck.com>
This commit is contained in:
Miroslav Lichvar
2020-01-03 09:36:59 +01:00
parent bfcd8ecc56
commit dd0679ad45
4 changed files with 24 additions and 1 deletions

View File

@@ -159,7 +159,7 @@ open_socket(int family)
case IPADDR_INET4:
case IPADDR_INET6:
port = CNF_GetCommandPort();
if (port == 0)
if (port == 0 || !SCK_IsFamilySupported(family))
return INVALID_SOCK_FD;
CNF_GetBindCommandAddress(family, &local_addr.ip_addr);