diff options
author | Ralf Habacker <ralf.habacker@freenet.de> | 2011-12-21 21:24:03 +0100 |
---|---|---|
committer | Ralf Habacker <ralf.habacker@freenet.de> | 2011-12-22 12:51:21 +0100 |
commit | 16e6236b8310d41d0f21923bb87fa4cf148919d0 (patch) | |
tree | aea9bc826ae7d08e2859c83eabf284dbb2dda3a2 | |
parent | 66a4f22841bd4fc942eb9cfac7aaf17577e0bd56 (diff) |
windows fix: use install root as base path for relative pathes in dbus service file
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=44030
-rw-r--r-- | dbus/dbus-spawn-win.c | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/dbus/dbus-spawn-win.c b/dbus/dbus-spawn-win.c index b0cf90f1..a7416cb6 100644 --- a/dbus/dbus-spawn-win.c +++ b/dbus/dbus-spawn-win.c @@ -544,6 +544,7 @@ spawn_program (char* name, char** argv, char** envp) STARTUPINFOA si; char *arg_string, *env_string; BOOL result; + char exe_path[MAX_PATH]; #ifdef DBUS_WINCE if (argv && argv[0]) @@ -558,14 +559,45 @@ spawn_program (char* name, char** argv, char** envp) env_string = build_env_string(envp); +#ifndef DBUS_WINCE + // handle relative pathes + if (strlen(name) > 2 && name[0] != '\\' && name[0] != '/' && name[1] != ':') + { + _dbus_verbose ("babysitter: spawning %s", name); + char install_root[2*MAX_PATH]; + LPSTR lpFile; + char *p; + if (!_dbus_get_install_root (install_root, sizeof(install_root))) + return INVALID_HANDLE_VALUE; + + strcat(install_root,name); + + // add exe extension, if not present + p = strrchr(name,'.'); + if (!p) + strcat(install_root,".exe"); + + // convert '/' into '\\' + while((p = strchr(install_root,'/')) != 0) + *p = '\\'; + + // separate path from filename + p = strrchr(install_root,'\\'); + // no complete path: error condition + if (!p) + return INVALID_HANDLE_VALUE; + *p = 0; + if (!SearchPathA(install_root, p+1, NULL, sizeof(exe_path), exe_path, &lpFile)) + return INVALID_HANDLE_VALUE; + } + else +#endif + strncpy(exe_path,name,MAX_PATH); + memset (&si, 0, sizeof (si)); si.cb = sizeof (si); -#ifdef DBUS_WINCE - result = CreateProcessA (name, arg_string, NULL, NULL, FALSE, 0, -#else - result = CreateProcessA (NULL, arg_string, NULL, NULL, FALSE, 0, -#endif - (LPVOID)env_string, NULL, &si, &pi); + result = CreateProcessA (exe_path, arg_string, NULL, NULL, FALSE, 0, + (LPVOID)env_string, NULL, &si, &pi); free (arg_string); if (env_string) free (env_string); |