Code Block Purpose?

Doug Goldstein cardoe at gentoo.org
Fri May 18 07:42:33 PDT 2007


Everytime anyone on Gentoo starts HAL they get the following log entries
when using --verbose=yes --daemon=no

Apr 18 11:20:12 [hald] 11:20:12.874 [I] hald_runner.c:299: Runner has pid 15460_

Apr 18 11:20:12 [hald] 11:20:12.874 [W] ci-tracker.c:200: Could not get uid for connection: org.freedesktop.DBus.Error.NameHasNoOwner Could not get UID of name 'org.freedesktop.DBus': no such name_

Apr 18 11:20:12 [hald] 11:20:12.874 [E] hald_dbus.c:4462: Cannot get caller info for org.freedesktop.DBus_

Apr 18 11:20:12 [hald] 11:20:12.874 [I] hald_runner.c:180: runner connection is 0x5545f0_


Looking at the code.... ci-tracker.c lines 197 to 203:

        dbus_error_init (&error);
        ci->uid = dbus_bus_get_unix_user (cit->dbus_connection,
system_bus_unique_name, &error);
        if (ci->uid == ((unsigned long) -1) || dbus_error_is_set (&error)) {
                HAL_WARNING (("Could not get uid for connection: %s %s",
error.name, error.message));
                dbus_error_free (&error);
                goto error;
        }

We see that dbus_bus_get_unix_user() is failing. The check below that on
line 199 is invalid since dbus_bus_get_unix_user() returns an unsigned
long so the casting of -1 to an unsigned long, which in a perfect world
would be LONG_MAX will differ on amd64 machines and x86 machines which
means that check will always be bad. Further more, D-Bus returns
DBUS_UID_UNSET on failure. Also making that check and then trying to use
the error structure without actually verifying that there's any data in
the error structure (the next part of the if statement) is bad... So I
was working up some patches.. But in the mean time I asked the D-Bus
guys why that was failing..

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

Is the simple dbus test case and it seems that it always fails. It
appears it's not suppose to be called by apps outside of D-Bus. So
that's where my question comes in, before I provide a patch for the
above issues.. Why do we have that code?


More information about the hal mailing list