]> git.decadent.org.uk Git - nfs-utils.git/commit - support/misc/tcpwrapper.c
tcp_wrappers: Use getifaddrs(3) if it is available
authorChuck Lever <chuck.lever@oracle.com>
Fri, 15 Jan 2010 20:53:07 +0000 (15:53 -0500)
committerSteve Dickson <steved@redhat.com>
Sun, 17 Jan 2010 21:45:12 +0000 (16:45 -0500)
commit4bc0dbaed1ba2f58beea2cdb0595b461e0c88b8e
treeb618147519a75390227a370f95c2d4de2e0daf41
parente8c917f53741100d6ea710100dca7c914791880b
tcp_wrappers: Use getifaddrs(3) if it is available

After glibc 2.3.3, getifaddrs(3) can return AF_INET6 addresses for
local network interfaces.  Using the library call is easier than
trying to update the open code in from_local(), and means we have
less to maintain in nfs-utils going forward.

And, since from_local() can now support IPv6, change its synopsis to
take a "struct sockaddr *" .

Note that the original code discovers local addresses once.  These
days, with wifi, DHCP, and NetworkManager, the local network
configuration can change dynamically over time.  So, call getifaddrs()
more often to ensure from_local() has up-to-date network configuration
information.

This implementation refreshes the list if from_local() has not been
called in the last second.  This is actually not terribly honerous.
check_default() invokes from_local() only when the remote host is not
in its access cache, or the access/deny files have changed.

So new hosts will cause a refresh, but previously seen hosts
(including localhost) should not.

On the other hand, it still may not be often enough.  After the first
call, if only previously seen hosts attempt to access our daemons,
from_local() would never be called, and the local list would never be
updated.  This might be possible during steady-state operation with
a small number of servers and clients.

It would also be nice if we could free the local interface address
list at shutdown time, but that would be a lot of trouble for little
gain.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
aclocal/ipv6.m4
configure.ac
support/include/tcpwrapper.h
support/misc/from_local.c
support/misc/tcpwrapper.c