UINT __stdcall ingres_cluster_isinstalled(MSIHANDLE hInstall) { MsiSetProperty(hInstall, "INGRES_CLUSTER_ISINSTALLED", "0"); if(CheckServiceExists("ClusSvc")) MsiSetProperty(hInstall, "INGRES_CLUSTER_ISINSTALLED", "1"); return (ERROR_SUCCESS); }
UINT __stdcall ingres_set_rep_reg_entries (MSIHANDLE ihnd) { HKEY hKey; char KeyName[256]; int status = 0; DWORD dwSize, dwDisposition, dwType; TCHAR tchValue[2048]; INSTALLSTATE iInstalled, iAction; BOOL bInstalled, bVer25, bVersion9X; char szID[3], szComponentGUID[39], szProductGUID[39]; bInstalled=bVer25=bVersion9X=FALSE; if (!MsiGetFeatureState(ihnd, "IngresReplicator", &iInstalled, &iAction)) { if (iInstalled==INSTALLSTATE_ABSENT && iAction==INSTALLSTATE_UNKNOWN) return ERROR_SUCCESS; } else return ERROR_SUCCESS; dwSize = sizeof(tchValue); if (MsiGetProperty( ihnd, "II_INSTALLATION", tchValue, &dwSize ) != ERROR_SUCCESS) { return (ERROR_INSTALL_FAILURE); } else { sprintf(KeyName, "Software\\IngresCorporation\\Ingres\\%s_Installation", tchValue); status = RegCreateKeyEx(HKEY_LOCAL_MACHINE, KeyName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition); } if (iInstalled == INSTALLSTATE_LOCAL) { /* ** Set up the InstalledFeatures registry key for possible use. */ dwType = REG_SZ; dwSize = sizeof(tchValue); if (RegQueryValueEx(hKey, "InstalledFeatures", NULL, &dwType, tchValue, &dwSize) != ERROR_SUCCESS) { strcpy(tchValue, "REP"); } else if (!strstr(tchValue, "REP")) strcat(tchValue, ",REP"); status = RegSetValueEx( hKey, "InstalledFeatures", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } dwSize=sizeof(szID); MsiGetProperty(ihnd, "II_INSTALLATION", szID, &dwSize); if (!_stricmp(szID, "II")) strcpy(szComponentGUID, "{531C8AD8-2F05-11D5-BDFC-00B0D0AD4485}"); else { int idx; idx = (toupper(szID[0]) - 'A') * 26 + toupper(szID[1]) - 'A'; if (idx <= 0) idx = (toupper(szID[0]) - 'A') * 26 + toupper(szID[1]) - '0'; sprintf(szComponentGUID, "{531C8AD8-2F05-11D5-%04X-%012X}", idx, idx*idx); } dwSize=sizeof(szProductGUID); MsiGetProperty(ihnd, "ProductCode", szProductGUID, &dwSize); if (iAction==INSTALLSTATE_ABSENT && GetRefCount(szComponentGUID, szProductGUID)==0) { /* ** Set up the RemovedFeatures registry key for use later on. */ dwType = REG_SZ; dwSize = sizeof(tchValue); if (RegQueryValueEx(hKey, "RemovedFeatures", NULL, &dwType, tchValue, &dwSize) != ERROR_SUCCESS) { strcpy(tchValue, "REP"); } else if (!strstr(tchValue, "REP")) strcat(tchValue, ",REP"); status = RegSetValueEx( hKey, "RemovedFeatures", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); RegCloseKey(hKey); return (status==ERROR_SUCCESS ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE); } else if (iInstalled == INSTALLSTATE_LOCAL || iAction != INSTALLSTATE_LOCAL) { dwSize = sizeof(tchValue); if (!MsiGetProperty(ihnd, "INGRES_UPGRADE", tchValue, &dwSize) && strcmp(tchValue, "2")) { RegCloseKey(hKey); return (ERROR_SUCCESS); } } strcpy(tchValue, "TRUE"); status = RegSetValueEx( hKey, "Ingres/Replicator", 0, REG_SZ, (CONST BYTE *)&tchValue, strlen(tchValue) + 1 ); dwType = REG_SZ; dwSize = sizeof(tchValue); if (RegQueryValueEx(hKey, "PostInstallationNeeded", NULL, &dwType, tchValue, &dwSize) != ERROR_SUCCESS) { dwSize = sizeof(tchValue); if (status || MsiGetProperty( ihnd, "INGRES_SERVICEAUTO", tchValue, &dwSize ) != ERROR_SUCCESS) { return (ERROR_INSTALL_FAILURE); } else { char szBuf[MAX_PATH+1]; sprintf(szBuf, "Ingres_Database_%s", szID); if (CheckServiceExists(szBuf)) { if (IsServiceStartupTypeAuto(szBuf)) sprintf(tchValue, "1"); else sprintf(tchValue, "0"); status = RegSetValueEx( hKey, "serviceauto", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } else status = RegSetValueEx( hKey, "serviceauto", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } dwSize = sizeof(tchValue); if (status || MsiGetProperty( ihnd, "INGRES_SERVICELOGINID", tchValue, &dwSize ) != ERROR_SUCCESS) { return (ERROR_INSTALL_FAILURE); } else { status = RegSetValueEx( hKey, "serviceloginid", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } dwSize = sizeof(tchValue); if (status || MsiGetProperty( ihnd, "INGRES_SERVICEPASSWORD", tchValue, &dwSize ) != ERROR_SUCCESS) { return (ERROR_INSTALL_FAILURE); } else { /* Clear the password from the property table. */ MsiSetProperty(ihnd, "INGRES_SERVICEPASSWORD", ""); MsiSetProperty(ihnd, "INGRES_SERVICEPASSWORD2", ""); status = RegSetValueEx( hKey, "servicepassword", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } strcpy(tchValue, "YES"); status = RegSetValueEx( hKey, "PostInstallationNeeded", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); MsiSetProperty(ihnd, "INGRES_POSTINSTALLATIONNEEDED", "1"); dwSize = sizeof(tchValue); MsiGetProperty(ihnd, "INGRES_RSP_LOC", tchValue, &dwSize); if (tchValue[0] && strcmp(tchValue, "0")) { strcpy(tchValue, "YES"); RegSetValueEx( hKey, "SilentInstall", 0, REG_SZ, (CONST BYTE *)&tchValue, strlen(tchValue) + 1 ); } dwSize = sizeof(tchValue); MsiGetProperty(ihnd, "Installed", tchValue, &dwSize); if (tchValue[0]) bInstalled=TRUE; dwSize = sizeof(tchValue); MsiGetProperty(ihnd, "INGRES_VER25", tchValue, &dwSize); if (tchValue[0] && !strcmp(tchValue, "1")) bVer25=0; dwSize=sizeof(tchValue); MsiGetProperty(ihnd, "Version9X", tchValue, &dwSize); if (tchValue[0]) bVersion9X=TRUE; if (!bInstalled && !bVer25 && bVersion9X) { strcpy(tchValue, "YES"); RegSetValueEx( hKey, "RebootNeeded", 0, REG_SZ, (CONST BYTE *)&tchValue, strlen(tchValue) + 1 ); } } return (status == ERROR_SUCCESS ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE); }
UINT __stdcall ingres_set_odbc_reg_entries (MSIHANDLE ihnd) { HKEY hKey, hKey2; char KeyName[256], KeyNameODBC[256]; int status = 0; DWORD dwSize, dwDisposition, dwType; TCHAR tchValue[2048]; INSTALLSTATE iInstalled, iAction; BOOL ODBC_Installed = FALSE; BOOL bInstalled, bVer25, bVersion9X; char szCode[3], szComponent[39], szProduct[39]; ODBC_Installed = FALSE; bInstalled=bVer25=bVersion9X=FALSE; if (!MsiGetComponentState(ihnd, "Bin.70DC58B6_2D77_11D5_BDFC_00B0D0AD4485", &iInstalled, &iAction)) { if (iInstalled==INSTALLSTATE_ABSENT && iAction==INSTALLSTATE_UNKNOWN) return ERROR_SUCCESS; } else return ERROR_SUCCESS; dwSize = sizeof(tchValue); if (MsiGetProperty( ihnd, "II_INSTALLATION", tchValue, &dwSize ) != ERROR_SUCCESS) { return (ERROR_INSTALL_FAILURE); } else { strcpy(szCode, tchValue); sprintf(KeyName, "Software\\IngresCorporation\\Ingres\\%s_Installation", tchValue); status = RegCreateKeyEx(HKEY_LOCAL_MACHINE, KeyName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition); } dwSize = sizeof(szProduct); MsiGetProperty(ihnd, "ProductCode", szProduct, &dwSize); if (!_stricmp(szCode, "II")) strcpy(szComponent, "{8FA72934-D481-405A-AD90-B7BDE7988247}"); else { int idx; idx = (toupper(szCode[0]) - 'A') * 26 + toupper(szCode[1]) - 'A'; if (idx <= 0) idx = (toupper(szCode[0]) - 'A') * 26 + toupper(szCode[1]) - '0'; sprintf(szComponent, "{8FA72934-D481-405A-%04X-%012X}", idx, idx*idx); } dwSize=sizeof(tchValue); MsiGetComponentPath(szProduct, szComponent, tchValue, &dwSize); if (tchValue[0] && iInstalled==INSTALLSTATE_LOCAL) ODBC_Installed = TRUE; if (ODBC_Installed) { /* ** Set up the InstalledFeatures registry key for possible use. */ dwType = REG_SZ; dwSize = sizeof(tchValue); if (RegQueryValueEx(hKey, "InstalledFeatures", NULL, &dwType, tchValue, &dwSize) != ERROR_SUCCESS) { strcpy(tchValue, "ODBC"); } else strcat(tchValue, ",ODBC"); status = RegSetValueEx( hKey, "InstalledFeatures", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } if (iAction==INSTALLSTATE_ABSENT) { /* ** Set up the RemovedFeatures registry key for use later on. */ dwType = REG_SZ; dwSize = sizeof(tchValue); if (RegQueryValueEx(hKey, "RemovedFeatures", NULL, &dwType, tchValue, &dwSize) != ERROR_SUCCESS) { strcpy(tchValue, "ODBC"); } else strcat(tchValue, ",ODBC"); status = RegSetValueEx( hKey, "RemovedFeatures", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); RegCloseKey(hKey); return (status==ERROR_SUCCESS ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE); } else if (ODBC_Installed || iAction!=INSTALLSTATE_LOCAL) { dwSize = sizeof(tchValue); if (!MsiGetProperty(ihnd, "INGRES_UPGRADE", tchValue, &dwSize) && strcmp(tchValue, "2")) { RegCloseKey(hKey); return (ERROR_SUCCESS); } } dwSize = sizeof(tchValue); if (status || MsiGetProperty( ihnd, "INGRES_ODBC", tchValue, &dwSize ) != ERROR_SUCCESS) { return (ERROR_INSTALL_FAILURE); } else { status = RegSetValueEx( hKey, "setup_ingresodbc", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } dwSize = sizeof(tchValue); if (status || MsiGetProperty( ihnd, "INGRES_ODBC_READONLY", tchValue, &dwSize ) != ERROR_SUCCESS) { return (ERROR_INSTALL_FAILURE); } else { status = RegSetValueEx( hKey, "setup_ingresodbcreadonly", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } //check if read-only odbc driver was installed by ODBC patch installer if ((!strcmp(tchValue, "") || !strcmp(tchValue, "0")) && ODBC_Installed && iAction==INSTALLSTATE_LOCAL) { sprintf(KeyNameODBC, "SOFTWARE\\ODBC\\ODBCINST.INI\\Ingres"); if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, KeyNameODBC, 0, KEY_QUERY_VALUE, &hKey2)) { /* the comment out part is a better way of doing the check but Ingres isn't ready for it ** b/c of older releases DriverReadOnly can't be trusted yet. */ /*dwSize=sizeof(tchValue); if ((status = RegQueryValueEx(hKey2, "DriverReadOnly", 0, NULL, (BYTE *)tchValue, &dwSize)) == ERROR_SUCCESS) { if (!strcmp(tchValue, "Y")) status = RegSetValueEx( hKey, "setup_ingresodbcreadonly", 0, REG_SZ, "1", strlen("1") + 1 ); } else if (status == ERROR_FILE_NOT_FOUND) {*/ dwSize=sizeof(tchValue); if (!RegQueryValueEx(hKey2, "Driver", 0, NULL, (BYTE *)tchValue, &dwSize)) { if (strstr(tchValue, "caiiro") > 0) { status = RegSetValueEx( hKey, "setup_ingresodbcreadonly", 0, REG_SZ, "1", strlen("1") + 1 ); //Update the property for future possible upgrades of the release MsiSetProperty( ihnd, "INGRES_ODBC_READONLY", "1" ); } } //} RegCloseKey(hKey2); } } strcpy(tchValue, "TRUE"); status = RegSetValueEx( hKey, "Ingres ODBC Driver", 0, REG_SZ, (CONST BYTE *)&tchValue, strlen(tchValue) + 1 ); dwType = REG_SZ; dwSize = sizeof(tchValue); if (RegQueryValueEx(hKey, "PostInstallationNeeded", NULL, &dwType, tchValue, &dwSize) != ERROR_SUCCESS) { dwSize = sizeof(tchValue); if (status || MsiGetProperty( ihnd, "INGRES_SERVICEAUTO", tchValue, &dwSize ) != ERROR_SUCCESS) { return (ERROR_INSTALL_FAILURE); } else { char szBuf[MAX_PATH+1]; sprintf(szBuf, "Ingres_Database_%s", szCode); if (CheckServiceExists(szBuf)) { if (IsServiceStartupTypeAuto(szBuf)) sprintf(tchValue, "1"); else sprintf(tchValue, "0"); status = RegSetValueEx( hKey, "serviceauto", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } else status = RegSetValueEx( hKey, "serviceauto", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } dwSize = sizeof(tchValue); if (status || MsiGetProperty( ihnd, "INGRES_SERVICELOGINID", tchValue, &dwSize ) != ERROR_SUCCESS) { return (ERROR_INSTALL_FAILURE); } else { status = RegSetValueEx( hKey, "serviceloginid", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } dwSize = sizeof(tchValue); if (status || MsiGetProperty( ihnd, "INGRES_SERVICEPASSWORD", tchValue, &dwSize ) != ERROR_SUCCESS) { return (ERROR_INSTALL_FAILURE); } else { /* Clear the password from the property table. */ MsiSetProperty(ihnd, "INGRES_SERVICEPASSWORD", ""); MsiSetProperty(ihnd, "INGRES_SERVICEPASSWORD2", ""); status = RegSetValueEx( hKey, "servicepassword", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } strcpy(tchValue, "YES"); status = RegSetValueEx( hKey, "PostInstallationNeeded", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); MsiSetProperty(ihnd, "INGRES_POSTINSTALLATIONNEEDED", "1"); dwSize = sizeof(tchValue); MsiGetProperty(ihnd, "INGRES_RSP_LOC", tchValue, &dwSize); if (tchValue[0] && strcmp(tchValue, "0")) { strcpy(tchValue, "YES"); RegSetValueEx( hKey, "SilentInstall", 0, REG_SZ, (CONST BYTE *)&tchValue, strlen(tchValue) + 1 ); } dwSize = sizeof(tchValue); MsiGetProperty(ihnd, "Installed", tchValue, &dwSize); if (tchValue[0]) bInstalled=TRUE; dwSize = sizeof(tchValue); MsiGetProperty(ihnd, "INGRES_VER25", tchValue, &dwSize); if (tchValue[0] && !strcmp(tchValue, "1")) bVer25=0; dwSize=sizeof(tchValue); MsiGetProperty(ihnd, "Version9X", tchValue, &dwSize); if (tchValue[0]) bVersion9X=TRUE; if (!bInstalled && !bVer25 && bVersion9X) { strcpy(tchValue, "YES"); RegSetValueEx( hKey, "RebootNeeded", 0, REG_SZ, (CONST BYTE *)&tchValue, strlen(tchValue) + 1 ); } } return (status == ERROR_SUCCESS ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE); }
/* Checks SERVICENAME, PORT and BUFFERSIZE parameters */ extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall) { wchar_t ServiceName[MAX_PATH]={0}; wchar_t SkipNetworking[MAX_PATH]={0}; wchar_t QuickConfig[MAX_PATH]={0}; wchar_t Password[MAX_PATH]={0}; wchar_t EscapedPassword[2*MAX_PATH+2]; wchar_t Port[6]; wchar_t BufferPoolSize[16]; DWORD PortLen=6; bool haveInvalidPort=false; const wchar_t *ErrorMsg=0; HRESULT hr= S_OK; UINT er= ERROR_SUCCESS; hr = WcaInitialize(hInstall, __FUNCTION__); ExitOnFailure(hr, "Failed to initialize"); WcaLog(LOGMSG_STANDARD, "Initialized."); DWORD ServiceNameLen = MAX_PATH; MsiGetPropertyW (hInstall, L"SERVICENAME", ServiceName, &ServiceNameLen); if(ServiceName[0]) { if(ServiceNameLen > 256) { ErrorMsg= L"Invalid service name. The maximum length is 256 characters."; goto LExit; } for(DWORD i=0; i< ServiceNameLen;i++) { if(ServiceName[i] == L'\\' || ServiceName[i] == L'/' || ServiceName[i]=='\'' || ServiceName[i] ==L'"') { ErrorMsg = L"Invalid service name. Forward slash and back slash are forbidden." L"Single and double quotes are also not permitted."; goto LExit; } } if(CheckServiceExists(ServiceName)) { ErrorMsg= L"A service with the same name already exists. " L"Please use a different name."; goto LExit; } } DWORD PasswordLen= MAX_PATH; MsiGetPropertyW (hInstall, L"PASSWORD", Password, &PasswordLen); EscapeCommandLine(Password, EscapedPassword, sizeof(EscapedPassword)/sizeof(EscapedPassword[0])); MsiSetPropertyW(hInstall,L"ESCAPEDPASSWORD",EscapedPassword); DWORD SkipNetworkingLen= MAX_PATH; MsiGetPropertyW(hInstall, L"SKIPNETWORKING", SkipNetworking, &SkipNetworkingLen); MsiGetPropertyW(hInstall, L"PORT", Port, &PortLen); if(SkipNetworking[0]==0 && Port[0] != 0) { /* Strip spaces */ for(DWORD i=PortLen-1; i > 0; i--) { if(Port[i]== ' ') Port[i] = 0; } if(PortLen > 5 || PortLen <= 3) haveInvalidPort = true; else { for (DWORD i=0; i< PortLen && Port[i] != 0;i++) { if(Port[i] < '0' || Port[i] >'9') { haveInvalidPort=true; break; } } } if (haveInvalidPort) { ErrorMsg = L"Invalid port number. Please use a number between 1025 and 65535."; goto LExit; } short port = (short)_wtoi(Port); if (!IsPortFree(port)) { ErrorMsg = L"The TCP Port you selected is already in use. " L"Please choose a different port."; goto LExit; } } DWORD QuickConfigLen = MAX_PATH; MsiGetPropertyW (hInstall, L"STDCONFIG", QuickConfig, &QuickConfigLen); if(QuickConfig[0] !=0) { MEMORYSTATUSEX memstatus; memstatus.dwLength =sizeof(memstatus); wchar_t invalidValueMsg[256]; if (!GlobalMemoryStatusEx(&memstatus)) { WcaLog(LOGMSG_STANDARD, "Error %u from GlobalMemoryStatusEx", GetLastError()); er= ERROR_INSTALL_FAILURE; goto LExit; } DWORD BufferPoolSizeLen= 16; MsiGetPropertyW(hInstall, L"BUFFERPOOLSIZE", BufferPoolSize, &BufferPoolSizeLen); /* Strip spaces */ for(DWORD i=BufferPoolSizeLen-1; i > 0; i--) { if(BufferPoolSize[i]== ' ') BufferPoolSize[i] = 0; } unsigned long long availableMemory= GetMaxBufferSize(memstatus.ullTotalPhys)/ONE_MB; swprintf_s(invalidValueMsg, L"Invalid buffer pool size. Please use a number between 1 and %llu", availableMemory); if(BufferPoolSizeLen == 0 || BufferPoolSizeLen > 15) { ErrorMsg= invalidValueMsg; goto LExit; } for (DWORD i=0; i < BufferPoolSizeLen && BufferPoolSize[BufferPoolSizeLen]; i++) { if(BufferPoolSize[i]< '0' || BufferPoolSize[i] > '9') { ErrorMsg= invalidValueMsg; goto LExit; } } BufferPoolSize[BufferPoolSizeLen]=0; MsiSetPropertyW(hInstall, L"BUFFERPOOLSIZE", BufferPoolSize); long long sz = _wtoi64(BufferPoolSize); if(sz <= 0 || sz > (long long)availableMemory) { if(sz > 0) { swprintf_s(invalidValueMsg, L"Value for buffer pool size is too large." L"Only approximately %llu MB is available for allocation." L"Please use a number between 1 and %llu.", availableMemory, availableMemory); } ErrorMsg= invalidValueMsg; goto LExit; } } LExit: MsiSetPropertyW (hInstall, L"WarningText", ErrorMsg); return WcaFinalize(er); }