Bug 90952

Summary: dbus-monitor is closed when ping is sent
Product: dbus Reporter: Ondrej Holy <oholy>
Component: coreAssignee: Simon McVittie <smcv>
Status: RESOLVED FIXED QA Contact: D-Bus Maintainers <dbus>
Severity: normal    
Priority: medium CC: bugzilla, walters
Version: unspecifiedKeywords: patch
Hardware: Other   
OS: All   
Whiteboard: review?
i915 platform: i915 features:
Attachments: dbus-monitor: disable automatic handling of o.fd.Peer messages
Add test-case to confirm that dbus_connection_set_route_peer_messages() is enough

Description Ondrej Holy 2015-06-12 08:50:10 UTC
I send ping:
$ dbus-send --dest=org.gnome.Nautilus /org/gnome/Nautilus org.freedesktop.DBus.Peer.Ping


Consequently dbus-monitor exited: 
$ dbus-monitor
...
method call time=1434089074.492372 sender=:1.1 -> destination=org.gnome.Nautilus serial=7 path=/org/gnome/Nautilus; interface=org.freedesktop.Application; member=Open
   array [
      string "file:///"
   ]
   array [
   ]
signal time=1434089074.523564 sender=(null sender) -> destination=(null destination) serial=0 path=/org/freedesktop/DBus/Local; interface=org.freedesktop.DBus.Local; member=Disconnected


Because dbus-daemon close it:
$ DBUS_VERBOSE=1 dbus-daemon --session
...
Connection :1.0 (uid=1000 pid=14507 comm="dbus-monitor ") became a monitor.
Activating service name='org.gnome.Nautilus'
Monitoring connection :1.0 (uid=1000 pid=14507 comm="dbus-monitor ") is not allowed to send messages; closing it. Please fix the monitor to not do that. (message type="method_return" interface="(unset)" member="(unset)" error name="(unset)" destination=":1.1")
Monitoring connection :1.0 closed.


But I suppose it shouldn't be closed...
Comment 1 Simon McVittie 2015-06-12 11:12:44 UTC
This seems very likely to be a regression in 1.9.x. dbus-monitor should turn off the part of libdbus that "helpfully" handles Peer messages automatically.
Comment 2 Simon McVittie 2015-06-12 11:15:43 UTC
Calling dbus_connection_set_route_peer_messages (conn, TRUE) in dbus-monitor is probably enough. That stops it from trying to reply to any Peer message that has a destination; and dbus-daemon should never send us a Peer message not fitting that description.
Comment 3 Simon McVittie 2015-07-03 13:05:21 UTC
Created attachment 116916 [details] [review]
dbus-monitor: disable automatic handling of o.fd.Peer  messages

A normal DBusConnection will automatically reply to o.fd.Peer
messages such as Ping. We don't want this: if we are using
traditional eavesdropping with an older dbus-daemon, we'll
confuse everyone else by replying to messages that weren't
intended for us. If we are using the new Monitoring
interface (since 1.9.12), the same still applies, but in
addition, the dbus-daemon will disconnect us for not being
a well-behaved monitor.
Comment 4 Simon McVittie 2015-07-03 13:05:39 UTC
Created attachment 116917 [details] [review]
Add test-case to confirm that  dbus_connection_set_route_peer_messages() is enough
Comment 5 Philip Withnall 2015-07-04 07:33:17 UTC
Comment on attachment 116916 [details] [review]
dbus-monitor: disable automatic handling of o.fd.Peer  messages

Review of attachment 116916 [details] [review]:
-----------------------------------------------------------------

++
Comment 6 Philip Withnall 2015-07-04 07:36:33 UTC
Comment on attachment 116917 [details] [review]
Add test-case to confirm that  dbus_connection_set_route_peer_messages() is enough

Review of attachment 116917 [details] [review]:
-----------------------------------------------------------------

++, although the commit summary is a bit opaque if you haven’t read the bug.
Comment 7 Simon McVittie 2015-07-21 16:20:29 UTC
(In reply to Philip Withnall from comment #6)
> ++, although the commit summary is a bit opaque if you haven’t read the bug.

Re-worded it and pushed.

Fixed in git for 1.9.18 and 1.8.20.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.