From a4392a602223abf218654b2f38db60fb68c736b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bahad=C4=B1r=20Kandemir?= Date: Wed, 11 May 2011 07:28:32 +0000 Subject: [PATCH] Fix COMAR processing messages sent to other services in eavesdropping mode of DBUS --- comar/include/config.h | 1 + comar/src/config.c | 3 +++ comar/src/loop.c | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/comar/include/config.h b/comar/include/config.h index c29be54..45bf59b 100644 --- a/comar/include/config.h +++ b/comar/include/config.h @@ -64,6 +64,7 @@ #endif extern char *config_server_address; +extern char *config_unique_address; extern char *config_service_name; extern char *config_interface; extern char *config_dir_data; diff --git a/comar/src/config.c b/comar/src/config.c index 453bd5c..e4145b6 100644 --- a/comar/src/config.c +++ b/comar/src/config.c @@ -38,6 +38,9 @@ //! D-Bus socket file char *config_server_address = DBUS_SERVER_ADDRESS; +//! D-Bus unique address +char *config_unique_address; + //! D-Bus service name char *config_service_name = DBUS_SERVICE_NAME; diff --git a/comar/src/loop.c b/comar/src/loop.c index 3c2fc80..c0016d1 100644 --- a/comar/src/loop.c +++ b/comar/src/loop.c @@ -196,6 +196,10 @@ filter_func(DBusConnection *conn, DBusMessage *bus_msg, void *data) PyObject *py_args = pydbus_import(bus_msg); + if (!dbus_message_has_destination(bus_msg, config_unique_address)) { + return DBUS_HANDLER_RESULT_HANDLED; + } + switch (dbus_message_get_type(bus_msg)) { case DBUS_MESSAGE_TYPE_METHOD_CALL: if (my_proc.nr_children > MAX_PROC) { @@ -320,6 +324,7 @@ loop_exec() return -1; } + config_unique_address = dbus_bus_get_unique_name(bus_conn); log_debug("Connected to D-Bus, unique id is %s\n", dbus_bus_get_unique_name(bus_conn)); // Request a name (example: com.server.test) -- 2.18.1