View Full Version : DBus over TCP?
RYX
December 12th, 2006, 09:54 PM
I was just wondering if the current implementation of dbus allows connecting to the bus via tcp-sockets. Does anybody know if that's already possible?
I am asking because I want to try communicating with compiz (over dbus) from a flash-movie (swf) - Flash9 offers a new binary socket class! It would be an interesting experiment to have a flash-movie acting as compiz-control-panel ... (I just found out that the free Flex2SDK from Adobe is not only for compiling mxml (Flex2-apps), but also for pure ActionScript3-classes (Flash-movies) ... that's great because you can work with pure AS3 and don't need any mxml ...)
:)
Guest
December 12th, 2006, 10:02 PM
That would be quite cool, Here some links i found, seem to suggest it's possible:
http://lists.freedesktop.org/archives/dbus/2004-November/001754.html http://www.freedesktop.org/wiki/Software_2fDBusRemote and http://lists.freedesktop.org/archives/dbus/2003-December/000628.html
RYX
December 12th, 2006, 10:58 PM
Thanks, zootreeves. I also found some sources that say it is possible (and all are some years old), but looks like there are no details about the "how", maybe because dbus over tcp is pretty insecure and not used very often.
Though - the security/encryption/firewall/etc issues should be no problem in my case, because it will only operate on the localhost, so maybe it is worth reading through some header-files ... (*sigh*)
:)
mikedee
December 12th, 2006, 11:21 PM
I think it should be easy you will just need to modify/create the correct config file.
man dbus-deamon will help ;)
You should be able to add an extra <listen> tag with the tcp: string like in the mailing list post linked before.
Sounds very interesting though
mikedee
December 12th, 2006, 11:59 PM
Oops - forgot to mention that you will need to also reverse engineer the dbus wire protocol. In theory its possible, nothing is encrypted and the dbus protocol is documented. But as we know, theres documentation and theres good useful documentation... :roll:
I dont think it would be too hard to convert the dbus plugin to be a tcp http plugin. You could then make standard get requests with any web enabled application.
The dbus tcp transport layer is just that, it still expects you to be using the dbus bindings, and there aren't any for flash. There are very good http bindings though.
I think it could make some awesome apps so I think Ill have a look to see how hard it would be, I dont think it will be too hard since dbus and http are very similar on a theoretical level.
RYX
December 13th, 2006, 12:19 AM
Thanks for your suggestions, mikedee.
Coding a new plugin would do the job for compiz, but dbus has so many possibilities to use from within flash-based applications that it would be the "better" way to create bindings (because flash can do much more than playing youtube-videos but lacks system-access for creating desktop-apps).
So, what do we have? The new AS3-api allows real binary access to TCP/IP-sockets. There is a new datatype ByteArray that allows byte-operations on data i/o. If Dbus allows (or can be patched to properly allow) connections over TCP, then (theoretically) all that should be a realizable task (though I agree it would require some nasty low-level coding).
A dbus-binding for Actionscript would push flash on Linux to a whole new level ...
:)
mikedee
December 13th, 2006, 12:36 AM
Actually I do not think that reverse enginering the protocol would be very hard at all, we only need very simple methods. From what I have seen it looks like the dbus protocol is similar to json.
If flash has those advanced tools then it might be a good idea, you will need a good network sniffer, you can then create a small python script which connects via tcp and sends a simple message, just watch what is sent and returned.
RYX
December 13th, 2006, 12:47 AM
I thought about using a little flash-movie connecting via tcp and dump out the answer, but python would do, too. :)
... I just found the answer to the question I wanted to ask (http://www.csquad.org/2006/05/26/dbus-daemon-how-to-listen-on-tcpip-socket/). The right syntax for letting dbus listen on tcp.
:)
mikedee
December 13th, 2006, 12:56 AM
I dont think you should be editing the system config file though, compiz operates over the session bus.
Also the man page mentions that you shouldnt edit these files, but you should copy them (not sure exactly how or where though).
RYX
December 13th, 2006, 01:16 AM
Yes, that's right. I only was looking for the right syntax to listen on tcp. I think the system and session bus both have the same config-file type, so it should be possible to put some config-file somewhere and have the session bus listening on tcp.
I have quickly read through the dbus message protocol specs (http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol) - it's partwise hard to understand for a non-native english speaker but doesn't look to difficult. I guess the main task would be creating some (de-)serializing mechanism in ActionScript to convert objects to raw dbus-messages in binary-form (or messages back into objects).
I'll have a deeper look into it during the next days ..
(concerning the network-sniffer: I recently came across ettercrap which is a man-in-the-middle sniffer and maybe this is one of the very few cases where this incredibly cool app can be used in a legal way)
:)
mikedee
December 13th, 2006, 02:14 AM
I have used a sniffer a few times for decoding website forms so that I could bypass the javascript and access the action page directly (it was for airline seats and no I didnt make any money - I did get very cheap European flights though). They are also good for debugging web apps where the cookies are going astray. Of course now days you can use Live HTTP Headers.
The industry standard is Ethereal but maybe that one is easier to work. I have not heard of that one before. Etherreal is more of a Network admin tool rather than a password sniffer ;)
I think you have a high chance of getting something to work, if you need any help with some of the exact translation let me know. The message is a standard header/body style, the signature in the header just defines which datatypes are being returned. Compiz only returns the simple datatypes at the moment so you should concentrate on them first.
The return signatures from compiz are like this "sssississss" generally and they are often variable length. When you are sending method calls you need to send them as a list of key value pairs.
eg. the calling signature will always be something like
"siss"
With the bold s's being the keys.
RYX
December 13th, 2006, 02:26 AM
Yeah, I think ettercrap is more an underground hacking-tool and is especially used for man-in-the-middle ttacks (google only gives 10-50 results) - found it as link within some "network-security"-related blog. I guess I'll use ethereal ... (but it can't be bad to have ettercrap's sources anyway - seems to be pretty rare)
:)
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.