AC_PREREQ(2.63)
-AC_INIT([pulseaudio], m4_esyscmd([./git-version-gen .tarball-version]),
- [mzchyfrnhqvb (at) 0pointer (dot) net])
+AC_INIT([pulseaudio],[m4_esyscmd(./git-version-gen .tarball-version)],[mzchyfrnhqvb (at) 0pointer (dot) net])
AC_CONFIG_SRCDIR([src/daemon/main.c])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
fi
dnl Compiler flags
- DESIRED_FLAGS="-Wall -W -Wextra -pipe -Wno-long-long -Winline -Wvla -Wno-overlength-strings -Wunsafe-loop-optimizations -Wundef -Wformat=2 -Wlogical-op -Wsign-compare -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Wfloat-equal -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing=2 -Wwrite-strings -Wno-unused-parameter -ffast-math -Wp,-D_FORTIFY_SOURCE=2 -fno-common -fdiagnostics-show-option"
-
- for flag in $DESIRED_FLAGS ; do
- CC_CHECK_CFLAGS([$flag], [CFLAGS="$CFLAGS $flag"])
- done
+ CC_CHECK_CFLAGS_APPEND([-Wall -W -Wextra -pipe -Wno-long-long -Winline -Wvla -Wno-overlength-strings -Wunsafe-loop-optimizations -Wundef -Wformat=2 -Wlogical-op -Wsign-compare -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Wfloat-equal -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing=2 -Wwrite-strings -Wno-unused-parameter -ffast-math -Wp,-D_FORTIFY_SOURCE=2 -fno-common -fdiagnostics-show-option])
dnl Linker flags.
dnl Check whether the linker supports the -version-script option.
[VERSIONING_LDFLAGS='-Wl,-version-script=$(srcdir)/map-file'])
AC_SUBST([VERSIONING_LDFLAGS])
+ dnl Check for the proper way to build libraries that have no undefined
+ dnl symbols; on some hosts this needs to be avoided but the macro
+ dnl takes care of it.
+ CC_NOUNDEFINED
+
dnl Check whether to build tests by default (as compile-test) or not
AC_ARG_ENABLE([default-build-tests],
AS_HELP_STRING([--disable-default-build-tests], [Build test programs only during make check]))
[LIBLTDL=])
AS_IF([test "x$LIBLTDL" = "x"],
- [AC_MSG_ERROR([Unable to find libltdl.])])
+ [AC_MSG_ERROR([Unable to find libltdl version 2. Makes sure you have libtool 2.2 or later installed.])])
AC_SUBST([LIBLTDL])
#### Determine build environment ####
endif
FOREIGN_CFLAGS = -w
- MODULE_LDFLAGS = -module -disable-static -avoid-version
+ MODULE_LDFLAGS = -module -disable-static -avoid-version $(LDFLAGS_NOUNDEFINED)
###################################
# Extra files #
bin_PROGRAMS = pulseaudio
pulseaudio_SOURCES = \
- daemon/caps.h daemon/caps.c \
+ daemon/caps.c daemon/caps.h \
daemon/cmdline.c daemon/cmdline.h \
daemon/cpulimit.c daemon/cpulimit.h \
daemon/daemon-conf.c daemon/daemon-conf.h \
daemon/dumpmodules.c daemon/dumpmodules.h \
daemon/ltdl-bind-now.c daemon/ltdl-bind-now.h \
- daemon/main.c
+ daemon/main.c \
+ daemon/server-lookup.c daemon/server-lookup.h
pulseaudio_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS) $(LIBSAMPLERATE_CFLAGS) $(LIBSPEEX_CFLAGS) $(LIBSNDFILE_CFLAGS) $(CAP_CFLAGS) $(LIBOIL_CFLAGS) $(DBUS_CFLAGS)
pulseaudio_LDADD = $(AM_LDADD) libpulsecore-@PA_MAJORMINORMICRO@.la libpulsecommon-@PA_MAJORMINORMICRO@.la libpulse.la $(LIBLTDL) $(LIBSAMPLERATE_LIBS) $(LIBSPEEX_LIBS) $(LIBSNDFILE_LIBS) $(CAP_LIBS) $(LIBOIL_LIBS) $(DBUS_LIBS)
pulsecore/core-error.c pulsecore/core-error.h \
pulsecore/core-rtclock.c pulsecore/core-rtclock.h \
pulsecore/core-util.c pulsecore/core-util.h \
- pulsecore/rtkit.c pulsecore/rtkit.h \
pulsecore/creds.h \
pulsecore/dynarray.c pulsecore/dynarray.h \
pulsecore/endianmacros.h \
endif
if HAVE_DBUS
- libpulsecommon_@PA_MAJORMINORMICRO@_la_SOURCES += pulsecore/dbus-util.c pulsecore/dbus-util.h
+ libpulsecommon_@PA_MAJORMINORMICRO@_la_SOURCES += \
+ pulsecore/dbus-util.c pulsecore/dbus-util.h \
+ pulsecore/rtkit.c pulsecore/rtkit.h
libpulsecommon_@PA_MAJORMINORMICRO@_la_CFLAGS += $(DBUS_CFLAGS)
libpulsecommon_@PA_MAJORMINORMICRO@_la_LIBADD += $(DBUS_LIBS)
endif
pulsecore/object.c pulsecore/object.h \
pulsecore/play-memblockq.c pulsecore/play-memblockq.h \
pulsecore/play-memchunk.c pulsecore/play-memchunk.h \
+ pulsecore/protocol-dbus.h \
pulsecore/resampler.c pulsecore/resampler.h \
pulsecore/rtpoll.c pulsecore/rtpoll.h \
pulsecore/sample-util.c pulsecore/sample-util.h \
endif
if HAVE_DBUS
-libpulsecore_@PA_MAJORMINORMICRO@_la_SOURCES += pulsecore/dbus-shared.c pulsecore/dbus-shared.h
+libpulsecore_@PA_MAJORMINORMICRO@_la_SOURCES += \
+ pulsecore/dbus-shared.c pulsecore/dbus-shared.h \
+ pulsecore/dbus-common.c pulsecore/dbus-common.h
libpulsecore_@PA_MAJORMINORMICRO@_la_CFLAGS += $(DBUS_CFLAGS)
libpulsecore_@PA_MAJORMINORMICRO@_la_LIBADD += $(DBUS_LIBS)
endif
if HAVE_DBUS
modlibexec_LTLIBRARIES += \
- module-rygel-media-server.la
+ module-rygel-media-server.la \
+ module-dbus-protocol.la
endif
if HAVE_BLUEZ
modules/module-position-event-sounds-symdef.h \
modules/module-augment-properties-symdef.h \
modules/module-cork-music-on-phone-symdef.h \
- modules/module-console-kit-symdef.h
+ modules/module-console-kit-symdef.h \
+ modules/module-dbus-protocol-symdef.h
EXTRA_DIST += $(SYMDEF_FILES)
BUILT_SOURCES += $(SYMDEF_FILES)
module_http_protocol_unix_la_CFLAGS = -DUSE_UNIX_SOCKETS -DUSE_PROTOCOL_HTTP $(AM_CFLAGS)
module_http_protocol_unix_la_LDFLAGS = $(MODULE_LDFLAGS)
module_http_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINORMICRO@.la libprotocol-http.la libpulsecommon-@PA_MAJORMINORMICRO@.la libpulse.la
+
+# D-Bus protocol
+
+module_dbus_protocol_la_SOURCES = \
+ pulsecore/dbus-objs/core.c pulsecore/dbus-objs/core.h \
+ modules/module-dbus-protocol.c
+module_dbus_protocol_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
+module_dbus_protocol_la_LDFLAGS = $(MODULE_LDFLAGS)
+module_dbus_protocol_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore-@PA_MAJORMINORMICRO@.la libpulsecommon-@PA_MAJORMINORMICRO@.la libpulse.la
# Native protocol
module_zeroconf_publish_la_SOURCES = modules/module-zeroconf-publish.c
module_zeroconf_publish_la_LDFLAGS = $(MODULE_LDFLAGS)
- module_zeroconf_publish_la_LIBADD = $(AM_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libpulsecore-@PA_MAJORMINORMICRO@.la libpulsecommon-@PA_MAJORMINORMICRO@.la libpulse.la
+ module_zeroconf_publish_la_LIBADD = $(AM_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libprotocol-native.la libpulsecore-@PA_MAJORMINORMICRO@.la libpulsecommon-@PA_MAJORMINORMICRO@.la libpulse.la
module_zeroconf_publish_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS)
module_zeroconf_discover_la_SOURCES = modules/module-zeroconf-discover.c
#include <unistd.h>
#include <locale.h>
#include <sys/types.h>
+ #include <sys/stat.h>
#include <liboil/liboil.h>
#include "dumpmodules.h"
#include "caps.h"
#include "ltdl-bind-now.h"
+#include "server-lookup.h"
#ifdef HAVE_LIBWRAP
/* Only one instance of these variables */
#endif
#ifdef HAVE_DBUS
-static pa_dbus_connection *register_dbus(pa_core *c) {
+static pa_dbus_connection *register_dbus_name(pa_core *c, DBusBusType bus, const char* name) {
DBusError error;
pa_dbus_connection *conn;
dbus_error_init(&error);
- if (!(conn = pa_dbus_bus_get(c, pa_in_system_mode() ? DBUS_BUS_SYSTEM : DBUS_BUS_SESSION, &error)) || dbus_error_is_set(&error)) {
+ if (!(conn = pa_dbus_bus_get(c, bus, &error)) || dbus_error_is_set(&error)) {
pa_log_warn("Unable to contact D-Bus: %s: %s", error.name, error.message);
goto fail;
}
- if (dbus_bus_request_name(pa_dbus_connection_get(conn), "org.pulseaudio.Server", DBUS_NAME_FLAG_DO_NOT_QUEUE, &error) == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
- pa_log_debug("Got org.pulseaudio.Server!");
+ if (dbus_bus_request_name(pa_dbus_connection_get(conn), name, DBUS_NAME_FLAG_DO_NOT_QUEUE, &error) == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+ pa_log_debug("Got %s!", name);
return conn;
}
if (dbus_error_is_set(&error))
- pa_log_warn("Failed to acquire org.pulseaudio.Server: %s: %s", error.name, error.message);
+ pa_log_error("Failed to acquire %s: %s: %s", name, error.name, error.message);
else
- pa_log_warn("D-Bus name org.pulseaudio.Server already taken. Weird shit!");
+ pa_log_error("D-Bus name %s already taken. Weird shit!", name);
/* PA cannot be started twice by the same user and hence we can
- * ignore mostly the case that org.pulseaudio.Server is already
- * taken. */
+ * ignore mostly the case that a name is already taken. */
fail:
-
if (conn)
pa_dbus_connection_unref(conn);
int autospawn_fd = -1;
pa_bool_t autospawn_locked = FALSE;
#ifdef HAVE_DBUS
- pa_dbus_connection *dbus = NULL;
+ pa_dbusobj_server_lookup *server_lookup = NULL; /* /org/pulseaudio/server_lookup */
+ pa_dbus_connection *lookup_service_bus = NULL; /* Always the user bus. */
+ pa_dbus_connection *server_bus = NULL; /* The bus where we reserve org.pulseaudio.Server, either the user or the system bus. */
+ pa_bool_t start_server;
#endif
pa_log_set_ident("pulseaudio");
pa_log_set_flags(PA_LOG_PRINT_TIME, PA_LOG_SET);
pa_log_set_show_backtrace(conf->log_backtrace);
+#ifdef HAVE_DBUS
+ /* conf->system_instance and conf->local_server_type control almost the
+ * same thing; make them agree about what is requested. */
+ switch (conf->local_server_type) {
+ case PA_SERVER_TYPE_UNSET:
+ conf->local_server_type = conf->system_instance ? PA_SERVER_TYPE_SYSTEM : PA_SERVER_TYPE_USER;
+ break;
+ case PA_SERVER_TYPE_USER:
+ case PA_SERVER_TYPE_NONE:
+ conf->system_instance = FALSE;
+ break;
+ case PA_SERVER_TYPE_SYSTEM:
+ conf->system_instance = TRUE;
+ break;
+ default:
+ pa_assert_not_reached();
+ }
+
+ start_server = conf->local_server_type == PA_SERVER_TYPE_USER || (getuid() == 0 && conf->local_server_type == PA_SERVER_TYPE_SYSTEM);
+
+ if (!start_server && conf->local_server_type == PA_SERVER_TYPE_SYSTEM) {
+ pa_log_notice(_("System mode refused for non-root user. Only starting the D-Bus server lookup service."));
+ conf->system_instance = FALSE;
+ }
+#endif
+
LTDL_SET_PRELOADED_SYMBOLS();
pa_ltdl_init();
ltdl_init = TRUE;
if (getuid() == 0 && !conf->system_instance)
pa_log_warn(_("This program is not intended to be run as root (unless --system is specified)."));
+#ifndef HAVE_DBUS /* A similar, only a notice worthy check was done earlier, if D-Bus is enabled. */
else if (getuid() != 0 && conf->system_instance) {
pa_log(_("Root privileges required."));
goto finish;
}
+#endif
if (conf->cmd == PA_CMD_START && conf->system_instance) {
pa_log(_("--start not supported for system instances."));
c->running_as_daemon = !!conf->daemonize;
c->disallow_exit = conf->disallow_exit;
c->flat_volumes = conf->flat_volumes;
+#ifdef HAVE_DBUS
+ c->server_type = conf->local_server_type;
+#endif
pa_assert_se(pa_signal_init(pa_mainloop_get_api(mainloop)) == 0);
pa_signal_new(SIGINT, signal_callback, c);
pa_assert_se(pa_cpu_limit_init(pa_mainloop_get_api(mainloop)) == 0);
buf = pa_strbuf_new();
- if (conf->load_default_script_file) {
- FILE *f;
- if ((f = pa_daemon_conf_open_default_script_file(conf))) {
- r = pa_cli_command_execute_file_stream(c, f, buf, &conf->fail);
- fclose(f);
+#ifdef HAVE_DBUS
+ if (start_server) {
+#endif
+ if (conf->load_default_script_file) {
+ FILE *f;
+
+ if ((f = pa_daemon_conf_open_default_script_file(conf))) {
+ r = pa_cli_command_execute_file_stream(c, f, buf, &conf->fail);
+ fclose(f);
+ }
}
- }
- if (r >= 0)
- r = pa_cli_command_execute(c, conf->script_commands, buf, &conf->fail);
+ if (r >= 0)
+ r = pa_cli_command_execute(c, conf->script_commands, buf, &conf->fail);
- pa_log_error("%s", s = pa_strbuf_tostring_free(buf));
- pa_xfree(s);
+ pa_log_error("%s", s = pa_strbuf_tostring_free(buf));
+ pa_xfree(s);
- /* We completed the initial module loading, so let's disable it
- * from now on, if requested */
- c->disallow_module_loading = !!conf->disallow_module_loading;
+ if (r < 0 && conf->fail) {
+ pa_log(_("Failed to initialize daemon."));
+ goto finish;
+ }
- if (r < 0 && conf->fail) {
- pa_log(_("Failed to initialize daemon."));
- goto finish;
+ if (!c->modules || pa_idxset_size(c->modules) == 0) {
+ pa_log(_("Daemon startup without any loaded modules, refusing to work."));
+ goto finish;
+ }
+#ifdef HAVE_DBUS
+ } else {
+ /* When we just provide the D-Bus server lookup service, we don't want
+ * any modules to be loaded. We haven't loaded any so far, so one might
+ * think there's no way to contact the server, but receiving certain
+ * signals could still cause modules to load. */
+ conf->disallow_module_loading = TRUE;
}
+#endif
- if (!c->modules || pa_idxset_size(c->modules) == 0) {
- pa_log(_("Daemon startup without any loaded modules, refusing to work."));
- goto finish;
- }
+ /* We completed the initial module loading, so let's disable it
+ * from now on, if requested */
+ c->disallow_module_loading = !!conf->disallow_module_loading;
#ifdef HAVE_FORK
if (daemon_pipe[1] >= 0) {
#endif
#ifdef HAVE_DBUS
- dbus = register_dbus(c);
+ if (!conf->system_instance) {
+ if (!(server_lookup = pa_dbusobj_server_lookup_new(c)))
+ goto finish;
+ if (!(lookup_service_bus = register_dbus_name(c, DBUS_BUS_SESSION, "org.pulseaudio.PulseAudio")))
+ goto finish;
+ }
+
+ if (start_server && !(server_bus = register_dbus_name(c, conf->system_instance ? DBUS_BUS_SYSTEM : DBUS_BUS_SESSION, "org.pulseaudio.Server")))
+ goto finish;
#endif
pa_log_info(_("Daemon startup complete."));
finish:
#ifdef HAVE_DBUS
- if (dbus)
- pa_dbus_connection_unref(dbus);
+ if (server_bus)
+ pa_dbus_connection_unref(server_bus);
+ if (lookup_service_bus)
+ pa_dbus_connection_unref(lookup_service_bus);
+ if (server_lookup)
+ pa_dbusobj_server_lookup_free(server_lookup);
#endif
if (autospawn_fd >= 0) {