dbus_bus_get_unix_user() incorrect type and other possible issue

Doug Goldstein cardoe at gentoo.org
Fri May 18 07:47:48 PDT 2007


Currently dbus_bus_get_unix_user() is defined as follows:

http://dbus.freedesktop.org/doc/api/html/dbus-bus_8c-source.html

unsigned long
dbus_bus_get_unix_user <http://dbus.freedesktop.org/doc/api/html/group__DBusBus.html#g3233d29e4495f8bffffe360581e330ec> (DBusConnection <http://dbus.freedesktop.org/doc/api/html/structDBusConnection.html> *connection,
                        const char     *name,
                        DBusError <http://dbus.freedesktop.org/doc/api/html/structDBusError.html>      *error)


dbus_bus_get_unix_user() is suppose to return the uid of the user. A uid
on a Linux/BSD platform is defined as a uid_t, which is always an
unsigned 32 bit integer. Internally the function uses a dbus_uint32_t
and does it's processing with that. However it returns an unsigned long,
which on x86 is fine. However if you go to other platforms it can and is
a different size (most notably amd64 where it's 64 bits). So obviously
the type is wrong. It should return either uid_t, which might not be
defined everywhere or just a dbus_uint32_t.

Next I was looking at it because I was trying to debug some HAL code
that calls that function and constantly fails. I tried to do the following..

dbus-send --system --dest=org.freedesktop.DBus --type=method_call
--print-reply / org.freedesktop.DBus.GetConnectionUnixUser
string:"org.freedesktop.DBus"

And that returns:

Error org.freedesktop.DBus.Error.NameHasNoOwner: Could not get UID of
name 'org.freedesktop.DBus': no such name

So it appears to always fail..

Any insight would be very helpful.


More information about the dbus mailing list