diff options
| -rw-r--r-- | daemon/echo.c | 7 | ||||
| -rw-r--r-- | hcid/dbus-service.c | 15 | ||||
| -rw-r--r-- | hcid/server.c | 5 | ||||
| -rw-r--r-- | hcid/server.h | 2 | 
4 files changed, 26 insertions, 3 deletions
| diff --git a/daemon/echo.c b/daemon/echo.c index 1fe23727..d6a852e1 100644 --- a/daemon/echo.c +++ b/daemon/echo.c @@ -373,6 +373,7 @@ int main(int argc, char *argv[])  	DBusConnection *system_bus;  	GIOChannel *server_io;  	struct sigaction sa; +	char *addr;  	start_logging("echo", "Bluetooth echo service ver %s", VERSION); @@ -388,6 +389,12 @@ int main(int argc, char *argv[])  	sigaction(SIGCHLD, &sa, NULL);  	sigaction(SIGPIPE, &sa, NULL); +	enable_debug(); + +	addr = getenv("BLUETOOTHD_ADDRESS"); + +	debug("Bluetooth daemon at %s", addr); +  	main_loop = g_main_loop_new(NULL, FALSE);  	system_bus = init_dbus(NULL, NULL, NULL); diff --git a/hcid/dbus-service.c b/hcid/dbus-service.c index 27d4bbad..1fa7a96b 100644 --- a/hcid/dbus-service.c +++ b/hcid/dbus-service.c @@ -43,6 +43,7 @@  #include "dbus-helper.h"  #include "hcid.h"  #include "notify.h" +#include "server.h"  #include "dbus-common.h"  #include "dbus-error.h"  #include "dbus-manager.h" @@ -408,7 +409,7 @@ static gboolean service_startup_timeout(gpointer data)  int service_start(struct service *service, DBusConnection *conn)  {  	DBusError derr; -	char *argv[2], command[PATH_MAX]; +	char *addr, *argv[2], *envp[2], command[PATH_MAX], address[256];  	if (!dbus_connection_add_filter(conn, service_filter, service, NULL)) {  		error("Unable to add signal filter"); @@ -425,11 +426,19 @@ int service_start(struct service *service, DBusConnection *conn)  	}  	snprintf(command, sizeof(command) - 1, "%s/bluetoothd-service-%s", -			SERVICEDIR, service->ident); +						SERVICEDIR, service->ident);  	argv[0] = command;  	argv[1] = NULL; -	if (!g_spawn_async(SERVICEDIR, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD, +	addr = get_local_server_address(); + +	snprintf(address, sizeof(address) - 1, "BLUETOOTHD_ADDRESS=%s", addr); +	envp[0] = address; +	envp[1] = NULL; + +	dbus_free(addr); + +	if (!g_spawn_async(SERVICEDIR, argv, envp, G_SPAWN_DO_NOT_REAP_CHILD,  				service_setup, service, &service->pid, NULL)) {  		error("Unable to execute %s", argv[0]);  		dbus_connection_remove_filter(conn, service_filter, service); diff --git a/hcid/server.c b/hcid/server.c index 702002c7..e055efff 100644 --- a/hcid/server.c +++ b/hcid/server.c @@ -59,6 +59,11 @@ static void handle_connection(DBusServer *server, DBusConnection *conn, void *da  static DBusServer *server = NULL; +char *get_local_server_address(void) +{ +	return dbus_server_get_address(server); +} +  void init_local_server(void)  {  	DBusError err; diff --git a/hcid/server.h b/hcid/server.h index ad5674c6..41eb5d86 100644 --- a/hcid/server.h +++ b/hcid/server.h @@ -23,3 +23,5 @@  void init_local_server(void);  void shutdown_local_server(void); + +char *get_local_server_address(void); | 
