messagebus AF_UNIX listening socket

Jakub Piotr Cłapa jpc at pld-linux.org
Wed Aug 3 09:56:01 EST 2005


Havoc Pennington wrote:
> On Tue, 2005-08-02 at 21:07 +0200, Jakub Piotr Cłapa wrote:
> 
>>Is the messagebus listening on UNIX socket '\x00/tmp/dbus-Iv42EWtOTH' + 
>>'\x00' * 87 (yes! 87 NULL bytes) on purpose?
>>
>>I think that anybody seeing
>>DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-Iv42EWtOTH,guid=7a3ced42fbeeaf14bbafceecee692d00
>>would expect that the socket is named "/tmp/dbus-Iv42EWtOTH" and pass 
>>"\x00/tmp/dbus-Iv42EWtOTH" to connect()
> 
> I'm not sure whether this is how abstract sockets have to work or not;
> apparently I thought it was when writing that code.
> 
> [...]

I was surprised too and it took quite a while to find where the problem 
lies. (strace proved to be invaluable)

> I guess bind()/connect() might allow a shorter addrlen, but it's a
> little tricky to compute since addrlen is the length of the whole struct
> and not just the sun_path bit so we'd have to do
> _DBUS_STRUCT_OFFSET(sun_path) + path len or something.

Probably yes --- we'll need to compute the accurate length of the struct 
counting only meaningful characters. Or document that the address is 
padded but it can be a portability problem and would probably look quite 
odd. ;]

-- 
Regards,
Jakub Piotr Cłapa


More information about the dbus mailing list