#endif
}
+static gchar *
+get_session_address_kdbus (void)
+{
+#ifdef G_OS_UNIX
+ gchar *ret = NULL;
+ gchar *bus;
+ GStatBuf buf;
+
+ bus = g_strdup_printf ("/sys/fs/kdbus/%d-user/bus", getuid());
+
+ /* if ENOENT, EPERM, etc., quietly don't use it */
+ if (g_stat (bus, &buf) < 0)
+ goto out;
+
+ ret = g_strconcat ("kernel:path=", bus, NULL);
+
+out:
+ g_free (bus);
+ return ret;
+#else
+ return NULL;
+#endif
+}
+
/* ---------------------------------------------------------------------------------------------------- */
#ifdef G_OS_UNIX
ret = g_strdup (g_getenv ("DBUS_SESSION_BUS_ADDRESS"));
if (ret == NULL)
{
- gchar *s;
- s = get_session_address_platform_specific (&local_error);
- ret = g_strdup_printf ("kernel:path=/sys/fs/kdbus/%d-user/bus;%s", getuid(), s);
- g_free(s);
+ ret = get_session_address_kdbus ();
+ if (ret == NULL)
+ ret = get_session_address_platform_specific (&local_error);
+ if (ret == NULL)
+ goto out;
}
break;