messagebus AF_UNIX listening socket

Havoc Pennington hp at redhat.com
Wed Aug 3 05:35:11 EST 2005


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.

"man unix":

       sun_family  always contains AF_UNIX.  sun_path contains the    
       zero-termi-
       nated pathname of the socket in the file system.   If  sun_path  
       starts
       with  a zero byte it refers to the abstract namespace maintained 
       by the
       Unix protocol module.  The socket’s address in this namespace 
       is given
       by  the rest of the bytes in sun_path.  Note that names in the 
       abstract
       namespace are not zero-terminated.

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.

Havoc




More information about the dbus mailing list