mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
Add support for libwrap
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@250 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
d09240118c
commit
66999e5ada
9 changed files with 70 additions and 10 deletions
19
configure.ac
19
configure.ac
|
|
@ -111,6 +111,25 @@ AC_SUBST(GLIB12_LIBS)
|
|||
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"
|
||||
|
|
|
|||
1
doc/todo
1
doc/todo
|
|
@ -11,7 +11,6 @@
|
|||
- filter capture data in client through alignment
|
||||
- add radio module
|
||||
- make autoload list use idxset
|
||||
- libwrap
|
||||
|
||||
** later ***
|
||||
- xmlrpc/http
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ libprotocol_simple_la_LIBADD = $(AM_LIBADD) libsocket-server.la libiochannel.la
|
|||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ int pa_authkey_load(const char *path, void *data, size_t length) {
|
|||
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);
|
||||
|
||||
|
|
@ -155,7 +155,8 @@ int pa_authkey_load_from_home(const char *fn, void *data, size_t 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;
|
||||
|
||||
|
|
|
|||
11
polyp/main.c
11
polyp/main.c
|
|
@ -34,6 +34,11 @@
|
|||
#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"
|
||||
|
|
@ -50,6 +55,12 @@
|
|||
#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));
|
||||
|
||||
|
|
|
|||
|
|
@ -54,16 +54,17 @@ PA_MODULE_VERSION(PACKAGE_VERSION)
|
|||
#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
|
||||
|
|
@ -73,6 +74,7 @@ PA_MODULE_VERSION(PACKAGE_VERSION)
|
|||
#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",
|
||||
|
|
@ -83,6 +85,7 @@ PA_MODULE_VERSION(PACKAGE_VERSION)
|
|||
#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",
|
||||
|
|
@ -119,7 +122,7 @@ static struct pa_socket_server *create_socket_server(struct pa_core *c, struct p
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,10 @@
|
|||
#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"
|
||||
|
|
@ -45,6 +49,7 @@ struct pa_socket_server {
|
|||
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;
|
||||
|
|
@ -74,6 +79,23 @@ static void callback(struct pa_mainloop_api *mainloop, struct pa_io_event *e, in
|
|||
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);
|
||||
|
|
@ -98,6 +120,7 @@ struct pa_socket_server* pa_socket_server_new(struct pa_mainloop_api *m, int 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);
|
||||
|
|
@ -159,7 +182,7 @@ fail:
|
|||
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;
|
||||
|
|
@ -193,8 +216,10 @@ struct pa_socket_server* pa_socket_server_new_ipv4(struct pa_mainloop_api *m, ui
|
|||
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;
|
||||
|
||||
|
|
@ -214,6 +239,8 @@ static void socket_server_free(struct pa_socket_server*s) {
|
|||
pa_xfree(s->filename);
|
||||
}
|
||||
|
||||
pa_xfree(s->tcpwrap_service);
|
||||
|
||||
s->mainloop->io_free(s->io_event);
|
||||
pa_xfree(s);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ struct pa_socket_server;
|
|||
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ void pa_source_post(struct pa_source*s, const struct pa_memchunk *chunk) {
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue