Permalink
Browse files

Use absolute path to cfixctl.dll in emb.envvar in order to avoid reli…

…ance on PATH
  • Loading branch information...
1 parent f8ae328 commit cc06e430515d2bbe641455c5a792789eedf09708 (no author) committed Oct 19, 2010
Showing with 29 additions and 6 deletions.
  1. +29 −6 src/cfixctl/cfixctl/localagent.cpp
@@ -331,9 +331,6 @@ static HRESULT CfixctlsGetObjrefMonikerString(
return Hr;
}
-#define CFIXCTLP_EMB_INIT_ENVVAR \
- CFIX_EMB_INIT_ENVVAR_NAME L"=cfixctl.dll!CfixctlServeHost"
-
static HRESULT CfixctlsSpawnHost(
__in ICfixAgent *Agent,
__in CfixTestModuleArch Arch,
@@ -478,6 +475,31 @@ static HRESULT CfixctlsSpawnHost(
}
//
+ // Prepare embedding environment variable.
+ //
+ // N.B. Use absolute path to DLL in order not ro rely on PATH.
+ //
+ WCHAR OwnDllPath[ MAX_PATH ];
+ if ( !GetModuleFileName(
+ CfixctlpGetModule(),
+ OwnDllPath,
+ _countof( OwnDllPath ) ) )
+ {
+ return HRESULT_FROM_WIN32( GetLastError() );
+ }
+
+ WCHAR EmbeddingEnvVar[ 300 ];
+ Hr = StringCchPrintf(
+ EmbeddingEnvVar,
+ _countof( EmbeddingEnvVar ),
+ CFIX_EMB_INIT_ENVVAR_NAME L"=%s!CfixctlServeHost",
+ OwnDllPath );
+ if ( FAILED( Hr ) )
+ {
+ return Hr;
+ }
+
+ //
// Prepare environment.
//
// The environment consists of the custom environment (if any)
@@ -493,7 +515,7 @@ static HRESULT CfixctlsSpawnHost(
//
// Embedding\n.
//
- ( CustomHostPath == NULL ? 0 : wcslen( CFIXCTLP_EMB_INIT_ENVVAR ) + 1 ) +
+ ( CustomHostPath == NULL ? 0 : wcslen( EmbeddingEnvVar ) + 1 ) +
//
// name=value\n
@@ -520,9 +542,10 @@ static HRESULT CfixctlsSpawnHost(
Hr = StringCchPrintf(
FullEnvironment,
FullEnvironmentCch,
- L"%s%s" CFIXCTLP_MONIKER_ENVVAR_NAME L"=%s\n",
+ L"%s%s%s" CFIXCTLP_MONIKER_ENVVAR_NAME L"=%s\n",
CustomEnvironment ? CustomEnvironment : L"",
- CustomHostPath ? CFIXCTLP_EMB_INIT_ENVVAR L"\n" : L"",
+ CustomHostPath ? EmbeddingEnvVar : L"",
+ CustomHostPath ? L"\n" : L"",
AgentMkDisplayName
);
if ( FAILED( Hr ) )

0 comments on commit cc06e43

Please sign in to comment.