diff --git a/configure.in b/configure.in index c0a831b..9fc8241 100644 --- a/configure.in +++ b/configure.in @@ -465,7 +465,7 @@ AC_DEFINE_UNQUOTED([DBUS_USE_SYNC], [$have_sync], [Use the gcc __sync extension] AC_SEARCH_LIBS(socket,[socket network]) AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)]) -AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll setlocale localeconv strtoll strtoull) +AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll setlocale localeconv strtoll strtoull gethostuuid) #### Check for broken poll; taken from Glib's configure diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index e859ec6..6f295c3 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3278,6 +3278,7 @@ _dbus_get_autolaunch_address (DBusString *address, * without rebooting I believe). If there's no standard one * we might want to use the registry instead of a file for * this, and I'm not sure how we'd ensure the uuid gets created. + * On OSX >= 10.6, uses function gethostuuid() to get hardware UUID. * * @param machine_id guid to init with the machine's uuid * @param create_if_not_found try to create the uuid if it doesn't exist @@ -3289,9 +3290,25 @@ _dbus_read_local_machine_uuid (DBusGUID *machine_id, dbus_bool_t create_if_not_found, DBusError *error) { +#ifndef HAVE_GETHOSTUUID DBusString filename; - _dbus_string_init_const (&filename, DBUS_MACHINE_UUID_FILE); + const char *uuidfile = _dbus_getenv ("DBUS_MACHINE_UUID_FILE"); + if (uuidfile == NULL) + uuidfile = DBUS_MACHINE_UUID_FILE; + _dbus_string_init_const (&filename, uuidfile); return _dbus_read_uuid_file (&filename, machine_id, create_if_not_found, error); +#else + uuid_t uuid; + struct timespec timeout = {0, 0}; + if (gethostuuid (uuid, &timeout) == -1) + { + dbus_set_error (error, DBUS_ERROR_FAILED, + "Failed to retrieve host UUID\n"); + return FALSE; + } + memcpy (machine_id->as_bytes, uuid, DBUS_UUID_LENGTH_BYTES); + return TRUE; +#endif } #define DBUS_UNIX_STANDARD_SESSION_SERVICEDIR "/dbus-1/services"