+2003-03-31 Havoc Pennington <hp@pobox.com>
+
+ * dbus/dbus-transport-unix.c (_dbus_transport_new_for_domain_socket)
+ (_dbus_transport_new_for_tcp_socket): these didn't need the "server"
+ argument since they are always client side
+
+ * dbus/dbus-server.c (dbus_server_get_address): new function
+
+ * bus/main.c (main): take the configuration file as an argument.
+
+ * test/data/valid-config-files/debug-allow-all.conf: new file to
+ use with dispatch.c tests for example
+
+ * bus/test-main.c (main): require test data dir
+
+ * bus/bus.c (bus_context_new): change this to take a
+ configuration file name as argument
+
+ * doc/config-file.txt (Elements): add <servicedir>
+
+ * bus/system.conf, bus/session.conf: new files
+
+ * dbus/dbus-bus.c (dbus_bus_get): look for system bus on
+ well-known socket if none set
+
+ * configure.in: create system.conf and session.conf
+
2003-03-30 Havoc Pennington <hp@pobox.com>
* bus/config-parser.c: hacking
EFENCE=
+configdir=$(sysconfdir)/dbus-1
+
+config_DATA= \
+ system.conf \
+ session.conf
+
bin_PROGRAMS=dbus-daemon-1
if DBUS_USE_LIBXML
}
BusActivation*
-bus_activation_new (BusContext *context,
- const char *address,
- const char **directories,
- DBusError *error)
+bus_activation_new (BusContext *context,
+ const DBusString *address,
+ const char **directories,
+ DBusError *error)
{
int i;
BusActivation *activation;
activation->refcount = 1;
activation->context = context;
- /* FIXME: We should split up the server addresses. */
- activation->server_address = _dbus_strdup (address);
- if (activation->server_address == NULL)
+ if (!_dbus_string_copy_data (address, &activation->server_address))
{
BUS_SET_OOM (error);
goto failed;
#include <dbus/dbus.h>
#include "bus.h"
-BusActivation* bus_activation_new (BusContext *context,
- const char *address,
- const char **paths,
- DBusError *error);
-void bus_activation_ref (BusActivation *activation);
-void bus_activation_unref (BusActivation *activation);
-dbus_bool_t bus_activation_activate_service (BusActivation *activation,
- DBusConnection *connection,
- DBusMessage *activation_message,
- const char *service_name,
- DBusError *error);
-dbus_bool_t bus_activation_service_created (BusActivation *activation,
- const char *service_name,
- DBusError *error);
+BusActivation* bus_activation_new (BusContext *context,
+ const DBusString *address,
+ const char **paths,
+ DBusError *error);
+void bus_activation_ref (BusActivation *activation);
+void bus_activation_unref (BusActivation *activation);
+dbus_bool_t bus_activation_activate_service (BusActivation *activation,
+ DBusConnection *connection,
+ DBusMessage *activation_message,
+ const char *service_name,
+ DBusError *error);
+dbus_bool_t bus_activation_service_created (BusActivation *activation,
+ const char *service_name,
+ DBusError *error);
+
#endif /* BUS_ACTIVATION_H */
#include "services.h"
#include "utils.h"
#include "policy.h"
+#include "config-parser.h"
#include <dbus/dbus-list.h>
#include <dbus/dbus-hash.h>
#include <dbus/dbus-internals.h>
{
int refcount;
char *address;
- DBusServer *server;
+ DBusList *servers;
BusConnections *connections;
BusActivation *activation;
BusRegistry *registry;
unsigned int condition,
void *data)
{
- BusContext *context = data;
+ DBusServer *server = data;
- return dbus_server_handle_watch (context->server, watch, condition);
+ return dbus_server_handle_watch (server, watch, condition);
}
static dbus_bool_t
add_server_watch (DBusWatch *watch,
- BusContext *context)
+ void *data)
{
- return bus_loop_add_watch (watch, server_watch_callback, context,
+ return bus_loop_add_watch (watch, server_watch_callback, data,
NULL);
}
static void
remove_server_watch (DBusWatch *watch,
- BusContext *context)
+ void *data)
{
- bus_loop_remove_watch (watch, server_watch_callback, context);
+ bus_loop_remove_watch (watch, server_watch_callback, data);
}
static dbus_bool_t
add_server_timeout (DBusTimeout *timeout,
- BusContext *context)
+ void *data)
{
- return bus_loop_add_timeout (timeout, server_timeout_callback, context, NULL);
+ return bus_loop_add_timeout (timeout, server_timeout_callback, data, NULL);
}
static void
remove_server_timeout (DBusTimeout *timeout,
- BusContext *context)
+ void *data)
{
- bus_loop_remove_timeout (timeout, server_timeout_callback, context);
+ bus_loop_remove_timeout (timeout, server_timeout_callback, data);
}
static void
dbus_free (list);
}
+static dbus_bool_t
+setup_server (BusContext *context,
+ DBusServer *server,
+ DBusError *error)
+{
+ dbus_server_set_new_connection_function (server,
+ new_connection_callback,
+ context, NULL);
+
+ if (!dbus_server_set_watch_functions (server,
+ add_server_watch,
+ remove_server_watch,
+ NULL,
+ server,
+ NULL))
+ {
+ BUS_SET_OOM (error);
+ return FALSE;
+ }
+
+ if (!dbus_server_set_timeout_functions (server,
+ add_server_timeout,
+ remove_server_timeout,
+ NULL,
+ server, NULL))
+ {
+ BUS_SET_OOM (error);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
BusContext*
-bus_context_new (const char *address,
- const char **service_dirs,
- DBusError *error)
+bus_context_new (const DBusString *config_file,
+ DBusError *error)
{
BusContext *context;
-
+ DBusList *link;
+ DBusList **addresses;
+ BusConfigParser *parser;
+ DBusString full_address;
+ const char *service_dirs[] = { NULL, NULL };
+
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
+
+ if (!_dbus_string_init (&full_address, _DBUS_INT_MAX))
+ return NULL;
+
+ parser = NULL;
+ context = NULL;
+
+ parser = bus_config_load (config_file, error);
+ if (parser == NULL)
+ goto failed;
context = dbus_new0 (BusContext, 1);
if (context == NULL)
{
BUS_SET_OOM (error);
- return NULL;
+ goto failed;
}
context->refcount = 1;
+
+ addresses = bus_config_parser_get_addresses (parser);
+
+ link = _dbus_list_get_first_link (addresses);
+ while (link != NULL)
+ {
+ DBusServer *server;
+
+ server = dbus_server_listen (link->data, error);
+ if (server == NULL)
+ goto failed;
+ else if (!setup_server (context, server, error))
+ goto failed;
- context->address = _dbus_strdup (address);
- if (context->address == NULL)
+ if (!_dbus_list_append (&context->servers, server))
+ {
+ BUS_SET_OOM (error);
+ goto failed;
+ }
+
+ link = _dbus_list_get_next_link (addresses, link);
+ }
+
+ /* We have to build the address backward, so that
+ * <listen> later in the config file have priority
+ */
+ link = _dbus_list_get_last_link (&context->servers);
+ while (link != NULL)
+ {
+ char *addr;
+
+ addr = dbus_server_get_address (link->data);
+ if (addr == NULL)
+ {
+ BUS_SET_OOM (error);
+ goto failed;
+ }
+
+ if (_dbus_string_get_length (&full_address) > 0)
+ {
+ if (!_dbus_string_append (&full_address, ";"))
+ {
+ BUS_SET_OOM (error);
+ goto failed;
+ }
+ }
+
+ if (!_dbus_string_append (&full_address, addr))
+ {
+ BUS_SET_OOM (error);
+ goto failed;
+ }
+
+ dbus_free (addr);
+
+ link = _dbus_list_get_prev_link (&context->servers, link);
+ }
+
+ if (!_dbus_string_copy_data (&full_address, &context->address))
{
BUS_SET_OOM (error);
goto failed;
}
- context->server = dbus_server_listen (address, error);
- if (context->server == NULL)
- goto failed;
-
- context->activation = bus_activation_new (context, address, service_dirs,
- error);
+ context->activation = bus_activation_new (context, &full_address,
+ service_dirs, error);
if (context->activation == NULL)
{
_DBUS_ASSERT_ERROR_IS_SET (error);
BUS_SET_OOM (error);
goto failed;
}
-
- dbus_server_set_new_connection_function (context->server,
- new_connection_callback,
- context, NULL);
-
- if (!dbus_server_set_watch_functions (context->server,
- (DBusAddWatchFunction) add_server_watch,
- (DBusRemoveWatchFunction) remove_server_watch,
- NULL,
- context,
- NULL))
- {
- BUS_SET_OOM (error);
- goto failed;
- }
- if (!dbus_server_set_timeout_functions (context->server,
- (DBusAddTimeoutFunction) add_server_timeout,
- (DBusRemoveTimeoutFunction) remove_server_timeout,
- NULL,
- context, NULL))
- {
- BUS_SET_OOM (error);
- goto failed;
- }
+ bus_config_parser_unref (parser);
+ _dbus_string_free (&full_address);
return context;
failed:
- bus_context_unref (context);
+ if (parser != NULL)
+ bus_config_parser_unref (parser);
+
+ if (context != NULL)
+ bus_context_unref (context);
+
+ _dbus_string_free (&full_address);
return NULL;
}
-void
-bus_context_shutdown (BusContext *context)
+static void
+shutdown_server (BusContext *context,
+ DBusServer *server)
{
- if (context->server == NULL ||
- !dbus_server_get_is_connected (context->server))
+ if (server == NULL ||
+ !dbus_server_get_is_connected (server))
return;
- if (!dbus_server_set_watch_functions (context->server,
+ if (!dbus_server_set_watch_functions (server,
NULL, NULL, NULL,
context,
NULL))
_dbus_assert_not_reached ("setting watch functions to NULL failed");
- if (!dbus_server_set_timeout_functions (context->server,
+ if (!dbus_server_set_timeout_functions (server,
NULL, NULL, NULL,
context,
NULL))
_dbus_assert_not_reached ("setting timeout functions to NULL failed");
- dbus_server_disconnect (context->server);
+ dbus_server_disconnect (server);
+}
+
+void
+bus_context_shutdown (BusContext *context)
+{
+ DBusList *link;
+
+ link = _dbus_list_get_first_link (&context->servers);
+ while (link != NULL)
+ {
+ shutdown_server (context, link->data);
+
+ link = _dbus_list_get_next_link (&context->servers, link);
+ }
}
void
if (context->refcount == 0)
{
+ DBusList *link;
+
_dbus_verbose ("Finalizing bus context %p\n", context);
bus_context_shutdown (context);
bus_activation_unref (context->activation);
context->activation = NULL;
}
-
- if (context->server)
+
+ link = _dbus_list_get_first_link (&context->servers);
+ while (link != NULL)
{
- dbus_server_unref (context->server);
- context->server = NULL;
+ dbus_server_unref (link->data);
+
+ link = _dbus_list_get_next_link (&context->servers, link);
}
+ _dbus_list_clear (&context->servers);
if (context->rules_by_uid)
{
typedef struct BusService BusService;
typedef struct BusTransaction BusTransaction;
-BusContext* bus_context_new (const char *address,
- const char **service_dirs,
- DBusError *error);
-void bus_context_shutdown (BusContext *context);
-void bus_context_ref (BusContext *context);
-void bus_context_unref (BusContext *context);
-BusRegistry* bus_context_get_registry (BusContext *context);
-BusConnections* bus_context_get_connections (BusContext *context);
-BusActivation* bus_context_get_activation (BusContext *context);
-dbus_bool_t bus_context_allow_user (BusContext *context,
- unsigned long uid);
-BusPolicy* bus_context_create_connection_policy (BusContext *context,
- DBusConnection *connection);
-
+BusContext* bus_context_new (const DBusString *config_file,
+ DBusError *error);
+void bus_context_shutdown (BusContext *context);
+void bus_context_ref (BusContext *context);
+void bus_context_unref (BusContext *context);
+BusRegistry* bus_context_get_registry (BusContext *context);
+BusConnections* bus_context_get_connections (BusContext *context);
+BusActivation* bus_context_get_activation (BusContext *context);
+dbus_bool_t bus_context_allow_user (BusContext *context,
+ unsigned long uid);
+BusPolicy* bus_context_create_connection_policy (BusContext *context,
+ DBusConnection *connection);
#endif /* BUS_BUS_H */
return FALSE;
}
+
+ if (parser->listen_on == NULL)
+ {
+ dbus_set_error (error, DBUS_ERROR_FAILED,
+ "Configuration file needs one or more <listen> elements giving addresses");
+ return FALSE;
+ }
return TRUE;
}
return parser->user;
}
+DBusList**
+bus_config_parser_get_addresses (BusConfigParser *parser)
+{
+ return &parser->listen_on;
+}
+
#ifdef DBUS_BUILD_TESTS
#include <stdio.h>
#include <dbus/dbus.h>
#include <dbus/dbus-string.h>
+#include <dbus/dbus-list.h>
/* Whatever XML library we're using just pushes data into this API */
/* Functions for extracting the parse results */
const char* bus_config_parser_get_user (BusConfigParser *parser);
-
+DBusList** bus_config_parser_get_addresses (BusConfigParser *parser);
/* Loader functions (backended off one of the XML parsers). Returns a
* finished ConfigParser.
bus_dispatch_test (const DBusString *test_data_dir)
{
BusContext *context;
- DBusError error;
- const char *activation_dirs[] = { NULL, NULL };
DBusConnection *foo;
DBusConnection *bar;
DBusConnection *baz;
+ DBusError error;
+
+ context = bus_context_new_test (test_data_dir,
+ "valid-config-files/debug-allow-all.conf");
+ if (context == NULL)
+ return FALSE;
dbus_error_init (&error);
- context = bus_context_new ("debug-pipe:name=test-server",
- activation_dirs,
- &error);
- if (context == NULL)
- _dbus_assert_not_reached ("could not alloc context");
foo = dbus_connection_open ("debug-pipe:name=test-server", &error);
if (foo == NULL)
{
BusContext *context;
DBusError error;
- const char *paths[] = { NULL, NULL };
+ DBusString config_file;
+
+ /* FIXME I think the arguments should be like:
+ * --system use standard system config file
+ * --session use standard session config file
+ * --config-file=foo.conf use some other file
+ */
- if (argc < 3)
+ if (argc != 2)
{
- /* FIXME obviously just for testing */
- _dbus_warn ("Give the server address as an argument and activation directory as args\n");
+ _dbus_warn ("The message bus configuration file must be given as the only argument\n");
return 1;
}
-
- paths[0] = argv[2];
dbus_error_init (&error);
- context = bus_context_new (argv[1], paths, &error);
+ _dbus_string_init_const (&config_file, argv[1]);
+ context = bus_context_new (&config_file, &error);
if (context == NULL)
{
_dbus_warn ("Failed to start message bus: %s\n",
bus_context_shutdown (context);
bus_context_unref (context);
-
+
return 0;
}
--- /dev/null
+<!-- This configuration file controls the per-user-login-session message bus.
+ Add a session-local.conf and edit that rather than changing this
+ file directly. -->
+
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <!-- FIXME - this is fairly complicated to fix.
+ Propose the following:
+ - add "unix:tmpdir=/tmp" which means unix domain transport
+ creates a socket with a random secure name
+ - add dbus_server_get_address() that gets the actual
+ server address
+ - add command line option or env variable to the daemon
+ causing it to print its list of addresses to a given
+ file descriptor
+ - session manager or whatever launches the session bus
+ reads the address from there and sets the env variable
+ -->
+ <listen>unix:path=/tmp/foobar</listen>
+ <policy context="default">
+ <!-- Allow everything -->
+ <allow send="*"/>
+ <allow receive="*"/>
+ <allow own="*"/>
+ </policy>
+
+ <!-- This is included last so local configuration can override what's
+ in this standard file -->
+ <include ignore_missing="yes">session-local.conf</include>
+</busconfig>
--- /dev/null
+<!-- This configuration file controls the systemwide message bus.
+ Add a system-local.conf and edit that rather than changing this
+ file directly. -->
+
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <user>fixme</user>
+ <listen>unix:path=@EXPANDED_LOCALSTATEDIR@/@DBUS_SYSTEM_SOCKET@</listen>
+ <policy context="default">
+ <!-- Deny everything -->
+ <deny send="*"/>
+ <deny receive="*"/>
+ <deny own="*"/>
+ </policy>
+
+ <!-- This is included last so local configuration can override what's
+ in this standard file -->
+ <include ignore_missing="yes">system-local.conf</include>
+</busconfig>
dir = _dbus_getenv ("DBUS_TEST_DATA");
if (dir == NULL)
- dir = "";
+ {
+ fprintf (stderr, "Must specify test data directory as argv[1] or in DBUS_TEST_DATA env variable\n");
+ return 1;
+ }
_dbus_string_init_const (&test_data_dir, dir);
;
}
+BusContext*
+bus_context_new_test (const DBusString *test_data_dir,
+ const char *filename)
+{
+ DBusError error;
+ DBusString config_file;
+ DBusString relative;
+ BusContext *context;
+
+ if (!_dbus_string_init (&config_file, _DBUS_INT_MAX))
+ {
+ _dbus_warn ("No memory\n");
+ return NULL;
+ }
+
+ if (!_dbus_string_copy (test_data_dir, 0,
+ &config_file, 0))
+ {
+ _dbus_warn ("No memory\n");
+ _dbus_string_free (&config_file);
+ return NULL;
+ }
+
+ _dbus_string_init_const (&relative, filename);
+
+ if (!_dbus_concat_dir_and_file (&config_file, &relative))
+ {
+ _dbus_warn ("No memory\n");
+ _dbus_string_free (&config_file);
+ return NULL;
+ }
+
+ dbus_error_init (&error);
+ context = bus_context_new (&config_file, &error);
+ if (context == NULL)
+ {
+ _DBUS_ASSERT_ERROR_IS_SET (&error);
+
+ _dbus_warn ("Failed to create debug bus context from configuration file %s: %s\n",
+ filename, error.message);
+
+ dbus_error_free (&error);
+
+ _dbus_string_free (&config_file);
+
+ return NULL;
+ }
+
+ _dbus_string_free (&config_file);
+
+ return context;
+}
+
#endif
dbus_bool_t bus_test_client_listed (DBusConnection *connection);
void bus_test_flush_bus (BusContext *context);
+BusContext* bus_context_new_test (const DBusString *test_data_dir,
+ const char *filename);
+
#endif
#endif /* BUS_TEST_H */
{
#ifdef DBUS_BUILD_TESTS
/* make tests go fast */
- return 10;
+ return 0;
#else
return 500;
#endif
AC_DEFINE(DBUS_DISABLE_ASSERT,1,[Disable assertion checking])
fi
+#### gcc warning flags
+
if test "x$GCC" = "xyes"; then
changequote(,)dnl
case " $CFLAGS " in
fi
fi
+#### Assorted checks
+
AC_CHECK_SIZEOF(char)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(long)
AC_SUBST(DBUS_QT_CXXFLAGS)
AC_SUBST(DBUS_QT_LIBS)
+##### Set up location for system bus socket
+## name of socket relative to localstatedir
+DBUS_SYSTEM_SOCKET=run/dbus/system_bus_socket
+AC_SUBST(DBUS_SYSTEM_SOCKET)
+
+#### find the actual value for $prefix that we'll end up with
+REAL_PREFIX=
+if test "x$prefix" = "xNONE"; then
+ REAL_PREFIX=$ac_default_prefix
+else
+ REAL_PREFIX=$prefix
+fi
+
+#### Have to go $localstatedir->$prefix/var->/usr/local/var
+#### someone please fix this a better way...
+LOCALSTATEDIR_TMP="$localstatedir"
+old_prefix=$prefix
+prefix=$REAL_PREFIX
+EXPANDED_LOCALSTATEDIR=`eval echo $LOCALSTATEDIR_TMP`
+prefix=$old_prefix
+AC_SUBST(EXPANDED_LOCALSTATEDIR)
+
AC_OUTPUT([
-Makefile
Doxyfile
+bus/system.conf
+bus/session.conf
+Makefile
dbus/Makefile
glib/Makefile
qt/Makefile
Building Qt bindings: ${have_qt}
Building GLib bindings: ${have_glib}
Using XML parser: ${with_xml}
+ System bus socket: ${EXPANDED_LOCALSTATEDIR}/${DBUS_SYSTEM_SOCKET}
"
if test x$enable_tests = xyes; then
- echo "NOTE: building with unit tests increases the size of the installed library and renders it insecure"
+ echo "NOTE: building with unit tests increases the size of the installed library and renders it insecure."
fi
if test x$enable_gcov = xyes; then
- echo "NOTE: building with coverage profiling is definitely for developers only"
+ echo "NOTE: building with coverage profiling is definitely for developers only."
fi
if test x$enable_verbose_mode = xyes; then
- echo "NOTE: building with verbose mode increases library size and may slightly increase security risk, but aids debugging."
+ echo "NOTE: building with verbose mode increases library size, may slightly increase security risk, and may cause a slight performance decrease, but aids debugging."
fi
if test x$enable_asserts = xyes; then
- echo "NOTE: building with assertions increases library size, but is probably a good idea anyway."
+ echo "NOTE: building with assertions increases library size, but will help a lot when tracking down bugs in software using D-BUS."
fi
-INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) -DDBUS_COMPILATION
+INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) -DDBUS_COMPILATION \
+ -DDBUS_SYSTEM_BUS_PATH=\""$(localstatedir)/@DBUS_SYSTEM_SOCKET@"\"
dbusincludedir=$(includedir)/dbus-1.0/dbus
value = _dbus_getenv (name);
- if (!value)
+ if (type == DBUS_BUS_SYSTEM &&
+ (value == NULL || *value == '\0'))
+ {
+ /* Use default system bus address if none set */
+ value = "unix:path=" DBUS_SYSTEM_BUS_PATH;
+ }
+
+ if (value == NULL || *value == '\0')
{
dbus_set_error (error, DBUS_ERROR_FAILED,
- "Could not get bus daemon address.");
+ "Environment variable %s not set, address of message bus unknown",
+ name);
_DBUS_UNLOCK (bus);
return NULL;
DBusError *error)
{
DBusServerDebugPipe *debug_server;
-
+ DBusString address;
+
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
if (!pipe_hash_ref ())
}
debug_server = dbus_new0 (DBusServerDebugPipe, 1);
-
if (debug_server == NULL)
- {
- pipe_hash_unref ();
- return NULL;
- }
+ goto nomem_0;
+
+ if (!_dbus_string_init (&address, _DBUS_INT_MAX))
+ goto nomem_1;
+ if (!_dbus_string_append (&address, "debug-pipe:name=") ||
+ !_dbus_string_append (&address, server_name))
+ goto nomem_2;
+
debug_server->name = _dbus_strdup (server_name);
if (debug_server->name == NULL)
- {
- dbus_free (debug_server->name);
- dbus_free (debug_server);
-
- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
-
- pipe_hash_unref ();
- return NULL;
- }
+ goto nomem_2;
if (!_dbus_server_init_base (&debug_server->base,
- &debug_vtable))
- {
- dbus_free (debug_server->name);
- dbus_free (debug_server);
-
- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
-
- pipe_hash_unref ();
- return NULL;
- }
+ &debug_vtable, &address))
+ goto nomem_3;
if (!_dbus_hash_table_insert_string (server_pipe_hash,
debug_server->name,
debug_server))
- {
- _dbus_server_finalize_base (&debug_server->base);
- dbus_free (debug_server->name);
- dbus_free (debug_server);
+ goto nomem_4;
- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ _dbus_string_free (&address);
- pipe_hash_unref ();
- return NULL;
- }
+ /* server keeps the pipe hash ref */
return (DBusServer *)debug_server;
+
+ nomem_4:
+ _dbus_server_finalize_base (&debug_server->base);
+ nomem_3:
+ dbus_free (debug_server->name);
+ nomem_2:
+ _dbus_string_free (&address);
+ nomem_1:
+ dbus_free (debug_server);
+ nomem_0:
+ pipe_hash_unref ();
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ return NULL;
}
/**
DBusConnection *connection;
int client_fd, server_fd;
DBusServer *server;
-
+ DBusString address;
+
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
server = _dbus_hash_table_lookup_string (server_pipe_hash,
dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS, NULL);
return NULL;
}
+
+ if (!_dbus_string_init (&address, _DBUS_INT_MAX))
+ {
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ return NULL;
+ }
+
+ if (!_dbus_string_append (&address, "debug-pipe:name=") ||
+ !_dbus_string_append (&address, server_name))
+ {
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ _dbus_string_free (&address);
+ return NULL;
+ }
if (!_dbus_full_duplex_pipe (&client_fd, &server_fd,
NULL))
{
_dbus_verbose ("failed to create full duplex pipe\n");
dbus_set_error (error, DBUS_ERROR_FAILED, "Could not create full-duplex pipe");
+ _dbus_string_free (&address);
return NULL;
}
_dbus_fd_set_close_on_exec (server_fd);
client_transport = _dbus_transport_new_for_fd (client_fd,
- FALSE);
+ FALSE, &address);
if (client_transport == NULL)
{
_dbus_close (client_fd, NULL);
_dbus_close (server_fd, NULL);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ _dbus_string_free (&address);
return NULL;
}
+ _dbus_string_free (&address);
+
client_fd = -1;
server_transport = _dbus_transport_new_for_fd (server_fd,
- TRUE);
+ TRUE, NULL);
if (server_transport == NULL)
{
_dbus_transport_unref (client_transport);
DBusError *error)
{
DBusServerDebug *debug_server;
-
+ DBusString address;
+
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
if (!server_hash)
if (debug_server == NULL)
return NULL;
+ if (!_dbus_string_init (&address, _DBUS_INT_MAX))
+ goto nomem_0;
+
+ if (!_dbus_string_append (&address, "debug:name=") ||
+ !_dbus_string_append (&address, server_name))
+ goto nomem_1;
+
debug_server->name = _dbus_strdup (server_name);
if (debug_server->name == NULL)
- {
- dbus_free (debug_server->name);
- dbus_free (debug_server);
-
- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
- }
+ goto nomem_1;
if (!_dbus_server_init_base (&debug_server->base,
- &debug_vtable))
- {
- dbus_free (debug_server->name);
- dbus_free (debug_server);
-
- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
-
- return NULL;
- }
+ &debug_vtable,
+ &address))
+ goto nomem_2;
if (!_dbus_hash_table_insert_string (server_hash,
debug_server->name,
debug_server))
- {
- _dbus_server_finalize_base (&debug_server->base);
- dbus_free (debug_server->name);
- dbus_free (debug_server);
+ goto nomem_3;
- dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
-
- return NULL;
- }
+ _dbus_string_free (&address);
return (DBusServer *)debug_server;
+
+ nomem_3:
+ _dbus_server_finalize_base (&debug_server->base);
+ nomem_2:
+ dbus_free (debug_server->name);
+ nomem_1:
+ _dbus_string_free (&address);
+ nomem_0:
+ dbus_free (debug_server);
+
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+
+ return NULL;
}
typedef struct
* to this server
*/
+ char *address; /**< Address this server is listening on. */
+
int max_connections; /**< Max number of connections allowed at once. */
DBusDataSlotList slot_list; /**< Data stored by allocated integer ID */
};
dbus_bool_t _dbus_server_init_base (DBusServer *server,
- const DBusServerVTable *vtable);
+ const DBusServerVTable *vtable,
+ const DBusString *address);
void _dbus_server_finalize_base (DBusServer *server);
dbus_bool_t _dbus_server_add_watch (DBusServer *server,
DBusWatch *watch);
if (!_dbus_set_fd_nonblocking (client_fd, NULL))
return TRUE;
- transport = _dbus_transport_new_for_fd (client_fd, TRUE);
+ transport = _dbus_transport_new_for_fd (client_fd, TRUE, NULL);
if (transport == NULL)
{
close (client_fd);
* accept new client connections.
*
* @param fd the file descriptor.
+ * @param address the server's address
* @returns the new server, or #NULL if no memory.
*
*/
DBusServer*
-_dbus_server_new_for_fd (int fd)
+_dbus_server_new_for_fd (int fd,
+ const DBusString *address)
{
DBusServerUnix *unix_server;
DBusWatch *watch;
}
if (!_dbus_server_init_base (&unix_server->base,
- &unix_vtable))
+ &unix_vtable, address))
{
_dbus_watch_unref (watch);
dbus_free (unix_server);
{
DBusServer *server;
int listen_fd;
-
+ DBusString address;
+
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
+
+ if (!_dbus_string_init (&address, _DBUS_INT_MAX))
+ {
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ return NULL;
+ }
+
+ if (!_dbus_string_append (&address, "unix:path=") ||
+ !_dbus_string_append (&address, path))
+ {
+ _dbus_string_free (&address);
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ return NULL;
+ }
listen_fd = _dbus_listen_unix_socket (path, error);
_dbus_fd_set_close_on_exec (listen_fd);
if (listen_fd < 0)
- return NULL;
+ {
+ _dbus_string_free (&address);
+ return NULL;
+ }
- server = _dbus_server_new_for_fd (listen_fd);
+ server = _dbus_server_new_for_fd (listen_fd, &address);
if (server == NULL)
{
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
close (listen_fd);
+ _dbus_string_free (&address);
return NULL;
}
+ _dbus_string_free (&address);
+
return server;
}
{
DBusServer *server;
int listen_fd;
-
+ DBusString address;
+
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
+
+ if (!_dbus_string_init (&address, _DBUS_INT_MAX))
+ {
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ return NULL;
+ }
+
+ if (!_dbus_string_append (&address, "tcp:host=") ||
+ !_dbus_string_append (&address, host) ||
+ !_dbus_string_append (&address, ",port=") ||
+ !_dbus_string_append_int (&address, port))
+ {
+ _dbus_string_free (&address);
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ return NULL;
+ }
listen_fd = _dbus_listen_tcp_socket (host, port, error);
_dbus_fd_set_close_on_exec (listen_fd);
if (listen_fd < 0)
- return NULL;
+ {
+ _dbus_string_free (&address);
+ return NULL;
+ }
- server = _dbus_server_new_for_fd (listen_fd);
+ server = _dbus_server_new_for_fd (listen_fd, &address);
if (server == NULL)
{
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
close (listen_fd);
+ _dbus_string_free (&address);
return NULL;
}
+ _dbus_string_free (&address);
+
return server;
DBUS_BEGIN_DECLS;
-DBusServer* _dbus_server_new_for_fd (int fd);
-DBusServer* _dbus_server_new_for_domain_socket (const char *path,
- DBusError *error);
-DBusServer* _dbus_server_new_for_tcp_socket (const char *host,
- dbus_uint32_t port,
- DBusError *error);
+DBusServer* _dbus_server_new_for_fd (int fd,
+ const DBusString *address);
+DBusServer* _dbus_server_new_for_domain_socket (const char *path,
+ DBusError *error);
+DBusServer* _dbus_server_new_for_tcp_socket (const char *host,
+ dbus_uint32_t port,
+ DBusError *error);
+
DBUS_END_DECLS;
*
* @param server the server.
* @param vtable the vtable for the subclass.
+ * @param address the server's address
* @returns #TRUE on success.
*/
dbus_bool_t
_dbus_server_init_base (DBusServer *server,
- const DBusServerVTable *vtable)
+ const DBusServerVTable *vtable,
+ const DBusString *address)
{
server->vtable = vtable;
server->refcount = 1;
+ server->address = NULL;
+ server->watches = NULL;
+ server->timeouts = NULL;
+ server->connection_counter = NULL;
+
+ if (!_dbus_string_copy_data (address, &server->address))
+ goto failed;
+
server->watches = _dbus_watch_list_new ();
if (server->watches == NULL)
- return FALSE;
+ goto failed;
server->timeouts = _dbus_timeout_list_new ();
if (server->timeouts == NULL)
- {
- _dbus_watch_list_free (server->watches);
- server->watches = NULL;
- return FALSE;
- }
+ goto failed;
server->connection_counter = _dbus_counter_new ();
if (server->connection_counter == NULL)
+ goto failed;
+
+ server->max_connections = 256; /* same as an X server, seems like a nice default */
+
+ _dbus_data_slot_list_init (&server->slot_list);
+
+ _dbus_verbose ("Initialized server on address %s\n", server->address);
+
+ return TRUE;
+
+ failed:
+ if (server->watches)
{
_dbus_watch_list_free (server->watches);
server->watches = NULL;
+ }
+ if (server->timeouts)
+ {
_dbus_timeout_list_free (server->timeouts);
server->timeouts = NULL;
-
- return FALSE;
}
-
- server->max_connections = 256; /* same as an X server, seems like a nice default */
-
- _dbus_data_slot_list_init (&server->slot_list);
+ if (server->connection_counter)
+ {
+ _dbus_counter_unref (server->connection_counter);
+ server->connection_counter = NULL;
+ }
+ if (server->address)
+ {
+ dbus_free (server->address);
+ server->address = NULL;
+ }
- return TRUE;
+ return FALSE;
}
/**
_dbus_watch_list_free (server->watches);
_dbus_timeout_list_free (server->timeouts);
_dbus_counter_unref (server->connection_counter);
+
+ dbus_free (server->address);
}
/**
}
/**
+ * Returns the address of the server, as a newly-allocated
+ * string which must be freed by the caller.
+ *
+ * @param server the server
+ * @returns the address or #NULL if no memory
+ */
+char*
+dbus_server_get_address (DBusServer *server)
+{
+ return _dbus_strdup (server->address);
+}
+
+/**
* Sets a function to be used for handling new connections. The given
* function is passed each new connection as the connection is
* created. If the new connection function increments the connection's
void dbus_server_unref (DBusServer *server);
void dbus_server_disconnect (DBusServer *server);
dbus_bool_t dbus_server_get_is_connected (DBusServer *server);
+char* dbus_server_get_address (DBusServer *server);
void dbus_server_set_new_connection_function (DBusServer *server,
DBusNewConnectionFunction function,
void *data,
if (!_dbus_transport_init_base (&debug_transport->base,
&debug_vtable,
- TRUE))
+ TRUE, NULL))
{
dbus_free (debug_transport);
return NULL;
{
DBusServer *debug_server;
DBusTransportDebug *debug_transport;
-
+ DBusString address;
+
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
debug_server = _dbus_server_debug_lookup (server_name);
return NULL;
}
+ if (!_dbus_string_init (&address, _DBUS_INT_MAX))
+ {
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ return NULL;
+ }
+
+ if (!_dbus_string_append (&address, "debug-pipe:name=") ||
+ !_dbus_string_append (&address, server_name))
+ {
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ _dbus_string_free (&address);
+ return NULL;
+ }
+
debug_transport = dbus_new0 (DBusTransportDebug, 1);
if (debug_transport == NULL)
{
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ _dbus_string_free (&address);
return NULL;
}
if (!_dbus_transport_init_base (&debug_transport->base,
&debug_vtable,
- FALSE))
+ FALSE, &address))
{
dbus_free (debug_transport);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ _dbus_string_free (&address);
return NULL;
}
+
+ _dbus_string_free (&address);
if (!create_timeout_object (debug_transport))
{
DBusCounter *live_messages_size; /**< Counter for size of all live messages. */
+ char *address; /**< Address of this server */
+
DBusAllowUnixUserFunction unix_user_function; /**< Function for checking whether a user is authorized. */
void *unix_user_data; /**< Data for unix_user_function */
DBusFreeFunction free_unix_user_data; /**< Function to free unix_user_data */
dbus_bool_t _dbus_transport_init_base (DBusTransport *transport,
const DBusTransportVTable *vtable,
- dbus_bool_t server);
+ dbus_bool_t server,
+ const DBusString *address);
void _dbus_transport_finalize_base (DBusTransport *transport);
*
* @param fd the file descriptor.
* @param server #TRUE if this transport is on the server side of a connection
+ * @param address the transport's address
* @returns the new transport, or #NULL if no memory.
*/
DBusTransport*
-_dbus_transport_new_for_fd (int fd,
- dbus_bool_t server)
+_dbus_transport_new_for_fd (int fd,
+ dbus_bool_t server,
+ const DBusString *address)
{
DBusTransportUnix *unix_transport;
if (!_dbus_transport_init_base (&unix_transport->base,
&unix_vtable,
- server))
+ server, address))
goto failed_4;
unix_transport->fd = fd;
/**
* Creates a new transport for the given Unix domain socket
- * path.
+ * path. This creates a client-side of a transport.
*
* @param path the path to the domain socket.
- * @param server #TRUE if this transport is on the server side of a connection
* @param error address where an error can be returned.
* @returns a new transport, or #NULL on failure.
*/
DBusTransport*
_dbus_transport_new_for_domain_socket (const char *path,
- dbus_bool_t server,
DBusError *error)
{
int fd;
DBusTransport *transport;
-
+ DBusString address;
+
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
+
+ if (!_dbus_string_init (&address, _DBUS_INT_MAX))
+ {
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ return NULL;
+ }
+
+ if (!_dbus_string_append (&address, "unix:path=") ||
+ !_dbus_string_append (&address, path))
+ {
+ _dbus_string_free (&address);
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ return NULL;
+ }
fd = _dbus_connect_unix_socket (path, error);
if (fd < 0)
{
_DBUS_ASSERT_ERROR_IS_SET (error);
+ _dbus_string_free (&address);
return NULL;
}
_dbus_verbose ("Successfully connected to unix socket %s\n",
path);
-
- transport = _dbus_transport_new_for_fd (fd, server);
+
+ transport = _dbus_transport_new_for_fd (fd, FALSE, &address);
if (transport == NULL)
{
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ _dbus_string_free (&address);
_dbus_close (fd, NULL);
fd = -1;
}
+
+ _dbus_string_free (&address);
return transport;
}
*
* @param host the host to connect to
* @param port the port to connect to
- * @param server #TRUE if this transport is on the server side of a connection
* @param error location to store reason for failure.
* @returns a new transport, or #NULL on failure.
*/
DBusTransport*
_dbus_transport_new_for_tcp_socket (const char *host,
dbus_int32_t port,
- dbus_bool_t server,
DBusError *error)
{
int fd;
DBusTransport *transport;
-
+ DBusString address;
+
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
+
+ if (!_dbus_string_init (&address, _DBUS_INT_MAX))
+ {
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ return NULL;
+ }
+
+ if (!_dbus_string_append (&address, "tcp:host=") ||
+ !_dbus_string_append (&address, host) ||
+ !_dbus_string_append (&address, ",port=") ||
+ !_dbus_string_append_int (&address, port))
+ {
+ _dbus_string_free (&address);
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
+ return NULL;
+ }
fd = _dbus_connect_tcp_socket (host, port, error);
if (fd < 0)
{
_DBUS_ASSERT_ERROR_IS_SET (error);
+ _dbus_string_free (&address);
return NULL;
}
_dbus_verbose ("Successfully connected to tcp socket %s:%d\n",
host, port);
- transport = _dbus_transport_new_for_fd (fd, server);
+ transport = _dbus_transport_new_for_fd (fd, FALSE, &address);
if (transport == NULL)
{
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
_dbus_close (fd, NULL);
+ _dbus_string_free (&address);
fd = -1;
}
+ _dbus_string_free (&address);
+
return transport;
}
DBUS_BEGIN_DECLS;
-DBusTransport* _dbus_transport_new_for_fd (int fd,
- dbus_bool_t server);
-DBusTransport* _dbus_transport_new_for_domain_socket (const char *path,
- dbus_bool_t server,
- DBusError *error);
-DBusTransport* _dbus_transport_new_for_tcp_socket (const char *host,
- dbus_int32_t port,
- dbus_bool_t server,
- DBusError *error);
+DBusTransport* _dbus_transport_new_for_fd (int fd,
+ dbus_bool_t server,
+ const DBusString *address);
+DBusTransport* _dbus_transport_new_for_domain_socket (const char *path,
+ DBusError *error);
+DBusTransport* _dbus_transport_new_for_tcp_socket (const char *host,
+ dbus_int32_t port,
+ DBusError *error);
+
DBUS_END_DECLS;
* @param transport the transport being created.
* @param vtable the subclass vtable.
* @param server #TRUE if this transport is on the server side of a connection
+ * @param address the address of the transport
* @returns #TRUE on success.
*/
dbus_bool_t
_dbus_transport_init_base (DBusTransport *transport,
const DBusTransportVTable *vtable,
- dbus_bool_t server)
+ dbus_bool_t server,
+ const DBusString *address)
{
DBusMessageLoader *loader;
DBusAuth *auth;
DBusCounter *counter;
+ char *address_copy;
loader = _dbus_message_loader_new ();
if (loader == NULL)
_dbus_auth_unref (auth);
_dbus_message_loader_unref (loader);
return FALSE;
+ }
+
+ if (server)
+ {
+ _dbus_assert (address == NULL);
+ address_copy = NULL;
+ }
+ else
+ {
+ _dbus_assert (address != NULL);
+
+ if (!_dbus_string_copy_data (address, &address_copy))
+ {
+ _dbus_counter_unref (counter);
+ _dbus_auth_unref (auth);
+ _dbus_message_loader_unref (loader);
+ return FALSE;
+ }
}
transport->refcount = 1;
transport->send_credentials_pending = !server;
transport->receive_credentials_pending = server;
transport->is_server = server;
-
+ transport->address = address_copy;
+
transport->unix_user_function = NULL;
transport->unix_user_data = NULL;
transport->free_unix_user_data = NULL;
transport->max_live_messages_size,
live_messages_size_notify,
transport);
+
+ if (transport->address)
+ _dbus_verbose ("Initialized transport on address %s\n", transport->address);
return TRUE;
}
_dbus_counter_set_notify (transport->live_messages_size,
0, NULL, NULL);
_dbus_counter_unref (transport->live_messages_size);
+ dbus_free (transport->address);
}
/**
goto bad_address;
}
- transport = _dbus_transport_new_for_domain_socket (path, FALSE, error);
+ transport = _dbus_transport_new_for_domain_socket (path, error);
}
else if (strcmp (method, "tcp") == 0)
{
goto bad_address;
}
- transport = _dbus_transport_new_for_tcp_socket (host, lport, FALSE, error);
+ transport = _dbus_transport_new_for_tcp_socket (host, lport, error);
}
#ifdef DBUS_BUILD_TESTS
else if (strcmp (method, "debug") == 0)
}
/**
+ * Gets the address of a transport. It will be
+ * #NULL for a server-side transport.
+ *
+ * @param transport the transport
+ * @returns transport's address
+ */
+const char*
+_dbus_transport_get_address (DBusTransport *transport)
+{
+ return transport->address;
+}
+
+/**
* Handles a watch by reading data, writing data, or disconnecting
* the transport, as appropriate for the given condition.
*
void _dbus_transport_disconnect (DBusTransport *transport);
dbus_bool_t _dbus_transport_get_is_connected (DBusTransport *transport);
dbus_bool_t _dbus_transport_get_is_authenticated (DBusTransport *transport);
+const char* _dbus_transport_get_address (DBusTransport *transport);
dbus_bool_t _dbus_transport_handle_watch (DBusTransport *transport,
DBusWatch *watch,
unsigned int condition);
EXTRA_DIST= \
+ config-file.txt \
dbus-specification.html \
dbus-specification.sgml \
dbus-test-plan.html \
Example: <listen>unix:path=/tmp/foo</listen>
If there are multiple <listen> elements, then the bus listens
- on multiple addresses.
+ on multiple addresses. The bus will pass its address to
+ activated services or other interested parties with
+ the last address given in <listen> first. That is,
+ apps will try to connect to the last <listen> address first.
<auth>
Example: <auth>EXTERNAL</auth>
Example: <auth>DBUS_COOKIE_SHA1</auth>
+ <servicedir>
+
+ Adds a directory to scan for .service files. Directories are
+ scanned starting with the last to appear in the config file
+ (the first .service file found that provides a particular
+ service will be used).
+
<policy>
context="(default|mandatory)" one of the context/user/group
attributes is mandatory
#bus_test_LDADD=$(TEST_LIBS) $(top_builddir)/bus/libdbus-daemon.la
spawn_test_LDADD=$(TEST_LIBS)
+EXTRA_DIST=fix-standard-tests.sh
+
dist-hook:
- DIRS="data data/valid-messages data/invalid-messages data/incomplete-messages data/auth data/sha-1"; \
+ DIRS="data data/valid-messages data/invalid-messages data/incomplete-messages data/auth data/sha-1 data/valid-config-files"; \
for D in $$DIRS; do \
test -d $(distdir)/$$D || mkdir $(distdir)/$$D ; \
done ; \
- FILES=`find -name "*.message" -o -name "*.message-raw" -o -name "*.auth-script" -o -name "*.sha1" -o -name "*.txt"` ; \
+ FILES=`find -name "*.message" -o -name "*.message-raw" -o -name "*.auth-script" -o -name "*.sha1" -o -name "*.txt" -o -name "*.conf"` ; \
for F in $$FILES; do \
echo '-- Disting file '$$F ; \
cp $$F $(distdir)/$$F ; \
done
+
+
+### we want our standard session.conf and system.conf in the test suite,
+### right now we manually sync copies of them over to the test suite
+### from time to time
+update-standard-tests:
+ cp -f $(top_builddir)/bus/system.conf.in data/valid-config-files/system.conf ; \
+ cp -f $(top_builddir)/bus/session.conf.in data/valid-config-files/session.conf ; \
+ $(srcdir)/fix-standard-tests.sh
--- /dev/null
+<!-- Bus that listens on a debug pipe and doesn't create any restrictions -->
+
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <listen>debug-pipe:name=test-server</listen>
+ <policy context="default">
+ <allow send="*"/>
+ <allow receive="*"/>
+ <allow own="*"/>
+ </policy>
+</busconfig>
--- /dev/null
+<!-- This configuration file controls the per-user-login-session message bus.
+ Add a session-local.conf and edit that rather than changing this
+ file directly. -->
+
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <!-- FIXME - this is fairly complicated to fix.
+ Propose the following:
+ - add "unix:tmpdir=/tmp" which means unix domain transport
+ creates a socket with a random secure name
+ - add dbus_server_get_address() that gets the actual
+ server address
+ - add command line option or env variable to the daemon
+ causing it to print its list of addresses to a given
+ file descriptor
+ - session manager or whatever launches the session bus
+ reads the address from there and sets the env variable
+ -->
+ <listen>unix:path=/tmp/foobar</listen>
+ <policy context="default">
+ <!-- Allow everything -->
+ <allow send="*"/>
+ <allow receive="*"/>
+ <allow own="*"/>
+ </policy>
+
+ <!-- This is included last so local configuration can override what's
+ in this standard file -->
+ <include ignore_missing="yes">session-local.conf</include>
+</busconfig>
--- /dev/null
+<!-- This configuration file controls the systemwide message bus.
+ Add a system-local.conf and edit that rather than changing this
+ file directly. -->
+
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <user>fixme</user>
+ <listen>unix:path=/var/run/dbus/system_bus_socket</listen>
+ <policy context="default">
+ <!-- Deny everything -->
+ <deny send="*"/>
+ <deny receive="*"/>
+ <deny own="*"/>
+ </policy>
+
+ <!-- This is included last so local configuration can override what's
+ in this standard file -->
+ <include ignore_missing="yes">system-local.conf</include>
+</busconfig>
--- /dev/null
+#! /bin/sh
+
+### this script is a lame hack used in the Makefile because
+### I couldn't figure out how to escape @EXPANDED_LOCALSTATEDIR@ etc.
+### inside the Makefile
+
+perl -pi -e "s%\@EXPANDED_LOCALSTATEDIR\@%/var%g" data/valid-config-files/system.conf
+perl -pi -e "s%\@DBUS_SYSTEM_SOCKET\@%run/dbus/system_bus_socket%g" data/valid-config-files/system.conf