Bug 48816 - dbus-send --address=ADDRESS only works for non-buses
Summary: dbus-send --address=ADDRESS only works for non-buses
Status: RESOLVED FIXED
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: unspecified
Hardware: All All
: medium normal
Assignee: Havoc Pennington
QA Contact: John (J5) Palmieri
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-17 04:31 UTC by Andrey Mazo
Modified: 2013-10-09 00:43 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Proposed fix (1.14 KB, application/octet-stream)
2012-04-17 04:31 UTC, Andrey Mazo
Details
Replace --address with --peer and --bus (3.38 KB, patch)
2012-06-29 04:50 UTC, Andrey Mazo
Details | Splinter Review
Replace --address with --peer and --bus. Review comments taken into account. (3.22 KB, patch)
2012-07-04 01:57 UTC, Andrey Mazo
Details | Splinter Review

Description Andrey Mazo 2012-04-17 04:31:34 UTC
Created attachment 60162 [details]
Proposed fix

This is caused by dbus_bus_register() not following dbus_connection_open().
Without --address= option dbus-send uses session or system bus which doesn't require the extra dbus_bus_register() call.

Reproducible in current git (8734e4a16ff220a7af0fd718ba50f92d23c496cf).

Steps to reproduce:
1) console1 # dbus-launch
DBUS_SESSION_BUS_ADDRESS=<ADDRESS>
...
2) console1 # dbus-monitor --address "<ADDRESS>" type=signal
3) console2 # dbus-send --address="<ADDRESS>" --type=signal /qqq foo.bar.baz

Actual result:
dbus-monitor on console1 doesn't receive the signal

Expected result:
dbus-monitor on console1 does receive the signal
signal sender=:1.38 -> dest=(null destination) serial=2 path=/qqq; interface=foo.bar; member=baz
Comment 1 Simon McVittie 2012-04-18 03:44:06 UTC
Using dbus_bus_register() would break something that currently works - dbus-send can currently send to non-bus (peer-to-peer) connections, but not to bus connections.

In dbus-monitor, the --address option does call dbus_bus_register() and dbus_bus_add_match(), which means it can be used on bus connections but not non-bus connections.

(Admittedly, bus connections are much more common.)

I think I'd prefer to deprecate --address in both cases, and add --bus=ADDRESS and --peer=ADDRESS which are unambiguous. (I'm sure there was already a bug report where I said the same, but I can't find it now.)

If you need to connect to a non-session, non-system bus with the existing dbus-send, here is a workaround:

    DBUS_SESSION_BUS_ADDRESS="ADDRESS" dbus-send --session ...
Comment 2 Andrey Mazo 2012-04-18 04:16:03 UTC
(In reply to comment #1)
> Using dbus_bus_register() would break something that currently works -
> dbus-send can currently send to non-bus (peer-to-peer) connections, but not to
> bus connections.
Sorry, I've completely forgot about non-bus connections.

> In dbus-monitor, the --address option does call dbus_bus_register() and
> dbus_bus_add_match(), which means it can be used on bus connections but not
> non-bus connections.
> 
> (Admittedly, bus connections are much more common.)
I see.

> I think I'd prefer to deprecate --address in both cases, and add --bus=ADDRESS
> and --peer=ADDRESS which are unambiguous. (I'm sure there was already a bug
> report where I said the same, but I can't find it now.)
Agree, I like --bus and --peer much better than --address.
Would you like to deprecate --address (and make it an alias for --peer) or just remove it?

> If you need to connect to a non-session, non-system bus with the existing
> dbus-send, here is a workaround:
> 
>     DBUS_SESSION_BUS_ADDRESS="ADDRESS" dbus-send --session ...
This works fine, thank you!
Comment 3 Simon McVittie 2012-06-27 01:05:36 UTC
(In reply to comment #2)
> (I'm sure there was already a bug
> report where I said the same, but I can't find it now.)

It was a mailing list thread: http://lists.freedesktop.org/archives/dbus/2011-November/014829.html and my reply http://lists.freedesktop.org/archives/dbus/2011-December/014833.html

> Agree, I like --bus and --peer much better than --address.
> Would you like to deprecate --address (and make it an alias for --peer) or just
> remove it?

("You" here is anyone providing a revised patch, not necessarily Andrey)

Deprecate it and keep it, please. If you removed it altogether, something that currently works (dbus-send --address to a non-bus) would cease to work, which would defeat the purpose of that suggestion.
Comment 4 Andrey Mazo 2012-06-29 04:50:56 UTC
Created attachment 63602 [details] [review]
Replace --address with --peer and --bus
Comment 5 Simon McVittie 2012-07-03 11:19:30 UTC
Comment on attachment 63602 [details] [review]
Replace --address with --peer and --bus

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

This basically looks good to me, although I think the warning is excessive. I'll leave this open for a bit in case anyone wants to veto it, then apply it to 1.7.x if nobody does.

::: tools/dbus-send.c
@@ +278,5 @@
> +              is_bus = FALSE;
> +            }
> +	  else /* address */
> +            {
> +              fprintf (stderr, "Warning: \"--address=\" is deprecated and may be removed soon. Please, use \"--peer\" for non-bus (peer-to-peer) connections and \"--bus\" for bus connections\n");

I'd prefer this to just have a comment /* backwards-compatible */ and no warning. Realistically, we aren't going to remove this command-line option for a very long time, if at all (it only "costs" 4 lines of code, after all).
Comment 6 Andrey Mazo 2012-07-04 01:57:04 UTC
Created attachment 63799 [details] [review]
Replace --address with --peer and --bus. Review comments taken into account.
Comment 7 Andrey Mazo 2013-10-08 14:24:19 UTC
(In reply to comment #5)
> [snip]
> This basically looks good to me, although I think the warning is excessive.
> I'll leave this open for a bit in case anyone wants to veto it, then apply
> it to 1.7.x if nobody does.
> [snip]

Could you, please, finally apply the patch?
The bug has been open for more than a year.
Or are there any other reason we should wait more?
Comment 8 Simon McVittie 2013-10-08 15:18:07 UTC
(In reply to comment #7)
> Could you, please, finally apply the patch?

Sorry, this bug wasn't keyworded 'patch' so I kept missing it when looking for pending patches.

Your patch conflicted with changes that had been made on master, but I've adjusted and applied it. Fixed in git for 1.7.6.
Comment 9 Andrey Mazo 2013-10-08 15:38:58 UTC
(In reply to comment #8)
> (In reply to comment #7)
> > Could you, please, finally apply the patch?
> 
> Sorry, this bug wasn't keyworded 'patch' so I kept missing it when looking
> for pending patches.
> 
> Your patch conflicted with changes that had been made on master, but I've
> adjusted and applied it. Fixed in git for 1.7.6.

Thank you very much!


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.