Using dbus send to 127.0.0.1 for custom method

I am trying to get dbus-send --address

to work with address 127.0.0.1 port 10010 for a custom method ( com.example.Test.TestMethod

). I wrote for myself. This is not very useful on its own, but I am trying to do something else and this is a test step.


First, I convinced myself that my testing method works as it should. Using the system bus is done locally for my method:

$ dbus-send --system --print-reply --type=method_call --dest=com.example.Test /com/example/Test com.example.Test.TestMethod string:foo
method return sender=:1.0 -> dest=:1.17 reply_serial=2
   string "returning foo"

      


Second, the crash --address

(I don't understand why it doesn't work):

$ dbus-send --address=tcp:host=127.0.0.1,port=10010 --print-reply --type=method_call --dest=com.example.Test /com/example/Test com.example.Test.TestMethod string:foo
Error org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

      

dbus-monitor

shows nothing:

$ DBUS_VERBOSE=1 dbus-monitor --system
(nothing)

      


Third, using --address

on org.freedesktop.DBus.Hello

succeeds. I don't know why this succeeds, while my method fails:

$ dbus-send --address=tcp:host=127.0.0.1,port=10010 --print-reply --type=method_call --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.Hello
method return sender=org.freedesktop.DBus -> dest=:1.15 reply_serial=1
   string ":1.15"

      


I made some changes to the config file /etc/dbus-1/system.conf

:

  <auth>ANONYMOUS</auth>
  <allow_anonymous/>

<listen>tcp:host=127.0.0.1,port=10010</listen>

    <allow send_destination="com.example.Test"/>
    <allow own="com.example.Test"/>

      


For debugging I used DBUS_VERBOSE=1

in dbus-send

, but I don't see anything useful in the output. A failure case and a success case have a minimally different output:

Successful case ( org.freedesktop.DBus.Hello

):

[dbus/dbus-transport-socket.c(879):do_reading]  read 89 bytes
[dbus/dbus-marshal-header.c(745):_dbus_header_have_message_untrusted] have 89 bytes, need body 9 + header 80 = 89
[dbus/dbus-marshal-validate.c(723):_dbus_validate_body_with_reason] validating body from pos 0 len 89 sig 'yyyyuua(yv)'

      

Bad case ( com.example.Test.TestMethod

):

[dbus/dbus-transport-socket.c(873):do_reading] Disconnected from remote app
[dbus/dbus-transport.c(502):_dbus_transport_disconnect] start
[dbus/dbus-transport-socket.c(1017):socket_disconnect] 
[dbus/dbus-transport-socket.c(76):free_watches] start
[dbus/dbus-watch.c(628):dbus_watch_set_data] Setting watch fd -1 data to data = (nil) function = (nil) from data = (nil) function = (nil)
[dbus/dbus-watch.c(628):dbus_watch_set_data] Setting watch fd -1 data to data = (nil) function = (nil) from data = (nil) function = (nil)
[dbus/dbus-transport-socket.c(98):free_watches] end
[dbus/dbus-transport.c(513):_dbus_transport_disconnect] end

      


I also started debug mode dbus-daemon

with help DBUS_VERBOSE=1

, but I cannot find a way out anywhere. It's not in syslog. I may not have a debug version, but I find it unlikely that dbus-send

both dbus-monitor

are apparently debug options.


I tried the same experiments on the session bus with the same results.


Version Information:

$ dbus-daemon --version
D-Bus Message Bus Daemon 1.6.8

$ cat /etc/debian_version
7.6

      

My ultimate goal is to use D-bus to transfer messages between computers. Getting dbus-send --address

to work in a local case is just my first step along the way.


Update Oct 16, 2014: I was able to get this to work. The decision is counterintuitive.

There are two requirements.

You need to communicate using the SYSTEM bus . You must set the SESSION environment variable .

$ DBUS_SESSION_BUS_ADDRESS=tcp:host=192.168.56.101,port=10010 dbus-send --print-reply --type=method_call --dest=com.example.Test /com/example/Test com.example.Test.TestMethod string:foo

      

+3


source to share


1 answer


I think this is because dbus-daemon is asking for a local secret and your client doesn't know how to read it. Can you try to reset all handshake with wires? (alternatively, you can use the dbus-dissect script, but this may require some adjustments to the source code)



0


source







All Articles