Problem using the latest D-Bus enabled GDM on Solaris

Havoc Pennington hp at redhat.com
Fri Sep 7 18:39:33 PDT 2007


Hi,

The key piece of info is that you aren't using the session bus, you're
instead creating your own server. (Which is probably right for this.)

One guess is that you need to call
dbus_connection_set_unix_user_function(), see
http://dbus.freedesktop.org/doc/api/html/group__DBusConnection.html

Another guess is that in handle_connection(), you need to ref the
connection and set it up with the main loop.

The socket should work fine afaik, though AIUI there are
platform-specific details of how filesystem permissions apply to
sockets. strace/truss should easily reveal if there's a permission
problem.

I'm not sure there's a point creating a random /tmp name for your
socket, btw. It creates a couple of problems (which you may have
solved, but maybe with code that could be avoided):
 1) when/how does the /tmp name get deleted?
 2) how does a client find out the name?

The reason the session bus creates a random socket name is that it
needs a new socket for every user session.

But the system bus just uses /var/lib/dbus/system_bus_socket or
something like that; by avoiding /tmp there's no security issue with a
well-known fixed name. Just use a directory that users can't write to.

With gdm you might be able to have something like
/var/lib/gdm/socket_:0,  socket_:1, perhaps.

For the session bus, the cleanup problem is solved in two ways. On
Linux, by using abstract sockets; and on other platforms the best I
came up with was the dbus-cleanup-sockets binary that comes with dbus,
which is meant to run in a cron job or something. It would not work
(without modification) for gdm's sockets, but the same idea would. (I
think it's just broken that sockets persist on the filesystem after
their server is gone - a longstanding unix design screwup.)

For the session bus, the discovery problem is solved with the
DBUS_SESSION_BUS_ADDRESS environment variable.

One last note, if you do use a random socket name, you can avoid the
#ifdef linux thing in your code; just always use the tmpdir=/tmp
version. If you specify tmpdir then abstract sockets are automatically
used when available.

If you use a fixed socket name, you can avoid the ifdef by just never
using abstract sockets, since their primary benefit is avoiding the
cleanup problem, and with fixed socket names cleanup doesn't really
matter.

So either way you should not need any ifdef here.

Havoc


More information about the dbus mailing list