Passing file descriptors over DBUS

Waldo Bastian Waldo.Bastian at intel.com
Thu Sep 8 03:48:16 PDT 2005


On Thursday 08 September 2005 02:03, Havoc Pennington wrote:
> On Wed, 2005-09-07 at 17:43 +0200, Waldo Bastian wrote:
> > In order to make the X server more flexible in handling configuration
> > changes one of the ideas so far is to use DBUS (either via the session
> > bus, or via a P2P connection) to tell the X server about it's
> > configuration. For that to work in a secure way, one of the requirements
> > is to have the ability to pass an open file descriptor across DBUS. (See
> > man 7 unix, SCM_RIGHTS)
> >
> > What are my chances of getting such functionality adopted in DBUS?
>
> Here's some past discussion:
>
> http://lists.freedesktop.org/archives/dbus/2004-October/001690.html
> http://lists.freedesktop.org/archives/dbus/2004-October/001691.html
> http://lists.freedesktop.org/archives/dbus/2004-November/001692.html

Oh, I'm not alone :-) That's encouraging.

> Basic conclusion then seemed to be, we couldn't figure out how to
> implement it, or at least that it would be a lot of work and raise some
> complicated issues. But it may be that there are simple solutions given
> enough thought.

The fact that messages get routed through the daemon make things slightly more 
complicated.

I think it should be possible to have an extension to say at the wire level, 
"this message contains a filedescriptor". Implementation wise you would need 
to tie the file descriptor to DBusMessage, you can essentially refcount the 
file descriptor by dup()-ing it. So once you put the file descriptor in the 
message it will get dup'ed and the caller is free to close his own file 
descriptor. A big question is whether DBUS can close the file descriptor 
directly after sending the message across the socket or whether it needs to 
wait till the other side has actually picked it up. The latter case would 
slightly complicate things.

Since messages can stay queued for a bit in the DBUS daemon (are their any 
limits on that?) there is the conceptual problem that it would be possible 
for the daemon to run out of file descriptors because it has a lot of 
messages with attached file descriptors queued. I don't think that's much 
different from running out of memory, except for the fact that running out of 
file descriptors may happen a lot earlier.

> The system bus is already used to obtain network configuration for
> example (in NetworkManager), so there may be a way to use that same
> approach.

Huh? I fail to see the relation between the two, but then again, I never 
looked very closely to the NetworkManager. Any particular code I should look 
at?

Cheers,
Waldo
-- 
Linux Client Architect - Channel Software Operation - Intel Corporation



More information about the dbus mailing list