in host/common/hostagenthelpers.cpp [4540:4713]
HRESULT GetFTPParamsFromRegistry( const char *pszSVRootKey,
SV_HOST_AGENT_PARAMS *pSV_HOST_AGENT_PARAMS )
{
HRESULT hr = S_OK;
char szValue[ 256 ];
CRegKey cregkey;
DWORD dwTmpPort;
DWORD dwCount = 0;
SVERROR svhr = SVS_OK;
char *FTPPassword = NULL;
do
{
DebugPrintf( "@ LINE %d in FILE %s \n", __LINE__, __FILE__ );
DebugPrintf( "ENTERED GetAgentParamsFromRegistry()...\n" );
if( ( NULL == pszSVRootKey ) ||
( NULL == pSV_HOST_AGENT_PARAMS ) )
{
hr = E_INVALIDARG;
DebugPrintf( "@ LINE %d in FILE %s \n", __LINE__, __FILE__ );
DebugPrintf( hr, "FAILED GetAgentParamsFromRegistry()... hr = %08X\n", hr );
break;
}
USES_CONVERSION;
//
//
//
DWORD dwResult = ERROR_SUCCESS;
dwResult = cregkey.Open( HKEY_LOCAL_MACHINE,
pszSVRootKey );
if( ERROR_SUCCESS != dwResult )
{
hr = HRESULT_FROM_WIN32( dwResult );
DebugPrintf( "@ LINE %d in FILE %s \n", __LINE__, __FILE__ );
DebugPrintf( hr, "FAILED cregkey.Open()... hr = %08X\n", hr );
break;
}
//
// Ashish - 05/01/04 - added registry calles to extract FTP information
//
dwCount = sizeof( szValue );
dwResult = cregkey.QueryStringValue( SV_FTP_HOST_VALUE_NAME, szValue, &dwCount );
if( ERROR_SUCCESS == dwResult )
{
inm_strcpy_s( pSV_HOST_AGENT_PARAMS->szSVFTPHost, ARRAYSIZE(pSV_HOST_AGENT_PARAMS->szSVFTPHost), szValue );
}
else
{
DebugPrintf( "@ LINE %d in FILE %s \n", __LINE__, __FILE__ );
DebugPrintf( hr, "WARNING cregkey.QueryValue()... key: %s; using default value. hr = %08X\n", SV_FTP_HOST_VALUE_NAME, HRESULT_FROM_WIN32( GetLastError() ) );
inm_strcpy_s( pSV_HOST_AGENT_PARAMS->szSVFTPHost, ARRAYSIZE(pSV_HOST_AGENT_PARAMS->szSVFTPHost), pSV_HOST_AGENT_PARAMS->szSVServerName );
}
//FTP User Name
dwCount = sizeof( szValue );
dwResult = cregkey.QueryStringValue( SV_FTP_USER_VALUE_NAME, szValue, &dwCount );
if( ERROR_SUCCESS == dwResult )
{
inm_strcpy_s( pSV_HOST_AGENT_PARAMS->szSVFTPUserName, ARRAYSIZE(pSV_HOST_AGENT_PARAMS->szSVFTPUserName), szValue );
dwCount = sizeof( szValue );
}
else
{
DebugPrintf( "@ LINE %d in FILE %s \n", __LINE__, __FILE__ );
DebugPrintf( hr, "WARNING cregkey.QueryValue()... key: %s; using default value. hr = %08X\n", SV_FTP_USER_VALUE_NAME, HRESULT_FROM_WIN32( GetLastError() ) );
inm_strcpy_s( pSV_HOST_AGENT_PARAMS->szSVFTPUserName, ARRAYSIZE(pSV_HOST_AGENT_PARAMS->szSVFTPUserName), SV_FTP_LOGIN );
}
//FTP Password
// Bugfix for bug26 - get the FTPPassword from config instead of
// from local registry
//
FTPPassword = new char[LENGTH_TRANSPORT_PASSWORD + 1];
if( NULL == FTPPassword )
{
hr = E_OUTOFMEMORY;
DebugPrintf( "@ LINE %d in FILE %s \n", __LINE__, __FILE__ );
DebugPrintf( hr, "FAILED new()... hr = %08X\n", hr );
// use the default FTP password
inm_strcpy_s( pSV_HOST_AGENT_PARAMS->szSVFTPPassword, ARRAYSIZE(pSV_HOST_AGENT_PARAMS->szSVFTPPassword), SV_FTP_PASSWORD );
break;
}
inm_strncpy_s(FTPPassword, LENGTH_TRANSPORT_PASSWORD + 1, SV_FTP_PASSWORD, LENGTH_TRANSPORT_PASSWORD);
FTPPassword[LENGTH_TRANSPORT_PASSWORD] = '\0';
inm_strcpy_s( pSV_HOST_AGENT_PARAMS->szSVFTPPassword, ARRAYSIZE(pSV_HOST_AGENT_PARAMS->szSVFTPPassword), FTPPassword );
//FTP Port
dwResult = cregkey.QueryDWORDValue( SV_FTP_PORT_VALUE_NAME, dwTmpPort );
if( ERROR_SUCCESS == dwResult )
{
pSV_HOST_AGENT_PARAMS->SVFTPPort = static_cast<INTERNET_PORT>( dwTmpPort );
}
else
{
DebugPrintf( "@ LINE %d in FILE %s \n", __LINE__, __FILE__ );
DebugPrintf( hr, "WARNING cregkey.QueryValue()... key: %s; using default value. hr = %08X\n", SV_FTP_PORT_VALUE_NAME, HRESULT_FROM_WIN32( GetLastError() ) );
pSV_HOST_AGENT_PARAMS->SVFTPPort = SV_FTP_PORT;
}
//FTP URL
dwCount = sizeof( szValue );
dwResult = cregkey.QueryStringValue( SV_FTP_URL_VALUE_NAME, szValue, &dwCount );
if( ERROR_SUCCESS == dwResult )
{
inm_strcpy_s( pSV_HOST_AGENT_PARAMS->szSVGetFTPInfoURL, ARRAYSIZE(pSV_HOST_AGENT_PARAMS->szSVGetFTPInfoURL), szValue );
dwCount = sizeof( szValue );
}
else
{
DebugPrintf( "@ LINE %d in FILE %s \n", __LINE__, __FILE__ );
DebugPrintf( hr, "WARNING cregkey.QueryValue()... key: %s; using default value. hr = %08X\n", SV_FTP_URL_VALUE_NAME, HRESULT_FROM_WIN32( GetLastError() ) );
inm_strcpy_s( pSV_HOST_AGENT_PARAMS->szSVGetFTPInfoURL, ARRAYSIZE(pSV_HOST_AGENT_PARAMS->szSVGetFTPInfoURL), SV_FTP_URL );
}
// Bug fix for #23
//
// SecureModes URL
dwCount = sizeof( szValue );
dwResult = cregkey.QueryStringValue( SV_SECURE_MODES_URL_VALUE_NAME, szValue, &dwCount );
if( ERROR_SUCCESS == dwResult )
{
inm_strcpy_s( pSV_HOST_AGENT_PARAMS->szSVGetSecureModesInfoURL, ARRAYSIZE(pSV_HOST_AGENT_PARAMS->szSVGetSecureModesInfoURL), szValue );
dwCount = sizeof( szValue );
}
else
{
DebugPrintf( "@ LINE %d in FILE %s \n", __LINE__, __FILE__ );
DebugPrintf( hr, "WARNING cregkey.QueryValue()... key: %s; using default value. hr = %08X\n", SV_SECURE_MODES_URL_VALUE_NAME, HRESULT_FROM_WIN32( GetLastError() ) );
inm_strcpy_s( pSV_HOST_AGENT_PARAMS->szSVGetSecureModesInfoURL, ARRAYSIZE(pSV_HOST_AGENT_PARAMS->szSVGetSecureModesInfoURL), SV_SECURE_MODES_URL );
}
//SSL Key Path
dwCount = sizeof( szValue );
dwResult = cregkey.QueryStringValue( SV_SSL_KEY_PATH, szValue, &dwCount );
if( ERROR_SUCCESS == dwResult )
{
inm_strcpy_s( pSV_HOST_AGENT_PARAMS->szSVSSLKeyPath, ARRAYSIZE(pSV_HOST_AGENT_PARAMS->szSVSSLKeyPath), szValue );
dwCount = sizeof( szValue );
}
else
{
DebugPrintf( "@ LINE %d in FILE %s \n", __LINE__, __FILE__ );
DebugPrintf( hr, "WARNING cregkey.QueryValue()... key: %s; using default value. hr = %08X\n", SV_SSL_KEY_PATH, HRESULT_FROM_WIN32( GetLastError() ) );
inm_strcpy_s( pSV_HOST_AGENT_PARAMS->szSVSSLKeyPath, ARRAYSIZE(pSV_HOST_AGENT_PARAMS->szSVSSLKeyPath), SV_SSL_DEFAULT_SSLKEYPATH );
}
//SSL Cert Path
dwCount = sizeof( szValue );
dwResult = cregkey.QueryStringValue( SV_SSL_CERT_PATH, szValue, &dwCount );
if( ERROR_SUCCESS == dwResult )
{
inm_strcpy_s( pSV_HOST_AGENT_PARAMS->szSVSSLCertificatePath, ARRAYSIZE(pSV_HOST_AGENT_PARAMS->szSVSSLCertificatePath), szValue );
dwCount = sizeof( szValue );
}
else
{
DebugPrintf( "@ LINE %d in FILE %s \n", __LINE__, __FILE__ );
DebugPrintf( hr, "WARNING cregkey.QueryValue()... key: %s; using default value. hr = %08X\n", SV_SSL_CERT_PATH, HRESULT_FROM_WIN32( GetLastError() ) );
inm_strcpy_s( pSV_HOST_AGENT_PARAMS->szSVSSLCertificatePath, ARRAYSIZE(pSV_HOST_AGENT_PARAMS->szSVSSLCertificatePath), SV_SSL_DEFAULT_SSLCERTPATH );
}
}
while( FALSE );
delete [] FTPPassword;
cregkey.Close();
return( hr );
}