dbus_bus_get_unix_user() incorrect type and other possible issue

Simon McVittie simon.mcvittie at collabora.co.uk
Fri May 18 08:28:34 PDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, 18 May 2007 at 10:47:48 -0400, Doug Goldstein wrote:
> 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.

"Obviously"? long is guaranteed to be >= 32 bits, so I can't see
any problem. On architectures with a 64-bit long the top half will
always be 0, but that's not exactly an important bug.

> 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

On the other hand,

% dbus-send --session --dest=org.freedesktop.DBus --type=method_call \
  --print-reply / org.freedesktop.DBus.GetConnectionUnixUser \
  string:"org.gnome.Epiphany"

returns my UID, and

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

returns a UID too.

It appears the function only fails for the bus daemon itself - it
refuses to tell you its own uid. The specification does, in fact, say
"Returns the unix uid of the process connected to the server" so it's
arguably correct to do this, but it seems strange not to add the
necessary 3 lines of code (or whatever) for the daemon to special-case its
own bus name.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: OpenPGP key: http://www.pseudorandom.co.uk/2003/contact/ or pgp.net

iD8DBQFGTcYiWSc8zVUw7HYRAj66AJ9PkF5UecOcV9m2OmRzjVJTcfvIowCg6BG0
PG/ECQscjEih5ZRLLvAVP4Q=
=dBxF
-----END PGP SIGNATURE-----


More information about the dbus mailing list