]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
Find dbus-daemon executable next to dbus shared libaray on windows.
authorJesper Dam <jalf@medical-insight.com>
Fri, 28 Oct 2011 13:54:30 +0000 (15:54 +0200)
committerRalf Habacker <ralf.habacker@freenet.de>
Fri, 28 Oct 2011 19:01:02 +0000 (21:01 +0200)
If the dbus shared library and the daemon executable are both in a dir
that is not part of the default search path and dbus-1.dll is dynamically
loaded with LoadLibrary(), it will fail to locate and launch the daemon
without this patch.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=41558
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
dbus/dbus-sysdeps-win.c

index a8c60bdaa5a91d9fd5ceb5d9c51493c3c0c8c82f..3bcf86acf71f4a3f8744af143336fe8f599c7be7 100644 (file)
@@ -2861,11 +2861,25 @@ _dbus_get_autolaunch_address (const char *scope, DBusString *address,
 
   if (!SearchPathA(NULL, daemon_name, NULL, sizeof(dbus_exe_path), dbus_exe_path, &lpFile))
     {
-      printf ("please add the path to %s to your PATH environment variable\n", daemon_name);
-      printf ("or start the daemon manually\n\n");
-      goto out;
+      // Look in directory containing dbus shared library
+      HMODULE hmod = _dbus_win_get_dll_hmodule();
+      char dbus_module_path[MAX_PATH];
+      DWORD rc = GetModuleFileNameA(hmod, dbus_module_path, sizeof(dbus_module_path));
+      if (rc > 0)
+        {
+          char *ext_idx = strrchr(dbus_module_path, '\\');
+          if (ext_idx)
+          *ext_idx = '\0';
+          if (!SearchPathA(dbus_module_path, daemon_name, NULL, sizeof(dbus_exe_path), dbus_exe_path, &lpFile))
+            {
+              printf ("please add the path to %s to your PATH environment variable\n", daemon_name);
+              printf ("or start the daemon manually\n\n");
+              goto out;
+            }
+        }
     }
 
+
   // Create process
   ZeroMemory( &si, sizeof(si) );
   si.cb = sizeof(si);