Permalink
Browse files

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

…ance on PATH
  • Loading branch information...
(no author)
(no author) committed Oct 19, 2010
1 parent f8ae328 commit cc06e430515d2bbe641455c5a792789eedf09708
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,
@@ -477,6 +474,31 @@ static HRESULT CfixctlsSpawnHost(
return Hr;
}
//
// 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.
//
@@ -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.