os: if inet_ntop() is available, use it for IPv4 addresses as well
Support for using inet_ntop() was originally added to support IPv6, and only used for IPv6 addresses in AuthAudit(). Two decades later, support for inet_ntop() is ubiquitous and OS'es have marked inet_ntoa() as deprecated, so use the modern interface for IPv4 as well now. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1760>
This commit is contained in:
parent
2ffe0f8a35
commit
6cc358dfb4
|
@ -152,6 +152,7 @@ conf_data.set('HAVE_GETPEEREID', cc.has_function('getpeereid') ? '1' : false)
|
|||
conf_data.set('HAVE_GETPEERUCRED', cc.has_function('getpeerucred') ? '1' : false)
|
||||
conf_data.set('HAVE_GETPROGNAME', cc.has_function('getprogname') ? '1' : false)
|
||||
conf_data.set('HAVE_GETZONEID', cc.has_function('getzoneid') ? '1' : false)
|
||||
conf_data.set('HAVE_INET_NTOP', cc.has_function('inet_ntop') ? '1' : false)
|
||||
conf_data.set('HAVE_MEMFD_CREATE', cc.has_function('memfd_create') ? '1' : false)
|
||||
conf_data.set('HAVE_MKOSTEMP', cc.has_function('mkostemp') ? '1' : false)
|
||||
conf_data.set('HAVE_MMAP', cc.has_function('mmap') ? '1' : false)
|
||||
|
|
|
@ -390,9 +390,18 @@ AuthAudit(ClientPtr client, Bool letin,
|
|||
strlcpy(addr, "local host", sizeof(addr));
|
||||
break;
|
||||
#if defined(TCPCONN)
|
||||
case AF_INET:
|
||||
snprintf(addr, sizeof(addr), "IP %s",
|
||||
inet_ntoa(((struct sockaddr_in *) saddr)->sin_addr));
|
||||
case AF_INET:{
|
||||
#if defined(HAVE_INET_NTOP)
|
||||
char ipaddr[INET_ADDRSTRLEN];
|
||||
|
||||
inet_ntop(AF_INET, &((struct sockaddr_in *) saddr)->sin_addr,
|
||||
ipaddr, sizeof(ipaddr));
|
||||
#else
|
||||
const char *ipaddr =
|
||||
inet_ntoa(((struct sockaddr_in *) saddr)->sin_addr);
|
||||
#endif
|
||||
snprintf(addr, sizeof(addr), "IP %s", ipaddr);
|
||||
}
|
||||
break;
|
||||
#if defined(IPv6)
|
||||
case AF_INET6:{
|
||||
|
|
Loading…
Reference in New Issue