remove libwrap support

libwrap is an obscure artefact from a past long ago, when source IP
address meant something.

And its API is "interesting"; it requires the application to expose
two global variables `allow_severity` and `deny_severity`.  This led
to bug #437.  I don't want to declare those variables; instead, I'd
like to remove libwrap support.

Closes #437
This commit is contained in:
Max Kellermann
2018-12-28 14:16:02 +01:00
parent 1c7bd7d5c4
commit 22e6d95c4b
8 changed files with 4 additions and 80 deletions

View File

@@ -40,11 +40,6 @@
#include <string.h>
#include <errno.h>
#ifdef HAVE_LIBWRAP
#include <sys/socket.h> /* needed for AF_LOCAL */
#include <tcpd.h>
#endif
const Domain httpd_output_domain("httpd_output");
inline
@@ -130,34 +125,11 @@ HttpdOutput::OnDeferredBroadcast() noexcept
void
HttpdOutput::OnAccept(UniqueSocketDescriptor fd,
SocketAddress address, gcc_unused int uid) noexcept
SocketAddress, gcc_unused int uid) noexcept
{
/* the listener socket has become readable - a client has
connected */
#ifdef HAVE_LIBWRAP
if (address.GetFamily() != AF_LOCAL) {
const auto hostaddr = ToString(address);
// TODO: shall we obtain the program name from argv[0]?
const char *progname = "mpd";
struct request_info req;
request_init(&req, RQ_FILE, fd.Get(), RQ_DAEMON, progname, 0);
fromhost(&req);
if (!hosts_access(&req)) {
/* tcp wrappers says no */
FormatWarning(httpd_output_domain,
"libwrap refused connection (libwrap=%s) from %s",
progname, hostaddr.c_str());
return;
}
}
#else
(void)address;
#endif /* HAVE_WRAP */
const std::lock_guard<Mutex> protect(mutex);
/* can we allow additional client */

View File

@@ -38,7 +38,7 @@ if get_option('httpd')
'httpd/HttpdClient.cxx',
'httpd/HttpdOutputPlugin.cxx',
]
output_plugins_deps += [ event_dep, net_dep, libwrap_dep ]
output_plugins_deps += [ event_dep, net_dep ]
need_encoder = true
endif