DebuggingDBus

Differences between revisions 1 and 8 (spanning 7 versions)
Revision 1 as of 2010-05-07 13:26:40
Size: 2675
Editor: pool-173-76-32-237
Comment: Initial explanation of how to view session/system bus
Revision 8 as of 2014-06-19 07:56:53
Size: 2550
Editor: 91-145-74-44
Comment:
Deletions are marked like this. Additions are marked like this.
Line 17: Line 17:
If it's too much information, pass a watch expression like so:
{{{
dbus-monitor "type='signal',sender='org.gnome.TypingMonitor',interface='org.gnome.TypingMonitor'"
}}}
Line 26: Line 21:
 1. Make a backup of /etc/dbus-1/system.conf:  1. Create a file /etc/dbus-1/system-local.conf, with these contents:
Line 28: Line 23:
sudo cp /etc/dbus-1/system.conf /etc/dbus-1/system.conf~ <!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
    <policy user="root">
        <allow eavesdrop="true"/>
        <allow eavesdrop="true" send_destination="*"/>
    </policy>
</busconfig>
Line 30: Line 33:
 1. Edit /etc/dbus-1/system.conf
 {{{
sudo editor /etc/dbus-1/system.conf
 }}}
 1. Find the <policy context="default"> section and replace it with the following block. This block opens up the system bus to viewing by anyone.
 1. Reboot your machine to pick up the configuration changes. Simply reloading the DBus server configuration is not sufficient. For further info see [[https://bugs.freedesktop.org/show_bug.cgi?id=80186|this bug]].
Line 36: Line 35:
 '''Note that this is not a safe policy! You should revert this change after you are done debugging.'''
 {{{
  <policy context="default">
    <!-- Allow everything to be sent -->
    <allow send_destination="*" eavesdrop="true"/>
    <!-- Allow everything to be received -->
    <allow eavesdrop="true"/>
    <!-- Allow anyone to own anything -->
    <allow own="*"/>
    <allow user="*"/>
  </policy>
 }}}
 1. Then comment out or delete the nearby <includedir> line. This line will include individual policies for specific services. But we don't want those individual policies to further restrict the bus. So we force our above lax policy by not including sub-policies.
 {{{
<!-- <includedir>system.d</includedir> -->
 }}}
 1. Reboot to get a fresh dbus daemon using this new policy.
Line 57: Line 39:
 1. When done debugging, remember to go back to your previous, secure policy:  1. When done debugging, it is wise to remove the policy snippet:
Line 59: Line 41:
sudo cp /etc/dbus-1/system.conf~ /etc/dbus-1/system.conf sudo rm /etc/dbus-1/system-local.conf
Line 61: Line 43:

= Filtering all the noise =

If there is just too much information on the bus, pass a match rule like so:
{{{
dbus-monitor "type=signal,sender='org.gnome.TypingMonitor',interface='org.gnome.TypingMonitor'"
}}}

Multiple rules can be specified. If a message matches ''any'' of the rules, the message will be printed. Like so:
{{{
dbus-monitor "type=error" "sender=org.freedesktop.SystemToolsBackends"
}}}
{{{
dbus-monitor "type=method_call" "type=method_return" "type=error"
}}}

See the [[http://dbus.freedesktop.org/doc/dbus-specification.html|D-Bus documentation]] for more information on match rule syntax.

Debugging Central

This page is part of the debugging series — pages with debugging details for a variety of Ubuntu packages.

Introduction

As more and more applications and system services use D-Bus, it becomes more important to know how to see what happens on the bus.

There are two buses commonly used: the session bus and the system bus. Either may be used by any application, depending on what it is doing.

How to monitor the session bus

This one is easy. Just run dbus-monitor and watch the output. This usually gives you enough information about what is happening on the bus.

dbus-monitor

How to monitor the system bus

This is trickier, because D-Bus policy typically prevents anything but signals from being viewable by dbus-monitor. But we can change that.

  1. Create a file /etc/dbus-1/system-local.conf, with these contents:
    <!DOCTYPE busconfig PUBLIC
    "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
    "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
    <busconfig>
        <policy user="root">
            <allow eavesdrop="true"/>
            <allow eavesdrop="true" send_destination="*"/>
        </policy>
    </busconfig>
  2. Reboot your machine to pick up the configuration changes. Simply reloading the DBus server configuration is not sufficient. For further info see this bug.

  3. Now run dbus-monitor as root. You should be able to see all signals, method calls, and method replies.
    sudo dbus-monitor --system
  4. When done debugging, it is wise to remove the policy snippet:
    sudo rm /etc/dbus-1/system-local.conf

Filtering all the noise

If there is just too much information on the bus, pass a match rule like so:

dbus-monitor "type=signal,sender='org.gnome.TypingMonitor',interface='org.gnome.TypingMonitor'"

Multiple rules can be specified. If a message matches any of the rules, the message will be printed. Like so:

dbus-monitor "type=error" "sender=org.freedesktop.SystemToolsBackends"

dbus-monitor "type=method_call" "type=method_return" "type=error"

See the D-Bus documentation for more information on match rule syntax.


CategoryBugSquad CategoryDebugging

DebuggingDBus (last edited 2014-06-19 07:56:53 by 91-145-74-44)