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

1
NEWS
View File

@ -4,6 +4,7 @@ ver 0.21.4 (not yet released)
- upnp: implement "list ... group"
* output
- httpd: declare protocol "HTTP/1.1" instead of "ICY"
* remove libwrap support
ver 0.21.3 (2018/11/16)
* output

View File

@ -88,7 +88,7 @@ For example, the following installs a fairly complete list of build dependencies
libupnp-dev \
libavahi-client-dev \
libsqlite3-dev \
libsystemd-dev libwrap0-dev \
libsystemd-dev \
libgtest-dev \
libboost-dev \
libicu-dev

View File

@ -312,7 +312,6 @@ subdir('src/lib/curl')
subdir('src/lib/expat')
subdir('src/lib/ffmpeg')
subdir('src/lib/gcrypt')
subdir('src/lib/wrap')
subdir('src/lib/nfs')
subdir('src/lib/oss')
subdir('src/lib/pcre')
@ -432,7 +431,6 @@ mpd = build_target(
systemd_dep,
sqlite_dep,
zeroconf_dep,
libwrap_dep,
more_deps,
],
link_args: link_args,

View File

@ -175,7 +175,6 @@ option('dbus', type: 'feature', description: 'D-Bus support')
option('expat', type: 'feature', description: 'Expat XML support')
option('icu', type: 'feature', description: 'Use libicu for Unicode')
option('iconv', type: 'feature', description: 'Use iconv() for character set conversion')
option('libwrap', type: 'feature', description: 'libwrap support')
option('pcre', type: 'feature', description: 'Enable regular expression support (using libpcre)')
option('sqlite', type: 'feature', description: 'SQLite database support (for stickers)')
option('yajl', type: 'feature', description: 'libyajl for YAML support')

View File

@ -35,10 +35,6 @@
#include <sys/socket.h>
#endif
#ifdef HAVE_LIBWRAP
#include <tcpd.h>
#endif
static constexpr char GREETING[] = "OK MPD " PROTOCOL_VERSION "\n";
Client::Client(EventLoop &_loop, Partition &_partition,
@ -66,27 +62,6 @@ client_new(EventLoop &loop, Partition &partition,
assert(fd.IsDefined());
#ifdef HAVE_LIBWRAP
if (address.GetFamily() != AF_LOCAL) {
// 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(client_domain,
"libwrap refused connection (libwrap=%s) from %s",
progname, remote.c_str());
return;
}
}
#endif /* HAVE_WRAP */
ClientList &client_list = *partition.instance.client_list;
if (client_list.IsFull()) {
LogWarning(client_domain, "Max connections reached");

View File

@ -1,21 +0,0 @@
libwrap_option = get_option('libwrap')
enable_libwrap = false
if not libwrap_option.disabled() and compiler.has_header('tcpd.h') and compiler.compiles('''
#include <tcpd.h>
bool CheckLibWrap(int fd, const char &progname) {
struct request_info req;
request_init(&req, RQ_FILE, fd, RQ_DAEMON, progname, 0);
fromhost(&req);
return hosts_access(&req);
}
''')
libwrap_dep = compiler.find_library('wrap', required: libwrap_option)
else
libwrap_dep = dependency('', required: libwrap_option)
endif
if not libwrap_dep.found() and libwrap_option.enabled()
error('libwrap not found')
endif
conf.set('HAVE_LIBWRAP', libwrap_dep.found())

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