Commit graph

470 commits

Author SHA1 Message Date
Ralf Habacker
360a68eddd dbus-monitor: Add timestamp to --monitor mode.
Use cross platform function _dbus_get_real_time() for fetching current time.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88896
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
[smcv: use %ld to avoid needing casts; reinstate printing the timestamp;
libdbus-1 is sufficient now that fd.o#83115 is fixed; print timestamp for
non-literal dbus-send replies too]
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-24 13:29:45 +00:00
Ralf Habacker
e78bac35cc dbus-monitor: Keep parameter list of method returns in --monitor mode in sync with --profile mode.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88896
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-02-24 11:48:40 +00:00
Ralf Habacker
3c889c694d dbus-monitor: convert remaining hard tabs to 8 space.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88896
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-02-24 11:48:06 +00:00
Simon McVittie
160f5bb9d2 dbus-launch: if autolaunching, use XDG_RUNTIME_DIR/bus if available
This provides backwards-compatible autolaunching behaviour, as long
as dbus-launch inherits the XDG_RUNTIME_DIR (which it presumably did
if it's going to work at all, since it must also have inherited the
DISPLAY). In particular, we go through the motions of starting the
dbus-daemon, so that we can start the "babysitter" process that will
maintain the X11 window to store the bus address.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61301
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
[smcv: decorate _dbus_lookup_user_bus with DBUS_PRIVATE_EXPORT so we
can still call it after fixing fd.o#83115; update cmake to match Autotools]
2015-02-24 11:25:50 +00:00
Simon McVittie
71c11a9e48 dbus-launch: use libdbus to read the UUID
As a side benefit, this means that dbus-launch now understands
/etc/machine-id and not just /var/lib/dbus/machine-id.

Since machine_uuid comes out of libdbus allocated with dbus_malloc,
to avoid having to copy it from malloc-allocated to
dbus_malloc-allocated storage, it makes sense to change it to be
consistently dbus_malloc-allocated (particularly now that Bug #83115
has made use of internal symbols relatively painless). However, I'm
deliberately not changing the allocation model of any other strings
in dbus-launch right now; that's a larger yak-shaving exercise.
2015-02-24 11:16:13 +00:00
Simon McVittie
2a6cefbc3b Add dbus-update-activation-environment tool
If OS builders (distributions) have chosen to use the per-user bus,
this provides two possible modes of operation for compatibility with
existing X session startup hooks.

A legacy-free system can just upload DISPLAY, XAUTHORITY and possibly
DBUS_SESSION_BUS_ADDRESS into dbus-daemon's and systemd's activation
environments, similar to
http://cgit.freedesktop.org/systemd/systemd/tree/xorg/50-systemd-user.sh
installed by systemd (but unlike systemctl,
dbus-update-activation-environment works for traditional
D-Bus-activated services, not just for systemd services).

A system where compatibility is required for environment variables
exported by snippets in /etc/X11/xinit/xinitrc.d (in Red Hat derivatives,
Gentoo, etc.) or /etc/X11/Xsession.d (Debian derivatives) can upload
the entire environment of the X session, minus some selected environment
variables which are specific to a login session (notably XDG_SESSION_ID).

In Debian, I plan to put the former in a new dbus-user-session package
that enables a user-session-centric mode of operation for D-Bus,
and the latter in the existing dbus-x11 package, with the intention that
dbus-x11 eventually becomes a tool for change-averse setups or goes
away entirely.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61301
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-24 11:15:52 +00:00
Ralf Habacker
387c1a5b91 dbus-monitor: Remove empty column in --profile mode.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89165
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-02-16 15:12:06 +01:00
Ralf Habacker
450c7067de dbus-monitor: Combine sec and usec columns into one timestamp column and unify platform related format string.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89165
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-02-16 15:12:06 +01:00
Simon McVittie
4453665b17 dbus-monitor: whitespace 2015-02-16 12:53:57 +00:00
Simon McVittie
bb950952e6 dbus-monitor: clarify column headers
- change "ref serial" to "in_reply_to" (avoiding whitespace for easy
  visual parsing)
- prefix with # to clarify that these are not part of the data

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89165
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-16 12:53:18 +00:00
Ralf Habacker
a52ef07c80 dbus-monitor.c: unify columns format in --profile mode and display column header.
[rebase onto correctly indented version -smcv]
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89165
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-16 12:53:16 +00:00
Simon McVittie
1ddaffffb8 dbus-monitor: convert remaining hard tabs to 8 spaces
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89165
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-02-16 12:52:53 +00:00
Simon McVittie
3ca9aa9cc0 dbus-send: pretty-print GVariant-style bytestrings
dbus-send could already pretty-print bytestrings that do not have
\0 termination, but those are awkward to work with (they need copying),
so they are now discouraged. Teach it to print bytestrings that
do have \0 termination as well.

In the process, rewrite this part of the message parser
to use dbus_message_iter_get_fixed_array(), which is the Right way
to get arrays of numbers out of a message.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89109
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-16 11:44:16 +00:00
Simon McVittie
1a28f82926 dbus-monitor: add options to log binary data with or without pcap framing
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-04 17:15:34 +00:00
Simon McVittie
8a621b8f77 dbus-monitor: add support for using BecomeMonitor to be a read-only monitor
Move the dbus_connection_add_filter() call further up as a precaution,
because it isn't safe for a monitor to not have a filter that
swallows all messages.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-02-04 17:15:31 +00:00
Simon McVittie
9806240b78 dbus-monitor: use common code from dbus-test-tool
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787
Reviewed-by: Philip Withnall
[also sync up the cmake build system -smcv]
2015-02-04 14:18:39 +00:00
Simon McVittie
1acc7b09ed lcov: use builddir, not srcdir
It seems lcov (or gcc?) has changed its paths since last time this
worked.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88808
Reviewed-by: Philip Withnall
2015-02-02 18:38:07 +00:00
Alban Crequy
74b4f1d07a dbus-test-tool: add black-hole mode
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34140
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2014-10-14 13:53:59 +01:00
Alban Crequy
75b35badb7 dbus-test-tool spam: add --messages-per-conn=N
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34140
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2014-10-14 13:53:57 +01:00
Alban Crequy
10f8b67a9f Add dbus-test-tool, currently with "echo" and "spam" modes
This is installed by default, but easy to filter out for embedded systems
or whatever.

Based on earlier work by Simon McVittie and Will Thompson

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34140
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2014-10-14 13:53:54 +01:00
Alban Crequy
668cd4eb20 GetAllMatchRules: provide an example how it could be used
[use dist_examples_SCRIPTS instead of EXTRA_DIST -smcv]

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=84598
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2014-10-06 12:10:51 +01:00
Alban Crequy
c681f46c22 dbus-monitor: more details on file descriptors
Print more details when receiving a file descriptor.

Before:
   unix fd 5

After:
   file descriptor
         inode: 1030
         type: char
   file descriptor
         inode: 295664
         type: socket
         address family: unknown (16)
   file descriptor
         inode: 295665
         type: socket
         address family: inet
         name 127.0.0.1 port 47723
         peer 127.0.0.1 port 22
   file descriptor
         inode: 295666
         type: socket
         address family: unix
         name @/tmp/d67s774Sws0pEra
   file descriptor
         inode: 295667
         type: socket
         address family: unix
         name @
         peer @

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80603
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2014-09-15 17:37:59 +01:00
Alban Crequy
eb4584d5c5 dbus-monitor: do not leak file descriptors from fd-passing
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80603
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2014-09-15 17:37:34 +01:00
Роман Донченко
5c7ea35c3d dbus-launch: kill bus if we can't attach to a session when requested
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=74698
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2014-06-11 11:38:24 +01:00
Роман Донченко
3be6063729 Avoid killing all available processes if an X error arrives early on
The timeline of events in dbus-launch's main process goes something like this:

* do initial X calls
[1]
* do some other stuff
* fork
    (child process starts doing some other stuff)
* return "intermediate parent" pid from fork()
* obtain bus daemon pid from bus_pid_to_launcher_pipe
[2]
* do things that might include X11 calls or killing the dbus-daemon

Meanwhile, the "babysitter" child goes like this:

* return 0 from fork()
[3]
* obtain bus daemon pid from parent process via bus_pid_to_babysitter_pipe
[4]
* do things that might include X11 calls or killing the bus daemon

Before [1] or [3], the right thing to do about an X error is to just
exit. The current implementation called kill(-1) first, which is
undesirable: it kills unrelated processes. With this change, we
just exit.

After [2] or [4], the right thing to do is to kill the dbus-daemon,
and that's what the existing code did.

Between [1] and [2], or between [3] and [4], there is no correct thing
that we can do immediately: we would have to wait for the end of the
"critical section", *then* kill the dbus-daemon. This has not yet been
implemented, so this patch relies for its correctness on the fact that
there are no libX11 calls between those points, so we cannot receive
an X error between them.

dbus-launch deserves more comments, or a reimplementation that is easier to
understand, but this change is certainly better than nothing.

[Commit message added, summarizing reviewers' comments -smcv]
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=74698
Reviewed-by: Simon McVittie
Reviewed-by: Thiago Macieira
2014-04-30 19:11:56 +01:00
Lukasz Skalski
9e7610ef17 Update .gitignore files
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=75833
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2014-03-06 13:10:56 +00:00
Robert Ancell
969f3918dc Support printing unix file descriptors in dbus-send/dbus-monitor
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=70592
Reviewed-by: Chengwei Yang <chengwei.yang@intel.com>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-11-27 15:08:25 +00:00
Chengwei Yang
faaa092f20 dbus-monitor: keep backwards compatibility
eavesdropping as a match rule key introduced in DBus 1.5.6, and the
privous implementation doesn't keep backwards compatibility with older
dbus-daemon.

And the reference dbus-daemon implementation just fail if unknwon key
found in match rule, this is undefined hehavior in DBus Sepcification.

Also there is a feature request for change this hehavior to
"ignore unknown key in match rule", See
https://bugs.freedesktop.org/show_bug.cgi?id=66114

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66107
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-10-09 11:26:46 +01:00
Andrey Mazo
b994830c7f dbus-send: replace --address with --peer and --bus.
--peer is a direct substitute for --address.
With --bus dbus-send registers on bus given by ADDRESS, thus allowing
messages to be sent to the bus.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=48816
[adjusted to apply to current master -smcv]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-10-09 11:18:20 +01:00
Simon McVittie
39673b945c Revert "dbus-send: replace --address"... to fix attribution
This reverts commit 5b74af796c.
2013-10-09 11:17:20 +01:00
Chengwei Yang
47df159cc5 Unify the way to find dbus-daemon test binary
There are two ways to find the dbus-daemon for testing. The first one is
defined as string at compile stage and the second one is export it from
test environment.

The first way has limitation that after defined, it's static string, so
it's impossible to run installable check. So let's unify to the second
way.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=37849
[added missing "}" -smcv]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-10-08 16:08:57 +01:00
Simon McVittie
5b74af796c dbus-send: replace --address with --peer and --bus.
--peer is a direct substitute for --address.
With --bus dbus-send registers on bus given by ADDRESS, thus allowing
messages to be sent to the bus.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=48816
[adjusted to apply to current master -smcv]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-10-08 16:08:33 +01:00
Chengwei Yang
1451f946c1 dbus-monitor: remove redundant match rules
Currently, DBus Specification only consists of four message types, so to
monitor all the types of message, no need to match all of them but just
left it empty is OK.

Signed-off-by: Chengwei Yang <chengwei.yang@intel.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66107
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-10-08 11:15:35 +01:00
Simon McVittie
f81cd4a18b When using dbus-launch for tests, fail hard if test binary is missing
We want to test the version-under-test, not the system version.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=37849
Reviewed-by: Chengwei Yang <chengwei.yang@intel.com>
2013-10-08 11:06:18 +01:00
Simon McVittie
580ed1c8fb dbus-launch: avoid asprintf(), and die gracefully on out-of-memory
asprintf() is a GNU extension (non-portable).

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=37849
Reviewed-by: Chengwei Yang <chengwei.yang@intel.com>
2013-10-08 11:06:18 +01:00
Chengwei Yang
fd5271f839 Fix build on NetBSD 6.1.1 with gcc 4.5.3
There are two build failure on NetBSD 6.1.1 with gcc 4.5.3, the first
one is char to int, warning treated as error. The second one is a mismatch
between format string and arguments.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69842
[adjusted commit message -smcv]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-10-08 10:29:20 +01:00
Sviatoslav Chagaev
990fd63f4e Fix an incorrect sizeof.
Fix an incorrect sizeof which leads to allocation of more memory than
actually needed.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69329
[elide redundant "* sizeof (char)" which is 1 by definition -smcv]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-09-16 15:31:22 +01:00
Simon McVittie
9577e33c89 Revert "Fix an incorrect sizeof." to fix attribution
This reverts commit 3c1938180b.
2013-09-16 15:31:22 +01:00
Simon McVittie
3c1938180b Fix an incorrect sizeof.
Fix an incorrect sizeof which leads to allocation of more memory than
actually needed.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69329
[elide redundant "* sizeof (char)" which is 1 by definition -smcv]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-09-16 12:43:40 +01:00
Chengwei Yang
ee0f28f6a5 Use test binaries in build dir to do test
When do autolaunch testing, libdbus will try to start dbus-launch in
installed direcotry, if fail then fall back to dbus-launch in $PATH.
dbus-launch does a relative better thing to start dbus-daemon in build
directory, however, in most of case, the build $prefix is different from
the real prefix where dbus-daemon installed. So dbus-daemon will fail to
start due to can't find its config file. And then dbus-launch will fall
back to finally the installed dbus-daemon.

This patch fix this behavior and will start dbus-launch and dbus-daemon
in build directory in test environment.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=37849
2013-09-13 14:29:45 +01:00
Chengwei Yang
fbeac8820a dbus-launch: unconditionally use SIGHUP and free memory on OOM
In a previous patch, it check SIGHUP for windows, however, in fact there
is dbus-launch-win.c supposed to be used on windows. So just use SIGHUP
unconditionally.

Also free memory on OOM, although this doesn't make much sense since
this is a oneshort program, rather than a daemon.

Signed-off-by: Chengwei Yang <chengwei.yang@intel.com>
[fixed whitespace -smcv]
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66068
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-09-05 14:01:46 +01:00
Simon McVittie
9d80d46a79 run-with-tmp-session-bus.sh: create a unique temporary file per process
This makes the regression tests OK to run in parallel.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2013-09-05 12:35:11 +01:00
Simon McVittie
5ee72fe2e1 dbus-run-session: remove various extra variables from the environment
DBUS_SESSION_BUS_PID is not mandatory to set, but we should unset it
if present, since it points to a different session's bus. Likewise for
DBUS_SESSION_BUS_WINDOWID.

Similarly, if DBUS_STARTER_BUS_TYPE and DBUS_STARTER_ADDRESS
are set (as they would be under GNOME Terminal 3.8, see
<https://bugs.freedesktop.org/show_bug.cgi?id=63119>) then they
are likely to point to a different session's bus.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39196
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Colin Walters <walters@verbum.org>
2013-08-23 11:41:16 +01:00
Ralf Habacker
bc02680c69 Fixed compiler warning on windows.
https://bugs.freedesktop.org/show_bug.cgi?id=61874
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-08-19 21:29:26 +02:00
Chengwei Yang
11c5dc126e tests to embedded tests: replaced in tools
Signed-off-by: Chengwei Yang <chengwei.yang@intel.com>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66291
2013-06-28 12:14:00 +01:00
Chengwei Yang
eec093bbdb dbus-launch: do not verbose output if build with verbose mode disabled
Signed-off-by: Chengwei Yang <chengwei.yang@intel.com>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66068
2013-06-26 15:23:35 +01:00
Chengwei Yang
8aa07c7e48 dbus-launch: align document
Signed-off-by: Chengwei Yang <chengwei.yang@intel.com>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66068
2013-06-26 15:23:11 +01:00
Chengwei Yang
973684f022 dbus-launch: fix coding style
Signed-off-by: Chengwei Yang <chengwei.yang@intel.com>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66068
2013-06-26 15:22:35 +01:00
Chengwei Yang
9665b8ecd8 FreeBSD: explicit include signal.h to fix build failure
In Linux envrionment, signal.h included by sys/wait.h, however, this
isn't the case in FreeBSD. So explicit include it to fix build failure.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66197
Signed-off-by: Chengwei Yang <chengwei.yang@intel.com>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-06-26 13:04:01 +01:00
Chengwei Yang
dd2ca80e3f dbus-send: Fix fail to run without "--dest" option
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65923
Signed-off-by: Chengwei Yang <chengwei.yang@intel.com>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-06-20 13:30:40 +01:00