AC_C_BIGENDIAN
+AC_CHECK_LIB(cap, cap_init, [CAP_LIBS='-lcap'], [CAP_LIBS=''])
+AC_SUBST(CAP_LIBS)
+
+AC_CHECK_HEADERS(sys/capability.h)
+
PKG_CHECK_MODULES(LIBSAMPLERATE, [ samplerate >= 0.1.0 ])
AC_SUBST(LIBSAMPLERATE_CFLAGS)
AC_SUBST(LIBSAMPLERATE_LIBS)
<tr><td><tt>sink_name=</tt></td><td>The name for the combined sink. (defaults to <tt>combined</tt>)</td></tr>
<tr><td><tt>master=</tt></td><td>The name of the first sink to link into the combined think. The sample rate/type is taken from this sink.</td></tr>
<tr><td><tt>slaves=</tt></td><td>Name of additional sinks to link into the combined think, seperated by commas.</td></tr>
- <tr><td><tt>adjust_time=</td><td>Time in seconds when to readjust the sample rate of all sinks. (defaults to 20)</td></tr>
- <tr><td><tt>resample_method=</td><td>Resampling algorithm to
+ <tr><td><tt>adjust_time=</tt></td><td>Time in seconds when to readjust the sample rate of all sinks. (defaults to 20)</td></tr>
+ <tr><td><tt>resample_method=</tt></td><td>Resampling algorithm to
use. See <tt>libsamplerate</tt>'s documentation for more
information. Use one of <tt>sinc-best-quality</tt>,
<tt>sinc-medium-quality</tt>, <tt>sinc-fastest</tt>,
modlibdir=$(libdir)/polypaudio-@PA_MAJORMINOR@
-AM_CFLAGS=-D_GNU_SOURCE -I$(top_srcdir) $(PTHREAD_CFLAGS)
+AM_CFLAGS=-D_GNU_SOURCE -I$(top_srcdir) $(PTHREAD_CFLAGS)
AM_CFLAGS+=-DDLSEARCHPATH=\"$(modlibdir)\"
AM_CFLAGS+=-DDEFAULT_SCRIPT_FILE=\"$(polypconfdir)/default.pa\"
AM_CFLAGS+=-DDEFAULT_CONFIG_FILE=\"$(polypconfdir)/daemon.conf\"
modinfo.c modinfo.h \
daemon-conf.c daemon-conf.h \
dumpmodules.c dumpmodules.h \
- conf-parser.h conf-parser.c
+ conf-parser.h conf-parser.c \
+ caps.h caps.c
polypaudio_CFLAGS = $(AM_CFLAGS) $(LIBSAMPLERATE_CFLAGS) $(LIBSNDFILE_CFLAGS)
polypaudio_INCLUDES = $(INCLTDL)
-polypaudio_LDADD = $(AM_LDADD) $(LIBLTDL) $(LIBSAMPLERATE_LIBS) $(LIBSNDFILE_LIBS) $(LEXLIB)
+polypaudio_LDADD = $(AM_LDADD) $(LIBLTDL) $(LIBSAMPLERATE_LIBS) $(LIBSNDFILE_LIBS) $(CAP_LIBS)
polypaudio_LDFLAGS=-export-dynamic
libprotocol_simple_la_SOURCES = protocol-simple.c protocol-simple.h
--- /dev/null
+/* $Id$ */
+
+/***
+ This file is part of polypaudio.
+
+ polypaudio is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ polypaudio is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with polypaudio; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <assert.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+
+#ifdef HAVE_SYS_CAPABILITY_H
+#include <sys/capability.h>
+#endif
+
+#include "log.h"
+#include "caps.h"
+
+void pa_drop_root(void) {
+ if (getuid() != 0 && geteuid() == 0) {
+ pa_log(__FILE__": Started SUID root, dropping root rights.\n");
+ setuid(getuid());
+ seteuid(getuid());
+ }
+}
+
+#ifdef HAVE_SYS_CAPABILITY_H
+int pa_limit_caps(void) {
+ int r = -1;
+ cap_t caps;
+ cap_value_t nice_cap = CAP_SYS_NICE;
+
+ caps = cap_init();
+ assert(caps);
+
+ cap_clear(caps);
+ cap_set_flag(caps, CAP_EFFECTIVE, 1, &nice_cap, CAP_SET);
+ cap_set_flag(caps, CAP_PERMITTED, 1, &nice_cap, CAP_SET);
+
+ if (cap_set_proc(caps) < 0)
+ goto fail;
+
+ pa_log(__FILE__": Started SUID root, capabilities limited.\n");
+
+ r = 0;
+
+fail:
+ cap_free (caps);
+
+ return r;
+}
+
+int pa_drop_caps(void) {
+ cap_t caps;
+ int r = -1;
+
+ caps = cap_init();
+ assert(caps);
+
+ cap_clear(caps);
+
+ if (cap_set_proc(caps) < 0)
+ goto fail;
+
+ pa_drop_root();
+
+ r = 0;
+
+fail:
+ cap_free (caps);
+
+ return r;
+}
+
+#else
+
+int pa_limit_caps(void) {
+ return 0;
+}
+
+int pa_drop_caps(void) {
+ pa_drop_root();
+ return 0;
+}
+
+#endif
+
--- /dev/null
+#ifndef foocapshfoo
+#define foocapshfoo
+
+/* $Id$ */
+
+/***
+ This file is part of polypaudio.
+
+ polypaudio is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ polypaudio is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with polypaudio; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+***/
+
+void pa_drop_root(void);
+int pa_limit_caps(void);
+int pa_drop_caps(void);
+
+#endif
#include "log.h"
#include "daemon-conf.h"
#include "dumpmodules.h"
+#include "caps.h"
static struct pa_mainloop *mainloop;
-static void drop_root(void) {
- if (getuid() != 0 && geteuid() == 0) {
- pa_log(__FILE__": Started SUID root, dropping root rights.\n");
- setuid(getuid());
- seteuid(getuid());
- }
-}
-
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));
int r, retval = 1, d = 0;
int daemon_pipe[2] = { -1, -1 };
+ pa_limit_caps();
+
r = lt_dlinit();
assert(r == 0);
if (conf->high_priority && conf->cmd == PA_CMD_DAEMON)
pa_raise_priority();
- drop_root();
+ pa_drop_caps();
if (conf->dl_search_path)
lt_dlsetsearchpath(conf->dl_search_path);
***/
#include <inttypes.h>
+#include <sys/time.h>
+#include <time.h>
+
#include "cdecl.h"
#include "sample.h"
#include <inttypes.h>
#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
#include "sample.h"
#include <sched.h>
#include <sys/resource.h>
#include <limits.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
#include <samplerate.h>
int pa_parse_resample_method(const char *string);
+
#endif