/*
- * Portions Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
+ * Portions Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC")
* Portions Copyright (C) 2001, 2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: BINDInstallDlg.cpp,v 1.37.228.1 2008/12/14 21:25:27 marka Exp $ */
+/* $Id: BINDInstallDlg.cpp,v 1.37.228.2 2008/12/14 21:33:07 tbox Exp $ */
/*
* Copyright (c) 1999-2000 by Nortel Networks Corporation
typedef struct _xexception
{
_xexception(UINT string, ...);
-
+
CString resString;
} Exception;
dirname[index] = '\0';
CString Dirname(dirname);
m_currentDir = Dirname;
-
+
CVersionInfo bindInst(filename);
if(bindInst.IsValid())
m_version.Format(IDS_VERSION, bindInst.GetFileVersionString());
&dwBufLen) == ERROR_SUCCESS)
if (strcmp(buf, ""))
m_defaultDir = buf;
-
+
RegCloseKey(hKey);
}
m_targetDir = m_defaultDir;
* User pressed the exit button
*/
void CBINDInstallDlg::OnExit() {
- EndDialog(0);
+ EndDialog(0);
}
/*
* User pressed the uninstall button. Make it go.
*/
void CBINDInstallDlg::OnUninstall() {
- UpdateData();
+ UpdateData();
if (MsgBox(IDS_UNINSTALL, MB_YESNO) == IDYES) {
if (CheckBINDService())
MsgBox(IDS_ERR_OPEN_SCM, GetErrMessage());
return;
}
-
+
SC_HANDLE hService = OpenService(hSCManager, BIND_SERVICE_NAME,
SERVICE_ALL_ACCESS);
if (!hService && GetLastError() != ERROR_SERVICE_DOES_NOT_EXIST){
QueryServiceStatus(hService, &ss);
if (ss.dwCurrentState == SERVICE_RUNNING) {
BOOL rc = ControlService(hService,
- SERVICE_CONTROL_STOP, &ss);
+ SERVICE_CONTROL_STOP, &ss);
if (rc == FALSE || ss.dwCurrentState != SERVICE_STOPPED) {
MsgBox(IDS_ERR_STOP_SERVICE, GetErrMessage());
return;
}
CloseServiceHandle(hService);
CloseServiceHandle(hSCManager);
-
+
// Directories
m_etcDir = m_targetDir + "\\etc";
m_binDir = m_targetDir + "\\bin";
else
GetDlgItem(IDC_CREATE_DIR)->SetWindowText("Not Removed");
-
+
// Delete registry keys for named
RegDeleteKey(HKEY_LOCAL_MACHINE, BIND_SESSION_SUBKEY);
RegDeleteKey(HKEY_LOCAL_MACHINE, BIND_SUBKEY);
RegDeleteKey(HKEY_LOCAL_MACHINE, BIND_UNINSTALL_SUBKEY);
-
+
ProgramGroup(FALSE);
SetCurrent(IDS_UNINSTALL_DONE);
/*
* Check that the Passwords entered match.
- */
+ */
if (m_accountPassword != m_accountPasswordConfirm) {
MsgBox(IDS_ERR_PASSWORD);
return;
MsgBox(IDS_ERR_WHITESPACE);
return;
}
-
+
/*
* Check the entered account name.
*/
#endif
try {
CreateDirs();
- CopyFiles();
+ CopyFiles();
RegisterService();
RegisterMessages();
RegCloseKey(hKey);
}
-
+
SetCurrent(IDS_ADD_REMOVE);
if (RegCreateKey(HKEY_LOCAL_MACHINE, BIND_UNINSTALL_SUBKEY,
&hKey) == ERROR_SUCCESS) {
(LPBYTE)(LPCTSTR)buf, buf.GetLength());
RegCloseKey(hKey);
}
-
+
ProgramGroup(FALSE);
-
+
if (m_startOnInstall)
StartBINDService();
}
SetCurrent(IDS_CREATE_DIR, m_binDir);
if (!CreateDirectory(m_binDir, NULL) && GetLastError() != ERROR_ALREADY_EXISTS)
throw(Exception(IDS_ERR_CREATE_DIR, m_binDir, GetErrMessage()));
-
+
SetItemStatus(IDC_CREATE_DIR);
}
installFiles[i].filename;
CString filespec = m_currentDir + "\\" + installFiles[i].filename;
CVersionInfo bindFile(destFile);
-
+
CVersionInfo origFile(filespec);
if (!origFile.IsValid() && installFiles[i].checkVer) {
if (MsgBox(IDS_FILE_BAD, MB_YESNO,
installFiles[i].filename,
GetErrMessage()));
}
-
+
try {
-/*
+/*
* Ignore Version checking. We need to make sure that all files get copied regardless
* of whether or not they are earlier or later versions since we cannot guarantee
* that we have either backward or forward compatibility between versions.
}
catch(...) {
if (installFiles[i].importance != FileData::Trivial) {
- if (installFiles[i].importance ==
+ if (installFiles[i].importance ==
FileData::Critical ||
MsgBox(IDS_ERR_NONCRIT_FILE, MB_YESNO,
installFiles[i].filename,
destFile = DestDir(installFiles[i].destination) + "\\" +
installFiles[i].filename;
-
+
if (uninstall)
SetCurrent(IDS_DELETE_FILE, installFiles[i].filename);
-
+
DeleteFile(destFile);
}
CString file = m_etcDir + "\\*.*";
BOOL rc;
HANDLE hFile;
-
+
hFile = FindFirstFile(file, &findData);
rc = hFile != INVALID_HANDLE_VALUE;
-
+
while (rc == TRUE) {
if (strcmp(findData.cFileName, ".") &&
strcmp(findData.cFileName, "..")) {
if (uninstall)
SetItemStatus(IDC_COPY_FILE, TRUE);
-}
+}
/*
* Get the service account name out of the registry, if any
else {
m_serviceExists = FALSE;
}
-
+
if (keyFound == TRUE) {
/* Get the named service account, if one was specified */
if (RegQueryValueEx(hKey, "ObjectName", NULL, NULL,
hService = CreateService(hSCManager, BIND_SERVICE_NAME,
BIND_DISPLAY_NAME, SERVICE_ALL_ACCESS, dwServiceType, dwStart,
SERVICE_ERROR_NORMAL, namedLoc, NULL, NULL, NULL, StartName,
- m_accountPassword);
-
+ m_accountPassword);
+
if (!hService && GetLastError() != ERROR_SERVICE_EXISTS)
throw(Exception(IDS_ERR_CREATE_SERVICE, GetErrMessage()));
if (RegCreateKey(HKEY_LOCAL_MACHINE, BIND_MESSAGE_SUBKEY, &hKey)
!= ERROR_SUCCESS)
throw(Exception(IDS_ERR_CREATE_KEY, GetErrMessage()));
-
+
/* Add the Event-ID message-file name to the subkey. */
if (RegSetValueEx(hKey, "EventMessageFile", 0, REG_EXPAND_SZ,
(LPBYTE)pszMsgDLL, strlen(pszMsgDLL) + 1) != ERROR_SUCCESS)
throw(Exception(IDS_ERR_SET_VALUE, GetErrMessage()));
RegCloseKey(hKey);
-
+
SetItemStatus(IDC_REG_MESSAGE);
}
/* Remove named from the list of messages sources */
if (RegDeleteKey(hKey, BIND_MESSAGE_NAME) != ERROR_SUCCESS)
break;
-
+
rc = TRUE;
break;
}
*/
void CBINDInstallDlg::InstallTags() {
CString tag;
-
+
tag.LoadString(IDS_INSTALL_FILE);
GetDlgItem(IDC_COPY_TAG)->SetWindowText(tag);
GetDlgItem(IDC_COPY_FILE)->SetWindowText("");
tag.LoadString(IDS_INSTALL_SERVICE);
GetDlgItem(IDC_SERVICE_TAG)->SetWindowText(tag);
-
+
tag.LoadString(IDS_INSTALL_MESSAGE);
GetDlgItem(IDC_MESSAGE_TAG)->SetWindowText(tag);
GetDlgItem(IDC_REG_MESSAGE)->SetWindowText("");
*/
void CBINDInstallDlg::UninstallTags() {
CString tag;
-
+
tag.LoadString(IDS_UNINSTALL_FILES);
GetDlgItem(IDC_COPY_TAG)->SetWindowText(tag);
GetDlgItem(IDC_COPY_FILE)->SetWindowText("");
tag.LoadString(IDS_UNINSTALL_SERVICE);
GetDlgItem(IDC_SERVICE_TAG)->SetWindowText(tag);
GetDlgItem(IDC_REG_SERVICE)->SetWindowText("");
-
+
tag.LoadString(IDS_UNINSTALL_MESSAGE);
GetDlgItem(IDC_MESSAGE_TAG)->SetWindowText(tag);
GetDlgItem(IDC_REG_MESSAGE)->SetWindowText("");
va_start(va, id);
vsprintf(buf, format, va);
va_end(va);
-
+
m_current.Format("%s", buf);
UpdateData(FALSE);
}
*/
void CBINDInstallDlg::StopBINDService() {
SERVICE_STATUS svcStatus;
-
+
SetCurrent(IDS_STOP_SERVICE);
SC_HANDLE hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (!hSCManager) {
MsgBox(IDS_ERR_OPEN_SCM, GetErrMessage());
}
-
+
SC_HANDLE hBINDSvc = OpenService(hSCManager, BIND_SERVICE_NAME,
SERVICE_ALL_ACCESS);
if (!hBINDSvc) {
MsgBox(IDS_ERR_OPEN_SERVICE, GetErrMessage());
}
-
+
BOOL rc = ControlService(hBINDSvc, SERVICE_CONTROL_STOP, &svcStatus);
}
if (!hSCManager) {
MsgBox(IDS_ERR_OPEN_SCM, GetErrMessage());
}
-
+
SC_HANDLE hBINDSvc = OpenService(hSCManager, BIND_SERVICE_NAME,
SERVICE_ALL_ACCESS);
if (!hBINDSvc) {
/*
* Display message boxes with variable args, using string table strings
- * for the format specifiers
+ * for the format specifiers
*/
int CBINDInstallDlg::MsgBox(int id, ...) {
CString format;
/*
* Call GetLastError(), retrieve the message associated with the error
*/
-CString CBINDInstallDlg::GetErrMessage(DWORD err) {
+CString CBINDInstallDlg::GetErrMessage(DWORD err) {
LPVOID msgBuf;
static char buf[BUFSIZ];
-
+
DWORD len = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, err == -1 ? GetLastError() : err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &msgBuf, 0, NULL );
void CBINDInstallDlg::ProgramGroup(BOOL create) {
TCHAR path[MAX_PATH], commonPath[MAX_PATH], fileloc[MAX_PATH], linkpath[MAX_PATH];
- HRESULT hres;
- IShellLink *psl = NULL;
+ HRESULT hres;
+ IShellLink *psl = NULL;
LPMALLOC pMalloc = NULL;
ITEMIDLIST *itemList = NULL;
}
return;
}
-
+
hr = SHGetPathFromIDList(itemList, commonPath);
pMalloc->Free(itemList);
if (create) {
sprintf(path, "%s\\ISC", commonPath);
CreateDirectory(path, NULL);
-
+
sprintf(path, "%s\\ISC\\BIND", commonPath);
CreateDirectory(path, NULL);
hres = CoInitialize(NULL);
- if (SUCCEEDED(hres)) {
- // Get a pointer to the IShellLink interface.
- hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID *)&psl);
+ if (SUCCEEDED(hres)) {
+ // Get a pointer to the IShellLink interface.
+ hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID *)&psl);
if (SUCCEEDED(hres))
- {
- IPersistFile* ppf;
+ {
+ IPersistFile* ppf;
sprintf(linkpath, "%s\\BINDCtrl.lnk", path);
sprintf(fileloc, "%s\\BINDCtrl.exe", m_binDir);
-
- psl->SetPath(fileloc);
- psl->SetDescription("BIND Control Panel");
- hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf);
- if (SUCCEEDED(hres)) {
- WCHAR wsz[MAX_PATH];
+ psl->SetPath(fileloc);
+ psl->SetDescription("BIND Control Panel");
- MultiByteToWideChar(CP_ACP, 0, linkpath, -1, wsz, MAX_PATH);
- hres = ppf->Save(wsz, TRUE);
- ppf->Release();
- }
+ hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf);
+ if (SUCCEEDED(hres)) {
+ WCHAR wsz[MAX_PATH];
+
+ MultiByteToWideChar(CP_ACP, 0, linkpath, -1, wsz, MAX_PATH);
+ hres = ppf->Save(wsz, TRUE);
+ ppf->Release();
+ }
if (GetFileAttributes("readme.txt") != -1) {
sprintf(fileloc, "%s\\Readme.txt", m_targetDir);
sprintf(linkpath, "%s\\Readme.lnk", path);
- psl->SetPath(fileloc);
- psl->SetDescription("BIND Readme");
+ psl->SetPath(fileloc);
+ psl->SetDescription("BIND Readme");
- hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf);
- if (SUCCEEDED(hres)) {
- WCHAR wsz[MAX_PATH];
+ hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf);
+ if (SUCCEEDED(hres)) {
+ WCHAR wsz[MAX_PATH];
- MultiByteToWideChar(CP_ACP, 0, linkpath, -1, wsz, MAX_PATH);
- hres = ppf->Save(wsz, TRUE);
- ppf->Release();
- }
- psl->Release();
+ MultiByteToWideChar(CP_ACP, 0, linkpath, -1, wsz, MAX_PATH);
+ hres = ppf->Save(wsz, TRUE);
+ ppf->Release();
+ }
+ psl->Release();
}
}
CoUninitialize();
- }
+ }
}
else {
TCHAR filename[MAX_PATH];