? config.cache ? dbus-1.1.1.tar.gz ? test/test-ids ? test/data/valid-config-files/session.d ? test/name-test/run-with-tmp-session-bus.conf ? test/name-test/test-ids Index: ChangeLog =================================================================== RCS file: /cvs/dbus/dbus/ChangeLog,v retrieving revision 1.1332 diff -u -p -r1.1332 ChangeLog --- ChangeLog 18 Jun 2007 18:05:21 -0000 1.1332 +++ ChangeLog 18 Jun 2007 19:31:21 -0000 @@ -1,5 +1,19 @@ 2007-06-18 Havoc Pennington - + + * doc/dbus-specification.xml: document org.freedesktop.DBus.GetId() + + * bus/driver.c (bus_driver_handle_get_id): implement org.freedesktop.DBus.GetId() + + * bus/bus.c (bus_context_new): generate a unique ID for each bus context + + * dbus/dbus-connection.c (dbus_connection_get_server_id): new function + + * dbus/dbus-bus.c (dbus_bus_get_id): new function + + * dbus/dbus-server.c (dbus_server_get_id): new function + +2007-06-18 Havoc Pennington + * dbus/dbus-sysdeps-unix.c (_dbus_read_credentials_socket): clean this up a little bit, to try and understand why telnet'ing to a server and sending a non-nul byte didn't disconnect immediately; Index: bus/bus.c =================================================================== RCS file: /cvs/dbus/dbus/bus/bus.c,v retrieving revision 1.80 diff -u -p -r1.80 bus.c --- bus/bus.c 13 Jun 2007 16:30:43 -0000 1.80 +++ bus/bus.c 18 Jun 2007 19:31:22 -0000 @@ -38,6 +38,7 @@ struct BusContext { int refcount; + DBusGUID uuid; char *config_file; char *type; char *address; @@ -552,6 +553,8 @@ bus_context_new (const DBusString *confi } context->refcount = 1; + _dbus_generate_uuid (&context->uuid); + if (!_dbus_string_copy_data (config_file, &context->config_file)) { BUS_SET_OOM (error); @@ -785,6 +788,13 @@ bus_context_new (const DBusString *confi } dbus_bool_t +bus_context_get_id (BusContext *context, + DBusString *uuid) +{ + return _dbus_uuid_encode (&context->uuid, uuid); +} + +dbus_bool_t bus_context_reload_config (BusContext *context, DBusError *error) { Index: bus/bus.h =================================================================== RCS file: /cvs/dbus/dbus/bus/bus.h,v retrieving revision 1.31 diff -u -p -r1.31 bus.h --- bus/bus.h 9 Jun 2007 23:41:32 -0000 1.31 +++ bus/bus.h 18 Jun 2007 19:31:22 -0000 @@ -78,6 +78,8 @@ dbus_bool_t bus_context_reload_con void bus_context_shutdown (BusContext *context); BusContext* bus_context_ref (BusContext *context); void bus_context_unref (BusContext *context); +dbus_bool_t bus_context_get_id (BusContext *context, + DBusString *uuid); const char* bus_context_get_type (BusContext *context); const char* bus_context_get_address (BusContext *context); BusRegistry* bus_context_get_registry (BusContext *context); Index: bus/dispatch.c =================================================================== RCS file: /cvs/dbus/dbus/bus/dispatch.c,v retrieving revision 1.82 diff -u -p -r1.82 dispatch.c --- bus/dispatch.c 14 Jun 2007 22:02:10 -0000 1.82 +++ bus/dispatch.c 18 Jun 2007 19:31:25 -0000 @@ -4085,7 +4085,7 @@ bus_dispatch_test (const DBusString *tes check2_try_iterations (context, foo, "nonexistent_service_no_auto_start", check_nonexistent_service_no_auto_start); -#ifdef DBUS_WIN_FIXME +#ifdef DBUS_WIN_FIXME _dbus_warn("TODO: dispatch.c segfault_service_no_auto_start test\n"); #else check2_try_iterations (context, foo, "segfault_service_no_auto_start", @@ -4101,7 +4101,7 @@ bus_dispatch_test (const DBusString *tes #ifdef DBUS_WIN_FIXME _dbus_warn("TODO: dispatch.c segfault_service_auto_start test\n"); -#else +#else check2_try_iterations (context, foo, "segfault_service_auto_start", check_segfault_service_auto_start); #endif Index: bus/driver.c =================================================================== RCS file: /cvs/dbus/dbus/bus/driver.c,v retrieving revision 1.79 diff -u -p -r1.79 driver.c --- bus/driver.c 6 Sep 2006 21:16:12 -0000 1.79 +++ bus/driver.c 18 Jun 2007 19:31:26 -0000 @@ -1382,6 +1382,61 @@ bus_driver_handle_reload_config (DBusCon return FALSE; } +static dbus_bool_t +bus_driver_handle_get_id (DBusConnection *connection, + BusTransaction *transaction, + DBusMessage *message, + DBusError *error) +{ + BusContext *context; + DBusMessage *reply; + DBusString uuid; + const char *v_STRING; + + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + if (!_dbus_string_init (&uuid)) + { + BUS_SET_OOM (error); + return FALSE; + } + + reply = NULL; + + context = bus_connection_get_context (connection); + if (!bus_context_get_id (context, &uuid)) + goto oom; + + reply = dbus_message_new_method_return (message); + if (reply == NULL) + goto oom; + + v_STRING = _dbus_string_get_const_data (&uuid); + if (!dbus_message_append_args (reply, + DBUS_TYPE_STRING, &v_STRING, + DBUS_TYPE_INVALID)) + goto oom; + + _dbus_assert (dbus_message_has_signature (reply, "s")); + + if (! bus_transaction_send_from_driver (transaction, connection, reply)) + goto oom; + + _dbus_string_free (&uuid); + dbus_message_unref (reply); + return TRUE; + + oom: + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + BUS_SET_OOM (error); + + if (reply) + dbus_message_unref (reply); + _dbus_string_free (&uuid); + return FALSE; +} + /* For speed it might be useful to sort this in order of * frequency of use (but doesn't matter with only a few items * anyhow) @@ -1396,6 +1451,10 @@ struct DBusMessage *message, DBusError *error); } message_handlers[] = { + { "Hello", + "", + DBUS_TYPE_STRING_AS_STRING, + bus_driver_handle_hello }, { "RequestName", DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_UINT32_AS_STRING, DBUS_TYPE_UINT32_AS_STRING, @@ -1408,10 +1467,6 @@ struct DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_UINT32_AS_STRING, DBUS_TYPE_UINT32_AS_STRING, bus_driver_handle_activate_service }, - { "Hello", - "", - DBUS_TYPE_STRING_AS_STRING, - bus_driver_handle_hello }, { "NameHasOwner", DBUS_TYPE_STRING_AS_STRING, DBUS_TYPE_BOOLEAN_AS_STRING, @@ -1455,7 +1510,11 @@ struct { "ReloadConfig", "", "", - bus_driver_handle_reload_config } + bus_driver_handle_reload_config }, + { "GetId", + "", + DBUS_TYPE_STRING_AS_STRING, + bus_driver_handle_get_id } }; static dbus_bool_t Index: dbus/dbus-bus.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-bus.c,v retrieving revision 1.64 diff -u -p -r1.64 dbus-bus.c --- dbus/dbus-bus.c 28 Oct 2006 01:41:37 -0000 1.64 +++ dbus/dbus-bus.c 18 Jun 2007 19:31:28 -0000 @@ -865,6 +865,85 @@ dbus_bus_get_unix_user (DBusConnection * return (unsigned long) uid; } +/** + * Asks the bus to return its globally unique ID, as described in the + * D-Bus specification. For the session bus, this is useful as a way + * to uniquely identify each user session. For the system bus, + * probably the bus ID is not useful; instead, use the machine ID + * since it's accessible without necessarily connecting to the bus and + * may be persistent beyond a single bus instance (across reboots for + * example). See dbus_get_local_machine_id(). + * + * In addition to an ID for each bus and an ID for each machine, there is + * an ID for each address that the bus is listening on; that can + * be retrieved with dbus_connection_get_server_id(), though it is + * probably not very useful. + * + * @param connection the connection + * @param error location to store the error + * @returns the bus ID or #NULL if error is set + */ +char* +dbus_bus_get_id (DBusConnection *connection, + DBusError *error) +{ + DBusMessage *message, *reply; + char *id; + const char *v_STRING; + + _dbus_return_val_if_fail (connection != NULL, NULL); + _dbus_return_val_if_error_is_set (error, NULL); + + message = dbus_message_new_method_call (DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS, + "GetId"); + + if (message == NULL) + { + _DBUS_SET_OOM (error); + return NULL; + } + + reply = dbus_connection_send_with_reply_and_block (connection, message, -1, + error); + + dbus_message_unref (message); + + if (reply == NULL) + { + _DBUS_ASSERT_ERROR_IS_SET (error); + return NULL; + } + + if (dbus_set_error_from_message (error, reply)) + { + _DBUS_ASSERT_ERROR_IS_SET (error); + dbus_message_unref (reply); + return NULL; + } + + v_STRING = NULL; + if (!dbus_message_get_args (reply, error, + DBUS_TYPE_STRING, &v_STRING, + DBUS_TYPE_INVALID)) + { + _DBUS_ASSERT_ERROR_IS_SET (error); + dbus_message_unref (reply); + return NULL; + } + + id = _dbus_strdup (v_STRING); /* may be NULL */ + + dbus_message_unref (reply); + + if (id == NULL) + _DBUS_SET_OOM (error); + + /* FIXME it might be nice to cache the ID locally */ + + return id; +} /** * Asks the bus to assign the given name to this connection by invoking Index: dbus/dbus-bus.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-bus.h,v retrieving revision 1.21 diff -u -p -r1.21 dbus-bus.h --- dbus/dbus-bus.h 22 Oct 2006 15:03:10 -0000 1.21 +++ dbus/dbus-bus.h 18 Jun 2007 19:31:28 -0000 @@ -49,6 +49,8 @@ const char* dbus_bus_get_unique_name unsigned long dbus_bus_get_unix_user (DBusConnection *connection, const char *name, DBusError *error); +char* dbus_bus_get_id (DBusConnection *connection, + DBusError *error); int dbus_bus_request_name (DBusConnection *connection, const char *name, unsigned int flags, Index: dbus/dbus-connection.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-connection.c,v retrieving revision 1.157 diff -u -p -r1.157 dbus-connection.c --- dbus/dbus-connection.c 18 Jun 2007 16:24:03 -0000 1.157 +++ dbus/dbus-connection.c 18 Jun 2007 19:31:32 -0000 @@ -2845,6 +2845,51 @@ dbus_connection_get_is_anonymous (DBusCo } /** + * Gets the ID of the server address we are authenticated to, if this + * connection is on the client side. If the connection is on the + * server side, this will always return #NULL - use dbus_server_get_id() + * to get the ID of your own server, if you are the server side. + * + * If a client-side connection is not authenticated yet, the ID may be + * available if it was included in the server address, but may not be + * available. The only way to be sure the server ID is available + * is to wait for authentication to complete. + * + * In general, each mode of connecting to a given server will have + * its own ID. So for example, if the session bus daemon is listening + * on UNIX domain sockets and on TCP, then each of those modalities + * will have its own server ID. + * + * If you want an ID that identifies an entire session bus, look at + * dbus_bus_get_id() instead (which is just a convenience wrapper + * around the org.freedesktop.DBus.GetId method invoked on the bus). + * + * You can also get a machine ID; see dbus_get_local_machine_id() to + * get the machine you are on. There isn't a convenience wrapper, but + * you can invoke org.freedesktop.DBus.Peer.GetMachineId on any peer + * to get the machine ID on the other end. + * + * The D-Bus specification describes the server ID and other IDs in a + * bit more detail. + * + * @param connection the connection + * @returns the server ID or #NULL if no memory or the connection is server-side + */ +char* +dbus_connection_get_server_id (DBusConnection *connection) +{ + char *id; + + _dbus_return_val_if_fail (connection != NULL, FALSE); + + CONNECTION_LOCK (connection); + id = _dbus_strdup (_dbus_transport_get_server_id (connection->transport)); + CONNECTION_UNLOCK (connection); + + return id; +} + +/** * Set whether _exit() should be called when the connection receives a * disconnect signal. The call to _exit() comes after any handlers for * the disconnect signal run; handlers can cancel the exit by calling Index: dbus/dbus-connection.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-connection.h,v retrieving revision 1.52 diff -u -p -r1.52 dbus-connection.h --- dbus/dbus-connection.h 18 Jun 2007 16:24:03 -0000 1.52 +++ dbus/dbus-connection.h 18 Jun 2007 19:31:32 -0000 @@ -179,6 +179,7 @@ void dbus_connection_close dbus_bool_t dbus_connection_get_is_connected (DBusConnection *connection); dbus_bool_t dbus_connection_get_is_authenticated (DBusConnection *connection); dbus_bool_t dbus_connection_get_is_anonymous (DBusConnection *connection); +char* dbus_connection_get_server_id (DBusConnection *connection); void dbus_connection_set_exit_on_disconnect (DBusConnection *connection, dbus_bool_t exit_on_disconnect); void dbus_connection_flush (DBusConnection *connection); Index: dbus/dbus-server.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-server.c,v retrieving revision 1.56 diff -u -p -r1.56 dbus-server.c --- dbus/dbus-server.c 24 May 2007 19:15:26 -0000 1.56 +++ dbus/dbus-server.c 18 Jun 2007 19:31:33 -0000 @@ -799,6 +799,43 @@ dbus_server_get_address (DBusServer *ser } /** + * Returns the unique ID of the server, as a newly-allocated + * string which must be freed by the caller. This ID is + * normally used by clients to tell when two #DBusConnection + * would be equivalent (because the server address passed + * to dbus_connection_open() will have the same guid in the + * two cases). dbus_connection_open() can re-use an existing + * connection with the same ID instead of opening a new + * connection. + * + * This is an ID unique to each #DBusServer. Remember that + * a #DBusServer represents only one mode of connecting, + * so e.g. a bus daemon can listen on multiple addresses + * which will mean it has multiple #DBusServer each with + * their own ID. + * + * The ID is not a UUID in the sense of RFC4122; the details + * are explained in the D-Bus specification. + * + * @param server the server + * @returns the id of the server or #NULL if no memory + */ +char* +dbus_server_get_id (DBusServer *server) +{ + char *retval; + + _dbus_return_val_if_fail (server != NULL, NULL); + + SERVER_LOCK (server); + retval = NULL; + _dbus_string_copy_data (&server->guid_hex, &retval); + SERVER_UNLOCK (server); + + return retval; +} + +/** * 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 @@ -1110,6 +1147,7 @@ dbus_server_get_data (DBusServer *serv #ifdef DBUS_BUILD_TESTS #include "dbus-test.h" +#include dbus_bool_t _dbus_server_test (void) @@ -1130,8 +1168,8 @@ _dbus_server_test (void) for (i = 0; i < _DBUS_N_ELEMENTS (valid_addresses); i++) { DBusError error; - - /* FIXME um, how are the two tests here different? */ + char *address; + char *id; dbus_error_init (&error); server = dbus_server_listen (valid_addresses[i], &error); @@ -1142,18 +1180,21 @@ _dbus_server_test (void) _dbus_assert_not_reached ("Failed to listen for valid address."); } - dbus_server_disconnect (server); - dbus_server_unref (server); + id = dbus_server_get_id (server); + _dbus_assert (id != NULL); + address = dbus_server_get_address (server); + _dbus_assert (address != NULL); - /* Try disconnecting before unreffing */ - server = dbus_server_listen (valid_addresses[i], &error); - if (server == NULL) + if (strstr (address, id) == NULL) { - _dbus_warn ("server listen error: %s: %s\n", error.name, error.message); - dbus_error_free (&error); - _dbus_assert_not_reached ("Failed to listen for valid address."); + _dbus_warn ("server id '%s' is not in the server address '%s'\n", + id, address); + _dbus_assert_not_reached ("bad server id or address"); } + dbus_free (id); + dbus_free (address); + dbus_server_disconnect (server); dbus_server_unref (server); } Index: dbus/dbus-server.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-server.h,v retrieving revision 1.20 diff -u -p -r1.20 dbus-server.h --- dbus/dbus-server.h 21 Oct 2006 18:51:30 -0000 1.20 +++ dbus/dbus-server.h 18 Jun 2007 19:31:33 -0000 @@ -55,6 +55,7 @@ void dbus_server_unref void dbus_server_disconnect (DBusServer *server); dbus_bool_t dbus_server_get_is_connected (DBusServer *server); char* dbus_server_get_address (DBusServer *server); +char* dbus_server_get_id (DBusServer *server); void dbus_server_set_new_connection_function (DBusServer *server, DBusNewConnectionFunction function, void *data, Index: dbus/dbus-transport.c =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-transport.c,v retrieving revision 1.59 diff -u -p -r1.59 dbus-transport.c --- dbus/dbus-transport.c 18 Jun 2007 16:24:03 -0000 1.59 +++ dbus/dbus-transport.c 18 Jun 2007 19:31:34 -0000 @@ -792,6 +792,22 @@ _dbus_transport_get_address (DBusTranspo } /** + * Gets the id of the server we are connected to (see + * dbus_server_get_id()). Only works on client side. + * + * @param transport the transport + * @returns transport's server's id or #NULL if we are the server side + */ +const char* +_dbus_transport_get_server_id (DBusTransport *transport) +{ + if (transport->is_server) + return NULL; + else + return transport->expected_guid; +} + +/** * Handles a watch by reading data, writing data, or disconnecting * the transport, as appropriate for the given condition. * Index: dbus/dbus-transport.h =================================================================== RCS file: /cvs/dbus/dbus/dbus/dbus-transport.h,v retrieving revision 1.23 diff -u -p -r1.23 dbus-transport.h --- dbus/dbus-transport.h 12 Jun 2007 18:36:19 -0000 1.23 +++ dbus/dbus-transport.h 18 Jun 2007 19:31:34 -0000 @@ -41,6 +41,7 @@ dbus_bool_t _dbus_transport_get_i dbus_bool_t _dbus_transport_get_is_authenticated (DBusTransport *transport); dbus_bool_t _dbus_transport_get_is_anonymous (DBusTransport *transport); const char* _dbus_transport_get_address (DBusTransport *transport); +const char* _dbus_transport_get_server_id (DBusTransport *transport); dbus_bool_t _dbus_transport_handle_watch (DBusTransport *transport, DBusWatch *watch, unsigned int condition); Index: doc/dbus-specification.xml =================================================================== RCS file: /cvs/dbus/dbus/doc/dbus-specification.xml,v retrieving revision 1.53 diff -u -p -r1.53 dbus-specification.xml --- doc/dbus-specification.xml 14 Jun 2007 09:50:17 -0000 1.53 +++ doc/dbus-specification.xml 18 Jun 2007 19:31:38 -0000 @@ -3824,6 +3824,42 @@ + + <literal>org.freedesktop.DBus.GetId</literal> + + As a method: + + GetId (out STRING id) + + Reply arguments: + + + + + Argument + Type + Description + + + + + 0 + STRING + Unique ID identifying the bus daemon + + + + + Gets the unique ID of the bus. The unique ID here is shared among all addresses the + bus daemon is listening on (TCP, UNIX domain socket, etc.) and its format is described in + . Each address the bus is listening on also has its own unique + ID, as described in . The per-bus and per-address IDs are not related. + There is also a per-machine ID, described in and returned + by org.freedesktop.DBus.Peer.GetMachineId(). + For a desktop session bus, the bus ID can be used as a way to uniquely identify a user's session. + + + Index: test/Makefile.am =================================================================== RCS file: /cvs/dbus/dbus/test/Makefile.am,v retrieving revision 1.45 diff -u -p -r1.45 Makefile.am --- test/Makefile.am 9 Jun 2007 21:53:20 -0000 1.45 +++ test/Makefile.am 18 Jun 2007 19:31:38 -0000 @@ -1,3 +1,5 @@ +## the "name-test" subdir in fact contains a bunch of tests now that need a temporary bus +## to be running to do stuff with. The directory should be renamed. SUBDIRS=name-test DIST_SUBDIRS=name-test @@ -6,9 +8,11 @@ INCLUDES=-I$(top_srcdir) $(DBUS_TEST_CFL if DBUS_BUILD_TESTS ## break-loader removed for now +## most of these binaries are used in tests but are not themselves tests TEST_BINARIES=test-service test-names test-shell-service shell-test spawn-test test-segfault test-exit test-sleep-forever -#enable stand alone make check test +## these are the things to run in make check (i.e. they are actual tests) +## (binaries in here must also be in TEST_BINARIES) TESTS=shell-test else TEST_BINARIES= Index: test/name-test/Makefile.am =================================================================== RCS file: /cvs/dbus/dbus/test/name-test/Makefile.am,v retrieving revision 1.7 diff -u -p -r1.7 Makefile.am --- test/name-test/Makefile.am 26 Oct 2006 18:06:07 -0000 1.7 +++ test/name-test/Makefile.am 18 Jun 2007 19:31:38 -0000 @@ -16,7 +16,7 @@ if DBUS_BUILD_TESTS ## we use noinst_PROGRAMS not check_PROGRAMS for TESTS so that we ## build even when not doing "make check" -noinst_PROGRAMS=test-names test-pending-call-dispatch test-threads-init +noinst_PROGRAMS=test-names test-pending-call-dispatch test-threads-init test-ids test_names_SOURCES= \ test-names.c @@ -36,5 +36,11 @@ test_threads_init_SOURCES = \ test_threads_init_LDADD=$(top_builddir)/dbus/libdbus-convenience.la $(DBUS_TEST_LIBS) test_threads_init_LDFLAGS=@R_DYNAMIC_LDFLAG@ +test_ids_SOURCES = \ + test-ids.c + +test_ids_LDADD=$(top_builddir)/dbus/libdbus-convenience.la $(DBUS_TEST_LIBS) +test_ids_LDFLAGS=@R_DYNAMIC_LDFLAG@ + endif Index: test/name-test/run-test.sh =================================================================== RCS file: /cvs/dbus/dbus/test/name-test/run-test.sh,v retrieving revision 1.5 diff -u -p -r1.5 run-test.sh --- test/name-test/run-test.sh 25 Aug 2006 19:50:16 -0000 1.5 +++ test/name-test/run-test.sh 18 Jun 2007 19:31:38 -0000 @@ -1,6 +1,6 @@ #! /bin/sh -ie() +die() { if ! test -z "$DBUS_SESSION_BUS_PID" ; then echo "killing message bus "$DBUS_SESSION_BUS_PID >&2 @@ -24,11 +24,14 @@ if test -z "$DBUS_TEST_NAME_IN_RUN_TEST" export DBUS_TEST_NAME_IN_RUN_TEST exec $DBUS_TOP_SRCDIR/tools/run-with-tmp-session-bus.sh $SCRIPTNAME $MODE fi +echo "running test-ids" +libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/name-test/test-ids || die "test-ids failed" + echo "running test-names" -libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/name-test/test-names || die "test-client failed" +libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/name-test/test-names || die "test-names failed" echo "running test-pending-call-dispatch" -libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/name-test/test-pending-call-dispatch || die "test-client failed" +libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/name-test/test-pending-call-dispatch || die "test-pending-call-dispatch failed" echo "running test-threads-init" -libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/name-test/test-threads-init || die "test-client failed" +libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/name-test/test-threads-init || die "test-threads-init failed" Index: test/name-test/test-ids.c =================================================================== RCS file: test/name-test/test-ids.c diff -N test/name-test/test-ids.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ test/name-test/test-ids.c 18 Jun 2007 19:31:38 -0000 @@ -0,0 +1,55 @@ +#include +#include +#include +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif + +static void +die (const char *message) +{ + fprintf (stderr, "*** test-ids: %s", message); + exit (1); +} + +int +main (int argc, + char **argv) +{ + DBusError error; + DBusConnection *connection; + char *id; + char *server_id; + + dbus_error_init (&error); + connection = dbus_bus_get (DBUS_BUS_SESSION, &error); + if (connection == NULL) + { + fprintf (stderr, "*** Failed to open connection to system bus: %s\n", + error.message); + dbus_error_free (&error); + return 1; + } + + server_id = dbus_connection_get_server_id (connection); + if (server_id == NULL) + die ("No bus server ID retrieved\n"); + /* printf("'%s'\n", server_id); */ + if (strlen (server_id) != 32) + die ("Bus server id should have length 32\n"); + dbus_free (server_id); + + id = dbus_bus_get_id (connection, NULL); + if (id == NULL) + die ("No bus ID retrieved\n"); + /* printf("'%s'\n", id); */ + if (strlen (id) != 32) + die ("Bus ID should have length 32\n"); + dbus_free (id); + + _dbus_verbose ("*** Test IDs exiting\n"); + + return 0; +}