From c2d1e5fb420fe60d2f3511581e996faa4d8c9337 Mon Sep 17 00:00:00 2001 From: Cosimo Alfarano Date: Thu, 7 Jul 2011 16:10:54 +0100 Subject: [PATCH 2/2] Add "eavesdrop=true" as constant match rule for dbus-monitor Bug: https://bugs.freedesktop.org/show_bug.cgi?id=37890 Bug-NB: NB#269748 Origin: vendor, Maemo --- tools/dbus-monitor.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) --- a/tools/dbus-monitor.c +++ b/tools/dbus-monitor.c @@ -35,6 +35,8 @@ #include "dbus-print-message.h" +#define EAVESDROPPING_RULE "eavesdrop=true" + #ifdef DBUS_WIN /* gettimeofday is not defined on windows */ @@ -50,6 +52,7 @@ #define _IONBF 0x04 #endif + void GetSystemTimeAsFileTime (LPFILETIME ftp) { @@ -299,10 +302,14 @@ main (int argc, char *argv[]) else if (arg[0] == '-') usage (argv[0], 1); else { + unsigned int filter_len; numFilters++; - filters = (char **)realloc(filters, numFilters * sizeof(char *)); - filters[j] = (char *)malloc((strlen(arg) + 1) * sizeof(char *)); - snprintf(filters[j], strlen(arg) + 1, "%s", arg); + /* append a rule (and a comma) to enable the monitor to eavesdrop */ + filter_len = strlen(EAVESDROPPING_RULE) + 1 + strlen(arg) + 1; + + filters = (char **)realloc(filters, numFilters * sizeof(char *)); + filters[j] = (char *)malloc(filter_len * sizeof(char *)); + snprintf(filters[j], filter_len, "%s,%s", EAVESDROPPING_RULE, arg); j++; } }