AC_SUBST(HAVE_GLIB12)
AM_CONDITIONAL([HAVE_GLIB12], [test "x$HAVE_GLIB12" = x1])
+AC_MSG_CHECKING([for tcpwrap library and headers])
+LIBWRAP_LIBS=
+saved_LIBS="$LIBS"
+LIBS="$LIBS -lwrap"
+AC_LINK_IFELSE(
+AC_LANG_PROGRAM(
+[#include <tcpd.h>
+#include <syslog.h>
+int allow_severity = LOG_INFO;
+int deny_severity = LOG_WARNING;],
+[struct request_info *req;
+return hosts_access (req);]),
+[AC_DEFINE(HAVE_LIBWRAP, [], [Have tcpwrap?])
+LIBWRAP_LIBS="-lwrap"
+AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+AC_SUBST(LIBWRAP_LIBS)
+LIBS="$saved_LIBS"
+
# If using GCC specify some additional parameters
if test "x$GCC" = "xyes" ; then
CFLAGS="$CFLAGS -pipe -W -Wall -pedantic"
- filter capture data in client through alignment
- add radio module
- make autoload list use idxset
-- libwrap
** later ***
- xmlrpc/http
libsocket_server_la_SOURCES = socket-server.c socket-server.h
libsocket_server_la_LDFLAGS = -avoid-version
-libsocket_server_la_LIBADD = $(AM_LIBADD) libiochannel.la libsocket-util.la
+libsocket_server_la_LIBADD = $(AM_LIBADD) libiochannel.la libsocket-util.la $(LIBWRAP_LIBS)
libsocket_client_la_SOURCES = socket-client.c socket-client.h
libsocket_client_la_LDFLAGS = -avoid-version
int pa_authkey_load_from_home(const char *fn, void *data, size_t length) {
char *home;
char path[PATH_MAX];
- char *p;
+ const char *p;
assert(fn && data && length);
if (!(home = getenv("HOME")))
return -2;
- snprintf(p = path, sizeof(path), "%s/%s", home, fn);
+ snprintf(path, sizeof(path), "%s/%s", home, fn);
+ p = path;
} else
p = fn;
#include <ltdl.h>
#include <memblock.h>
+#ifdef HAVE_LIBWRAP
+#include <syslog.h>
+#include <tcpd.h>
+#endif
+
#include "core.h"
#include "mainloop.h"
#include "module.h"
#include "caps.h"
#include "cli-text.h"
+#ifdef HAVE_LIBWRAP
+/* Only one instance of these variables */
+int allow_severity = LOG_INFO;
+int deny_severity = LOG_WARNING;
+#endif
+
static void signal_callback(struct pa_mainloop_api*m, struct pa_signal_event *e, int sig, void *userdata) {
pa_log(__FILE__": Got signal %s.\n", pa_strsignal(sig));
#include "protocol-simple.h"
#define protocol_new pa_protocol_simple_new
#define protocol_free pa_protocol_simple_free
+ #define TCPWRAP_SERVICE "polypaudio-simple"
#define IPV4_PORT 4711
#define UNIX_SOCKET "/tmp/polypaudio/simple"
#define MODULE_ARGUMENTS "rate", "format", "channels", "sink", "source", "playback", "record",
PA_MODULE_DESCRIPTION("Simple protocol "SOCKET_DESCRIPTION)
PA_MODULE_USAGE("rate=<sample rate> format=<sample format> channels=<number of channels> sink=<sink to connect to> source=<source to connect to> playback=<enable playback?> record=<enable record?> "SOCKET_USAGE)
-
#elif defined(USE_PROTOCOL_CLI)
#include "protocol-cli.h"
#define protocol_new pa_protocol_cli_new
#define protocol_free pa_protocol_cli_free
+ #define TCPWRAP_SERVICE "polypaudio-cli"
#define IPV4_PORT 4712
#define UNIX_SOCKET "/tmp/polypaudio/cli"
#define MODULE_ARGUMENTS
#include "protocol-native.h"
#define protocol_new pa_protocol_native_new
#define protocol_free pa_protocol_native_free
+ #define TCPWRAP_SERVICE "polypaudio-native"
#define IPV4_PORT PA_NATIVE_DEFAULT_PORT
#define UNIX_SOCKET "/tmp/polypaudio/native"
#define MODULE_ARGUMENTS "public", "cookie",
#include "esound.h"
#define protocol_new pa_protocol_esound_new
#define protocol_free pa_protocol_esound_free
+ #define TCPWRAP_SERVICE "esound"
#define IPV4_PORT ESD_DEFAULT_PORT
#define UNIX_SOCKET ESD_UNIX_SOCKET_NAME
#define MODULE_ARGUMENTS "sink", "source", "public", "cookie",
return NULL;
}
- if (!(s = pa_socket_server_new_ipv4(c->mainloop, loopback ? INADDR_LOOPBACK : INADDR_ANY, port)))
+ if (!(s = pa_socket_server_new_ipv4(c->mainloop, loopback ? INADDR_LOOPBACK : INADDR_ANY, port, TCPWRAP_SERVICE)))
return NULL;
#else
int r;
#include <netinet/in.h>
#include <arpa/inet.h>
+#ifdef HAVE_LIBWRAP
+#include <tcpd.h>
+#endif
+
#include "socket-server.h"
#include "socket-util.h"
#include "xmalloc.h"
int ref;
int fd;
char *filename;
+ char *tcpwrap_service;
void (*on_connection)(struct pa_socket_server*s, struct pa_iochannel *io, void *userdata);
void *userdata;
goto finish;
}
+#ifdef HAVE_LIBWRAP
+
+ if (s->type == SOCKET_SERVER_IPV4 && s->tcpwrap_service) {
+ struct request_info req;
+
+ request_init(&req, RQ_DAEMON, s->tcpwrap_service, RQ_FILE, nfd, NULL);
+ fromhost(&req);
+ if (!hosts_access(&req)) {
+ pa_log(__FILE__": TCP connection refused by tcpwrap.\n");
+ close(nfd);
+ goto finish;
+ }
+
+ pa_log(__FILE__": TCP connection accepted by tcpwrap.\n");
+ }
+#endif
+
/* There should be a check for socket type here */
if (s->type == SOCKET_SERVER_IPV4)
pa_socket_tcp_low_delay(fd);
s->filename = NULL;
s->on_connection = NULL;
s->userdata = NULL;
+ s->tcpwrap_service = NULL;
s->mainloop = m;
s->io_event = m->io_new(m, fd, PA_IO_EVENT_INPUT, callback, s);
return NULL;
}
-struct pa_socket_server* pa_socket_server_new_ipv4(struct pa_mainloop_api *m, uint32_t address, uint16_t port) {
+struct pa_socket_server* pa_socket_server_new_ipv4(struct pa_mainloop_api *m, uint32_t address, uint16_t port, const char *tcpwrap_service) {
struct pa_socket_server *ss;
int fd = -1;
struct sockaddr_in sa;
goto fail;
}
- if ((ss = pa_socket_server_new(m, fd)))
+ if ((ss = pa_socket_server_new(m, fd))) {
ss->type = SOCKET_SERVER_IPV4;
+ ss->tcpwrap_service = pa_xstrdup(tcpwrap_service);
+ }
return ss;
pa_xfree(s->filename);
}
+ pa_xfree(s->tcpwrap_service);
+
s->mainloop->io_free(s->io_event);
pa_xfree(s);
}
struct pa_socket_server* pa_socket_server_new(struct pa_mainloop_api *m, int fd);
struct pa_socket_server* pa_socket_server_new_unix(struct pa_mainloop_api *m, const char *filename);
-struct pa_socket_server* pa_socket_server_new_ipv4(struct pa_mainloop_api *m, uint32_t address, uint16_t port);
+struct pa_socket_server* pa_socket_server_new_ipv4(struct pa_mainloop_api *m, uint32_t address, uint16_t port, const char *tcpwrap_service);
void pa_socket_server_unref(struct pa_socket_server*s);
struct pa_socket_server* pa_socket_server_ref(struct pa_socket_server *s);
assert(s && s->ref >= 1 && chunk);
pa_source_ref(s);
- pa_idxset_foreach(s->outputs, do_post, chunk);
+ pa_idxset_foreach(s->outputs, do_post, (void*) chunk);
pa_source_unref(s);
}