diff options
Diffstat (limited to '')
22 files changed, 4231 insertions, 0 deletions
diff --git a/bin/win32/BINDInstall/AccountInfo.cpp b/bin/win32/BINDInstall/AccountInfo.cpp new file mode 100644 index 0000000..73357a8 --- /dev/null +++ b/bin/win32/BINDInstall/AccountInfo.cpp @@ -0,0 +1,456 @@ +/* + * Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +/* Compiled with UNICODE */ + +#include "stdafx.h" + +#include <windows.h> +#include <lm.h> +#include <ntsecapi.h> + +#include <isc/ntgroups.h> +#include <isc/result.h> +#include "AccountInfo.h" + +#define MAX_NAME_LENGTH 256 + +NTSTATUS +OpenPolicy( + LPWSTR ServerName, /* machine to open policy on (Unicode) */ + DWORD DesiredAccess, /* desired access to policy */ + PLSA_HANDLE PolicyHandle /* resultant policy handle */ + ); + +BOOL +GetAccountSid( + LPTSTR SystemName, /* where to lookup account */ + LPTSTR AccountName, /* account of interest */ + PSID *Sid /* resultant buffer containing SID */ + ); + +NTSTATUS +SetPrivilegeOnAccount( + LSA_HANDLE PolicyHandle, /* open policy handle */ + PSID AccountSid, /* SID to grant privilege to */ + LPWSTR PrivilegeName, /* privilege to grant (Unicode) */ + BOOL bEnable /* enable or disable */ + ); + +NTSTATUS +GetPrivilegesOnAccount( + LSA_HANDLE PolicyHandle, /* open policy handle */ + PSID AccountSid, /* SID to grant privilege to */ + wchar_t **PrivList, /* Ptr to List of Privileges found */ + unsigned int *PrivCount /* total number of Privileges in list */ + ); + +NTSTATUS +AddPrivilegeToAcccount( + LPTSTR AccountName, /* Name of the account */ + LPWSTR PrivilegeName /* Privilege to Add */ + ); + +void +InitLsaString( + PLSA_UNICODE_STRING LsaString, /* destination */ + LPWSTR String /* source (Unicode) */ + ); + +void +DisplayNtStatus( + LPSTR szAPI, /* pointer to function name (ANSI) */ + NTSTATUS Status /* NTSTATUS error value */ + ); + +void +DisplayWinError( + LPSTR szAPI, /* pointer to function name (ANSI) */ + DWORD WinError /* DWORD WinError */ + ); + +#ifndef STATUS_SUCCESS +#define STATUS_SUCCESS ((NTSTATUS)0x00000000L) +#endif + +/* + * Note that this code only retrieves the list of privileges of the + * requested account or group. However, all accounts belong to the + * Everyone group even though that group is not returned by the + * calls to get the groups to which that account belongs. + * The Everyone group has two privileges associated with it: + * SeChangeNotifyPrivilege and SeNetworkLogonRight + * It is not advisable to disable or remove these privileges + * from the group nor can the account be removed from the Everyone + * group + * The None group has no privileges associated with it and is the group + * to which an account belongs if it is associated with no group. + */ + +int +GetAccountPrivileges(char *name, wchar_t **PrivList, unsigned int *PrivCount, + char **Accounts, unsigned int *totalAccounts, + int maxAccounts) +{ + LSA_HANDLE PolicyHandle; + TCHAR AccountName[256]; /* static account name buffer */ + PSID pSid; + unsigned int i; + NTSTATUS Status; + isc_result_t istatus; + int iRetVal = RTN_ERROR; /* assume error from main */ + int n; + + /* + * Open the policy on the target machine. + */ + if ((Status = OpenPolicy(NULL, + POLICY_LOOKUP_NAMES, + &PolicyHandle)) != STATUS_SUCCESS) + return (RTN_ERROR); + + /* + * Let's see if the account exists. Return if not + */ + n = wnsprintf(AccountName, sizeof(AccountName), TEXT("%hS"), name); + if (n < 0 || (size_t)n >= sizeof(AccountName)) { + LsaClose(PolicyHandle); + return (RTN_ERROR); + } + + if (!GetAccountSid(NULL, AccountName, &pSid)) { + LsaClose(PolicyHandle); + return (RTN_NOACCOUNT); + } + + /* + * Find out what groups the account belongs to + */ + istatus = isc_ntsecurity_getaccountgroups(name, Accounts, maxAccounts, + totalAccounts); + if (istatus == ISC_R_NOMEMORY) { + LsaClose(PolicyHandle); + return (RTN_NOMEMORY); + } else if (istatus != ISC_R_SUCCESS) { + LsaClose(PolicyHandle); + return (RTN_ERROR); + } + + Accounts[*totalAccounts] = name; /* Add the account to the list */ + (*totalAccounts)++; + + /* + * Loop through each Account to get the list of privileges + */ + for (i = 0; i < *totalAccounts; i++) { + n = wnsprintf(AccountName, sizeof(AccountName), TEXT("%hS"), + Accounts[i]); + if (n < 0 || (size_t)n >= sizeof(AccountName)) { + continue; + } + + /* Obtain the SID of the user/group. */ + if (!GetAccountSid(NULL, AccountName, &pSid)) { + continue; /* Try the next one */ + } + + /* Get the Privileges allocated to this SID */ + if ((Status = GetPrivilegesOnAccount(PolicyHandle, pSid, + PrivList, PrivCount)) == STATUS_SUCCESS) + { + iRetVal=RTN_OK; + if (pSid != NULL) + HeapFree(GetProcessHeap(), 0, pSid); + } else { + if (pSid != NULL) + HeapFree(GetProcessHeap(), 0, pSid); + continue; /* Try the next one */ + } + } + + /* + * Close the policy handle. + */ + LsaClose(PolicyHandle); + + (*totalAccounts)--; /* Correct for the number of groups */ + return iRetVal; +} + +BOOL +CreateServiceAccount(char *name, char *password) { + NTSTATUS retstat; + USER_INFO_1 ui; + DWORD dwLevel = 1; + DWORD dwError = 0; + NET_API_STATUS nStatus; + + size_t namelen = strlen(name); + size_t passwdlen = strlen(password); + wchar_t AccountName[MAX_NAME_LENGTH]; + wchar_t AccountPassword[MAX_NAME_LENGTH]; + + mbstowcs(AccountName, name, namelen + 1); + mbstowcs(AccountPassword, password, passwdlen + 1); + + /* + * Set up the USER_INFO_1 structure. + * USER_PRIV_USER: name is required here when creating an account + * rather than an administrator or a guest. + */ + + ui.usri1_name = (LPWSTR) &AccountName; + ui.usri1_password = (LPWSTR) &AccountPassword; + ui.usri1_priv = USER_PRIV_USER; + ui.usri1_home_dir = NULL; + ui.usri1_comment = L"ISC BIND Service Account"; + ui.usri1_flags = UF_PASSWD_CANT_CHANGE | UF_DONT_EXPIRE_PASSWD | + UF_SCRIPT; + ui.usri1_script_path = NULL; + /* + * Call the NetUserAdd function, specifying level 1. + */ + nStatus = NetUserAdd(NULL, dwLevel, (LPBYTE)&ui, &dwError); + + if (nStatus != NERR_Success) + return (FALSE); + + retstat = AddPrivilegeToAcccount(name, SE_SERVICE_LOGON_PRIV); + return (TRUE); +} + +NTSTATUS +AddPrivilegeToAcccount(LPTSTR name, LPWSTR PrivilegeName) { + LSA_HANDLE PolicyHandle; + TCHAR AccountName[256]; /* static account name buffer */ + PSID pSid; + NTSTATUS Status; + unsigned long err; + int n; + + /* + * Open the policy on the target machine. + */ + if ((Status = OpenPolicy(NULL, POLICY_ALL_ACCESS, &PolicyHandle)) + != STATUS_SUCCESS) + return (RTN_ERROR); + + /* + * Let's see if the account exists. Return if not + */ + n = wnsprintf(AccountName, sizeof(AccountName), TEXT("%hS"), name); + if (n < 0 || (size_t)n >= sizeof(AccountName)) { + LsaClose(PolicyHandle); + return (RTN_ERROR); + } + + if (!GetAccountSid(NULL, AccountName, &pSid)) { + LsaClose(PolicyHandle); + return (RTN_NOACCOUNT); + } + + err = LsaNtStatusToWinError(SetPrivilegeOnAccount(PolicyHandle, + pSid, PrivilegeName, TRUE)); + + LsaClose(PolicyHandle); + if (err == ERROR_SUCCESS) + return (RTN_OK); + else + return (err); +} + +void +InitLsaString(PLSA_UNICODE_STRING LsaString, LPWSTR String){ + size_t StringLength; + + if (String == NULL) { + LsaString->Buffer = NULL; + LsaString->Length = 0; + LsaString->MaximumLength = 0; + return; + } + + StringLength = wcslen(String); + LsaString->Buffer = String; + LsaString->Length = (USHORT) StringLength * sizeof(WCHAR); + LsaString->MaximumLength = (USHORT)(StringLength+1) * sizeof(WCHAR); +} + +NTSTATUS +OpenPolicy(LPWSTR ServerName, DWORD DesiredAccess, PLSA_HANDLE PolicyHandle){ + LSA_OBJECT_ATTRIBUTES ObjectAttributes; + LSA_UNICODE_STRING ServerString; + PLSA_UNICODE_STRING Server = NULL; + + /* + * Always initialize the object attributes to all zeroes. + */ + ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes)); + + if (ServerName != NULL) { + /* + * Make a LSA_UNICODE_STRING out of the LPWSTR passed in + */ + InitLsaString(&ServerString, ServerName); + Server = &ServerString; + } + + /* + * Attempt to open the policy. + */ + return (LsaOpenPolicy(Server, &ObjectAttributes, DesiredAccess, + PolicyHandle)); +} + +BOOL +GetAccountSid(LPTSTR SystemName, LPTSTR AccountName, PSID *Sid) { + LPTSTR ReferencedDomain = NULL; + DWORD cbSid = 128; /* initial allocation attempt */ + DWORD cbReferencedDomain = 16; /* initial allocation size */ + SID_NAME_USE peUse; + BOOL bSuccess = FALSE; /* assume this function will fail */ + + __try { + /* + * initial memory allocations + */ + if ((*Sid = HeapAlloc(GetProcessHeap(), 0, cbSid)) == NULL) + __leave; + + if ((ReferencedDomain = (LPTSTR) HeapAlloc(GetProcessHeap(), 0, + cbReferencedDomain)) == NULL) __leave; + + /* + * Obtain the SID of the specified account on the specified system. + */ + while (!LookupAccountName(SystemName, AccountName, *Sid, &cbSid, + ReferencedDomain, &cbReferencedDomain, + &peUse)) + { + if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { + /* reallocate memory */ + if ((*Sid = HeapReAlloc(GetProcessHeap(), 0, + *Sid, cbSid)) == NULL) __leave; + + if ((ReferencedDomain= (LPTSTR) HeapReAlloc( + GetProcessHeap(), 0, ReferencedDomain, + cbReferencedDomain)) == NULL) + __leave; + } + else + __leave; + } + bSuccess = TRUE; + } /* finally */ + __finally { + + /* Cleanup and indicate failure, if appropriate. */ + + HeapFree(GetProcessHeap(), 0, ReferencedDomain); + + if (!bSuccess) { + if (*Sid != NULL) { + HeapFree(GetProcessHeap(), 0, *Sid); + *Sid = NULL; + } + } + + } + + return (bSuccess); +} + +NTSTATUS +SetPrivilegeOnAccount(LSA_HANDLE PolicyHandle, PSID AccountSid, + LPWSTR PrivilegeName, BOOL bEnable) +{ + LSA_UNICODE_STRING PrivilegeString; + + /* Create a LSA_UNICODE_STRING for the privilege name. */ + InitLsaString(&PrivilegeString, PrivilegeName); + + /* grant or revoke the privilege, accordingly */ + if (bEnable) + return (LsaAddAccountRights(PolicyHandle, AccountSid, + &PrivilegeString, 1)); + else + return (LsaRemoveAccountRights(PolicyHandle, AccountSid, + FALSE, &PrivilegeString, 1)); +} + +NTSTATUS +GetPrivilegesOnAccount(LSA_HANDLE PolicyHandle, PSID AccountSid, + wchar_t **PrivList, unsigned int *PrivCount) +{ + NTSTATUS Status; + LSA_UNICODE_STRING *UserRights; + ULONG CountOfRights; + unsigned int retlen = 0; + DWORD i, j; + int found; + + Status = LsaEnumerateAccountRights(PolicyHandle, AccountSid, + &UserRights, &CountOfRights); + /* Only continue if there is something */ + if (UserRights == NULL || Status != STATUS_SUCCESS) + return (Status); + + for (i = 0; i < CountOfRights; i++) { + found = -1; + retlen = UserRights[i].Length/sizeof(wchar_t); + for (j = 0; j < *PrivCount; j++) { + found = wcsncmp(PrivList[j], UserRights[i].Buffer, + retlen); + if (found == 0) + break; + } + if (found != 0) { + PrivList[*PrivCount] = + (wchar_t *)malloc(UserRights[i].MaximumLength); + if (PrivList[*PrivCount] == NULL) + return (RTN_NOMEMORY); + + wcsncpy(PrivList[*PrivCount], UserRights[i].Buffer, + retlen); + PrivList[*PrivCount][retlen] = L'\0'; + (*PrivCount)++; + } + + } + + return (Status); +} + +void +DisplayNtStatus(LPSTR szAPI, NTSTATUS Status) { + /* Convert the NTSTATUS to Winerror. Then call DisplayWinError(). */ + DisplayWinError(szAPI, LsaNtStatusToWinError(Status)); +} + +void +DisplayWinError(LPSTR szAPI, DWORD WinError) { + LPSTR MessageBuffer; + DWORD dwBufferLength; + + if (dwBufferLength=FormatMessageA( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, WinError, GetUserDefaultLangID(), + (LPSTR) &MessageBuffer, 0, NULL)){ + DWORD dwBytesWritten; /* unused */ + + /* Output message string on stderr. */ + WriteFile(GetStdHandle(STD_ERROR_HANDLE), MessageBuffer, + dwBufferLength, &dwBytesWritten, NULL); + + /* Free the buffer allocated by the system. */ + LocalFree(MessageBuffer); + } +} diff --git a/bin/win32/BINDInstall/AccountInfo.h b/bin/win32/BINDInstall/AccountInfo.h new file mode 100644 index 0000000..1eb684d --- /dev/null +++ b/bin/win32/BINDInstall/AccountInfo.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + + + +#define RTN_OK 0 +#define RTN_NOACCOUNT 1 +#define RTN_NOMEMORY 2 +#define RTN_ERROR 10 + +#define SE_SERVICE_LOGON_PRIV L"SeServiceLogonRight" + +/* + * This routine retrieves the list of all Privileges associated with + * a given account as well as the groups to which it beongs + */ +int +GetAccountPrivileges( + char *name, /* Name of Account */ + wchar_t **PrivList, /* List of Privileges returned */ + unsigned int *PrivCount, /* Count of Privileges returned */ + char **Groups, /* List of Groups to which account belongs */ + unsigned int *totalGroups, /* Count of Groups returned */ + int maxGroups /* Maximum number of Groups to return */ + ); + +/* + * This routine creates an account with the given name which has just + * the logon service privilege and no membership of any groups, + * i.e. it's part of the None group. + */ +BOOL +CreateServiceAccount(char *name, char *password); diff --git a/bin/win32/BINDInstall/BINDInstall.cpp b/bin/win32/BINDInstall/BINDInstall.cpp new file mode 100644 index 0000000..5ee0981 --- /dev/null +++ b/bin/win32/BINDInstall/BINDInstall.cpp @@ -0,0 +1,98 @@ +/* + * Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +/* + * Copyright (c) 1999-2000 by Nortel Networks Corporation + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND NORTEL NETWORKS DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NORTEL NETWORKS + * BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#include "stdafx.h" +#include "BINDInstall.h" +#include "BINDInstallDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CBINDInstallApp + +BEGIN_MESSAGE_MAP(CBINDInstallApp, CWinApp) + //{{AFX_MSG_MAP(CBINDInstallApp) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG + ON_COMMAND(ID_HELP, CWinApp::OnHelp) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CBINDInstallApp construction + +CBINDInstallApp::CBINDInstallApp() +{ + // TODO: add construction code here, + // Place all significant initialization in InitInstance +} + +///////////////////////////////////////////////////////////////////////////// +// The one and only CBINDInstallApp object + +CBINDInstallApp theApp; + +///////////////////////////////////////////////////////////////////////////// +// CBINDInstallApp initialization + +BOOL CBINDInstallApp::InitInstance() +{ + // Standard initialization + // If you are not using these features and wish to reduce the size + // of your final executable, you should remove from the following + // the specific initialization routines you do not need. +#if _MSC_VER < 1300 +#ifdef _AFXDLL + Enable3dControls(); // Call this when using MFC in a shared DLL +#else + Enable3dControlsStatic(); // Call this when linking to MFC statically +#endif +#endif + + CBINDInstallDlg dlg; + m_pMainWnd = &dlg; + INT_PTR nResponse = dlg.DoModal(); + if (nResponse == IDOK) + { + // TODO: Place code here to handle when the dialog is + // dismissed with OK + } + else if (nResponse == IDCANCEL) + { + // TODO: Place code here to handle when the dialog is + // dismissed with Cancel + } + + // Since the dialog has been closed, return FALSE so that we exit the + // application, rather than start the application's message pump. + return FALSE; +} diff --git a/bin/win32/BINDInstall/BINDInstall.dsp.in b/bin/win32/BINDInstall/BINDInstall.dsp.in new file mode 100644 index 0000000..11d2dfa --- /dev/null +++ b/bin/win32/BINDInstall/BINDInstall.dsp.in @@ -0,0 +1,177 @@ +# Microsoft Developer Studio Project File - Name="BINDInstall" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "@PLATFORM@ (x86) Application" 0x0101 + +CFG=BINDInstall - @PLATFORM@ Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "BINDInstall.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "BINDInstall.mak" CFG="BINDInstall - @PLATFORM@ Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "BINDInstall - @PLATFORM@ Release" (based on "@PLATFORM@ (x86) Application") +!MESSAGE "BINDInstall - @PLATFORM@ Debug" (based on "@PLATFORM@ (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "BINDInstall - @PLATFORM@ Release" + +# PROP BASE Use_MFC 5 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 6 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 @COPTX@ @COPTI@ /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MT /W3 @COPTX@ @COPTI@ /O2 /I "..\..\.." /I "..\include" /I "..\..\..\include" /I "..\..\named\win32\include" /I "..\..\..\lib\isc\win32\include" /I "..\..\..\lib\isc\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" @CRYPTO@ @USE_GSSAPI@ @USE_PYTHON@ /Yu"stdafx.h" /FD /TP /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows @MACHINE@ +# ADD LINK32 version.lib netapi32.lib /nologo /subsystem:windows /pdb:none @MACHINE@ /out:"..\..\..\Build\Release\BINDInstall.exe" + +!ELSEIF "$(CFG)" == "BINDInstall - @PLATFORM@ Debug" + +# PROP BASE Use_MFC 5 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 6 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm @COPTX@ @COPTI@ /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm @COPTX@ @COPTI@ /Zi /Od /I "..\..\.." /I "..\include" /I "..\..\..\include" /I "..\..\named\win32\include" /I "..\..\..\lib\isc\win32\include" /I "..\..\..\lib\isc\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" @CRYPTO@ @USE_GSSAPI@ @USE_PYTHON@ /FR /Yu"stdafx.h" /FD /TP /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 /nologo /subsystem:windows /debug @MACHINE@ /pdbtype:sept +# ADD LINK32 version.lib netapi32.lib /nologo /subsystem:windows /pdb:none /debug @MACHINE@ /out:"..\..\..\Build\Debug\BINDInstall.exe" + +!ENDIF + +# Begin Target + +# Name "BINDInstall - @PLATFORM@ Release" +# Name "BINDInstall - @PLATFORM@ Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\AccountInfo.cpp +# End Source File +# Begin Source File + +SOURCE=.\BINDInstall.cpp +# End Source File +# Begin Source File + +SOURCE=.\BINDInstallDlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\DirBrowse.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\lib\isc\win32\ntgroups.c +# SUBTRACT CPP @COPTY@ /Yc /Yu +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# Begin Source File + +SOURCE=.\VersionInfo.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\Accountinfo.h +# End Source File +# Begin Source File + +SOURCE=.\BINDInstall.h +# End Source File +# Begin Source File + +SOURCE=.\BINDInstallDlg.h +# End Source File +# Begin Source File + +SOURCE=.\DirBrowse.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\lib\isc\win32\include\isc\ntgroups.h +# End Source File +# Begin Source File + +SOURCE=.\Resource.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# Begin Source File + +SOURCE=.\VersionInfo.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\res\BINDInstall.ico +# End Source File +# Begin Source File + +SOURCE=.\res\BINDInstall.rc2 +# End Source File +# End Group +# Begin Source File + +SOURCE=.\BINDInstall.rc +# End Source File +# End Target +# End Project diff --git a/bin/win32/BINDInstall/BINDInstall.dsw b/bin/win32/BINDInstall/BINDInstall.dsw new file mode 100644 index 0000000..c949bc7 --- /dev/null +++ b/bin/win32/BINDInstall/BINDInstall.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "BINDInstall"=.\BINDInstall.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/bin/win32/BINDInstall/BINDInstall.h b/bin/win32/BINDInstall/BINDInstall.h new file mode 100644 index 0000000..1d12d5e --- /dev/null +++ b/bin/win32/BINDInstall/BINDInstall.h @@ -0,0 +1,57 @@ +/* + * Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + + +/* + * Copyright (c) 1999-2000 by Nortel Networks Corporation + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND NORTEL NETWORKS DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NORTEL NETWORKS + * BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#ifndef BINDINSTALL_H +#define BINDINSTALL_H + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "resource.h" // main symbols + +class CBINDInstallApp : public CWinApp +{ +public: + CBINDInstallApp(); + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CBINDInstallApp) + public: + virtual BOOL InitInstance(); + //}}AFX_VIRTUAL + + //{{AFX_MSG(CBINDInstallApp) + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +#endif diff --git a/bin/win32/BINDInstall/BINDInstall.mak.in b/bin/win32/BINDInstall/BINDInstall.mak.in new file mode 100644 index 0000000..5b53ea2 --- /dev/null +++ b/bin/win32/BINDInstall/BINDInstall.mak.in @@ -0,0 +1,428 @@ +# Microsoft Developer Studio Generated NMAKE File, Based on BINDInstall.dsp +!IF "$(CFG)" == "" +CFG=BINDInstall - @PLATFORM@ Debug +!MESSAGE No configuration specified. Defaulting to BINDInstall - @PLATFORM@ Debug. +!ENDIF + +!IF "$(CFG)" != "BINDInstall - @PLATFORM@ Release" && "$(CFG)" != "BINDInstall - @PLATFORM@ Debug" +!MESSAGE Invalid configuration "$(CFG)" specified. +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "BINDInstall.mak" CFG="BINDInstall - @PLATFORM@ Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "BINDInstall - @PLATFORM@ Release" (based on "@PLATFORM@ (x86) Application") +!MESSAGE "BINDInstall - @PLATFORM@ Debug" (based on "@PLATFORM@ (x86) Application") +!MESSAGE +!ERROR An invalid configuration is specified. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF + +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "BINDInstall - @PLATFORM@ Release" +_VC_MANIFEST_INC=0 +_VC_MANIFEST_BASENAME=__VC80 +!ELSE +_VC_MANIFEST_INC=1 +_VC_MANIFEST_BASENAME=__VC80.Debug +!ENDIF + +#################################################### +# Specifying name of temporary resource file used only in incremental builds: + +!if "$(_VC_MANIFEST_INC)" == "1" +_VC_MANIFEST_AUTO_RES=$(_VC_MANIFEST_BASENAME).auto.res +!else +_VC_MANIFEST_AUTO_RES= +!endif + +#################################################### +# _VC_MANIFEST_EMBED_EXE - command to embed manifest in EXE: + +!if "$(_VC_MANIFEST_INC)" == "1" + +#MT_SPECIAL_RETURN=1090650113 +#MT_SPECIAL_SWITCH=-notify_resource_update +MT_SPECIAL_RETURN=0 +MT_SPECIAL_SWITCH= +_VC_MANIFEST_EMBED_EXE= \ +if exist $@.manifest mt.exe -manifest $@.manifest -out:$(_VC_MANIFEST_BASENAME).auto.manifest $(MT_SPECIAL_SWITCH) & \ +if "%ERRORLEVEL%" == "$(MT_SPECIAL_RETURN)" \ +rc /r $(_VC_MANIFEST_BASENAME).auto.rc & \ +link $** /out:$@ $(LFLAGS) + +!else + +_VC_MANIFEST_EMBED_EXE= \ +if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;1 + +!endif + +#################################################### +# _VC_MANIFEST_EMBED_DLL - command to embed manifest in DLL: + +!if "$(_VC_MANIFEST_INC)" == "1" + +#MT_SPECIAL_RETURN=1090650113 +#MT_SPECIAL_SWITCH=-notify_resource_update +MT_SPECIAL_RETURN=0 +MT_SPECIAL_SWITCH= +_VC_MANIFEST_EMBED_EXE= \ +if exist $@.manifest mt.exe -manifest $@.manifest -out:$(_VC_MANIFEST_BASENAME).auto.manifest $(MT_SPECIAL_SWITCH) & \ +if "%ERRORLEVEL%" == "$(MT_SPECIAL_RETURN)" \ +rc /r $(_VC_MANIFEST_BASENAME).auto.rc & \ +link $** /out:$@ $(LFLAGS) + +!else + +_VC_MANIFEST_EMBED_EXE= \ +if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;2 + +!endif +#################################################### +# _VC_MANIFEST_CLEAN - command to clean resources files generated temporarily: + +!if "$(_VC_MANIFEST_INC)" == "1" + +_VC_MANIFEST_CLEAN=-del $(_VC_MANIFEST_BASENAME).auto.res \ + $(_VC_MANIFEST_BASENAME).auto.rc \ + $(_VC_MANIFEST_BASENAME).auto.manifest + +!else + +_VC_MANIFEST_CLEAN= + +!endif + +!IF "$(CFG)" == "BINDInstall - @PLATFORM@ Release" + +OUTDIR=.\Release +INTDIR=.\Release + +ALL : "..\..\..\Build\Release\BINDInstall.exe" + + +CLEAN : + -@erase "$(INTDIR)\AccountInfo.obj" + -@erase "$(INTDIR)\BINDInstall.obj" + -@erase "$(INTDIR)\BINDInstall.pch" + -@erase "$(INTDIR)\BINDInstall.res" + -@erase "$(INTDIR)\BINDInstallDlg.obj" + -@erase "$(INTDIR)\DirBrowse.obj" + -@erase "$(INTDIR)\ntgroups.obj" + -@erase "$(INTDIR)\StdAfx.obj" + -@erase "$(INTDIR)\vc60.idb" + -@erase "$(INTDIR)\VersionInfo.obj" + -@erase "..\..\..\Build\Release\BINDInstall.exe" + -@$(_VC_MANIFEST_CLEAN) + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP_PROJ=/nologo /MT /W3 @COPTX@ @COPTI@ /O2 /I "..\..\.." /I "..\include" /I "..\..\..\include" /I "..\..\named\win32\include" /I "..\..\..\lib\isc\win32\include" /I "..\..\..\lib\isc\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" @CRYPTO@ @USE_GSSAPI@ @USE_PYTHON@ /Fp"$(INTDIR)\BINDInstall.pch" /Yu"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /TP /c +MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 +RSC_PROJ=/l 0x409 /fo"$(INTDIR)\BINDInstall.res" /d "NDEBUG" +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\BINDInstall.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +LINK32_FLAGS=version.lib netapi32.lib /nologo /subsystem:windows /pdb:none @MACHINE@ /out:"..\..\..\Build\Release\BINDInstall.exe" +LINK32_OBJS= \ + "$(INTDIR)\AccountInfo.obj" \ + "$(INTDIR)\BINDInstall.obj" \ + "$(INTDIR)\BINDInstallDlg.obj" \ + "$(INTDIR)\DirBrowse.obj" \ + "$(INTDIR)\ntgroups.obj" \ + "$(INTDIR)\StdAfx.obj" \ + "$(INTDIR)\VersionInfo.obj" \ + "$(INTDIR)\BINDInstall.res" + +"..\..\..\Build\Release\BINDInstall.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + $(_VC_MANIFEST_EMBED_EXE) + +!ELSEIF "$(CFG)" == "BINDInstall - @PLATFORM@ Debug" + +OUTDIR=.\Debug +INTDIR=.\Debug +# Begin Custom Macros +OutDir=.\Debug +# End Custom Macros + +ALL : "..\..\..\Build\Debug\BINDInstall.exe" "$(OUTDIR)\BINDInstall.bsc" + + +CLEAN : + -@erase "$(INTDIR)\AccountInfo.obj" + -@erase "$(INTDIR)\AccountInfo.sbr" + -@erase "$(INTDIR)\BINDInstall.obj" + -@erase "$(INTDIR)\BINDInstall.pch" + -@erase "$(INTDIR)\BINDInstall.res" + -@erase "$(INTDIR)\BINDInstall.sbr" + -@erase "$(INTDIR)\BINDInstallDlg.obj" + -@erase "$(INTDIR)\BINDInstallDlg.sbr" + -@erase "$(INTDIR)\DirBrowse.obj" + -@erase "$(INTDIR)\DirBrowse.sbr" + -@erase "$(INTDIR)\ntgroups.obj" + -@erase "$(INTDIR)\ntgroups.sbr" + -@erase "$(INTDIR)\StdAfx.obj" + -@erase "$(INTDIR)\StdAfx.sbr" + -@erase "$(INTDIR)\vc60.idb" + -@erase "$(INTDIR)\vc60.pdb" + -@erase "$(INTDIR)\VersionInfo.obj" + -@erase "$(INTDIR)\VersionInfo.sbr" + -@erase "$(OUTDIR)\BINDInstall.bsc" + -@erase "..\..\..\Build\Debug\BINDInstall.exe" + -@$(_VC_MANIFEST_CLEAN) + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP_PROJ=/nologo /MTd /W3 /Gm @COPTX@ @COPTI@ /Zi /Od /I "..\..\.." /I "..\include" /I "..\..\..\include" /I "..\..\named\win32\include" /I "..\..\..\lib\isc\win32\include" /I "..\..\..\lib\isc\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" @CRYPTO@ @USE_GSSAPI@ @USE_PYTHON@ /FR"$(INTDIR)\\" /Fp"$(INTDIR)\BINDInstall.pch" /Yu"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /TP /GZ /c +MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 +RSC_PROJ=/l 0x409 /fo"$(INTDIR)\BINDInstall.res" /d "_DEBUG" +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\BINDInstall.bsc" +BSC32_SBRS= \ + "$(INTDIR)\AccountInfo.sbr" \ + "$(INTDIR)\BINDInstall.sbr" \ + "$(INTDIR)\BINDInstallDlg.sbr" \ + "$(INTDIR)\DirBrowse.sbr" \ + "$(INTDIR)\ntgroups.sbr" \ + "$(INTDIR)\StdAfx.sbr" \ + "$(INTDIR)\VersionInfo.sbr" + +"$(OUTDIR)\BINDInstall.bsc" : "$(OUTDIR)" $(BSC32_SBRS) + $(BSC32) @<< + $(BSC32_FLAGS) $(BSC32_SBRS) +<< + +LINK32=link.exe +LINK32_FLAGS=version.lib netapi32.lib /nologo /subsystem:windows /pdb:none /debug @MACHINE@ /out:"..\..\..\Build\Debug\BINDInstall.exe" +LINK32_OBJS= \ + "$(INTDIR)\AccountInfo.obj" \ + "$(INTDIR)\BINDInstall.obj" \ + "$(INTDIR)\BINDInstallDlg.obj" \ + "$(INTDIR)\DirBrowse.obj" \ + "$(INTDIR)\ntgroups.obj" \ + "$(INTDIR)\StdAfx.obj" \ + "$(INTDIR)\VersionInfo.obj" \ + "$(INTDIR)\BINDInstall.res" + +"..\..\..\Build\Debug\BINDInstall.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + $(_VC_MANIFEST_EMBED_EXE) + +!ENDIF + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + + +!IF "$(NO_EXTERNAL_DEPS)" != "1" +!IF EXISTS("BINDInstall.dep") +!INCLUDE "BINDInstall.dep" +!ELSE +!MESSAGE Warning: cannot find "BINDInstall.dep" +!ENDIF +!ENDIF + + +!IF "$(CFG)" == "BINDInstall - @PLATFORM@ Release" || "$(CFG)" == "BINDInstall - @PLATFORM@ Debug" +SOURCE=.\AccountInfo.cpp + +!IF "$(CFG)" == "BINDInstall - @PLATFORM@ Release" + + +"$(INTDIR)\AccountInfo.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\BINDInstall.pch" + + +!ELSEIF "$(CFG)" == "BINDInstall - @PLATFORM@ Debug" + + +"$(INTDIR)\AccountInfo.obj" "$(INTDIR)\AccountInfo.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\BINDInstall.pch" + + +!ENDIF + +SOURCE=.\BINDInstall.cpp + +!IF "$(CFG)" == "BINDInstall - @PLATFORM@ Release" + + +"$(INTDIR)\BINDInstall.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\BINDInstall.pch" + + +!ELSEIF "$(CFG)" == "BINDInstall - @PLATFORM@ Debug" + + +"$(INTDIR)\BINDInstall.obj" "$(INTDIR)\BINDInstall.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\BINDInstall.pch" + + +!ENDIF + +SOURCE=.\BINDInstallDlg.cpp + +!IF "$(CFG)" == "BINDInstall - @PLATFORM@ Release" + + +"$(INTDIR)\BINDInstallDlg.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\BINDInstall.pch" + + +!ELSEIF "$(CFG)" == "BINDInstall - @PLATFORM@ Debug" + + +"$(INTDIR)\BINDInstallDlg.obj" "$(INTDIR)\BINDInstallDlg.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\BINDInstall.pch" + + +!ENDIF + +SOURCE=.\DirBrowse.cpp + +!IF "$(CFG)" == "BINDInstall - @PLATFORM@ Release" + + +"$(INTDIR)\DirBrowse.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\BINDInstall.pch" + + +!ELSEIF "$(CFG)" == "BINDInstall - @PLATFORM@ Debug" + + +"$(INTDIR)\DirBrowse.obj" "$(INTDIR)\DirBrowse.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\BINDInstall.pch" + + +!ENDIF + +SOURCE=..\..\..\lib\isc\win32\ntgroups.c + +!IF "$(CFG)" == "BINDInstall - @PLATFORM@ Release" + +CPP_SWITCHES=/nologo /MT /W3 @COPTX@ @COPTI@ /O2 /I "..\include" /I "..\..\..\include" /I "..\..\named\win32\include" /I "..\..\..\lib\isc\win32\include" /I "..\..\..\lib\isc\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" @CRYPTO@ @USE_GSSAPI@ /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /TP /c + +"$(INTDIR)\ntgroups.obj" : $(SOURCE) "$(INTDIR)" + $(CPP) @<< + $(CPP_SWITCHES) $(SOURCE) +<< + + +!ELSEIF "$(CFG)" == "BINDInstall - @PLATFORM@ Debug" + +CPP_SWITCHES=/nologo /MTd /W3 /Gm @COPTX@ @COPTI@ /Zi /Od /I "..\include" /I "..\..\..\include" /I "..\..\named\win32\include" /I "..\..\..\lib\isc\win32\include" /I "..\..\..\lib\isc\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" @CRYPTO@ @USE_GSSAPI@ /FR"$(INTDIR)\\" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /TP /GZ /c + +"$(INTDIR)\ntgroups.obj" "$(INTDIR)\ntgroups.sbr" : $(SOURCE) "$(INTDIR)" + $(CPP) @<< + $(CPP_SWITCHES) $(SOURCE) +<< + + +!ENDIF + +SOURCE=.\StdAfx.cpp + +!IF "$(CFG)" == "BINDInstall - @PLATFORM@ Release" + +CPP_SWITCHES=/nologo /MT /W3 @COPTX@ @COPTI@ /O2 /I "..\include" /I "..\..\..\include" /I "..\..\named\win32\include" /I "..\..\..\lib\isc\win32\include" /I "..\..\..\lib\isc\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" @CRYPTO@ @USE_GSSAPI@ /Fp"$(INTDIR)\BINDInstall.pch" /Yc"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /TP /c + +"$(INTDIR)\StdAfx.obj" "$(INTDIR)\BINDInstall.pch" : $(SOURCE) "$(INTDIR)" + $(CPP) @<< + $(CPP_SWITCHES) $(SOURCE) +<< + + +!ELSEIF "$(CFG)" == "BINDInstall - @PLATFORM@ Debug" + +CPP_SWITCHES=/nologo /MTd /W3 /Gm @COPTX@ @COPTI@ /Zi /Od /I "..\include" /I "..\..\..\include" /I "..\..\named\win32\include" /I "..\..\..\lib\isc\win32\include" /I "..\..\..\lib\isc\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" @CRYPTO@ @USE_GSSAPI@ /FR"$(INTDIR)\\" /Fp"$(INTDIR)\BINDInstall.pch" /Yc"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /TP /GZ /c + +"$(INTDIR)\StdAfx.obj" "$(INTDIR)\StdAfx.sbr" "$(INTDIR)\BINDInstall.pch" : $(SOURCE) "$(INTDIR)" + $(CPP) @<< + $(CPP_SWITCHES) $(SOURCE) +<< + + +!ENDIF + +SOURCE=.\VersionInfo.cpp + +!IF "$(CFG)" == "BINDInstall - @PLATFORM@ Release" + + +"$(INTDIR)\VersionInfo.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\BINDInstall.pch" + + +!ELSEIF "$(CFG)" == "BINDInstall - @PLATFORM@ Debug" + + +"$(INTDIR)\VersionInfo.obj" "$(INTDIR)\VersionInfo.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\BINDInstall.pch" + + +!ENDIF + +SOURCE=.\BINDInstall.rc + +"$(INTDIR)\BINDInstall.res" : $(SOURCE) "$(INTDIR)" + $(RSC) $(RSC_PROJ) $(SOURCE) + + + +!ENDIF + +#################################################### +# Commands to generate initial empty manifest file and the RC file +# that references it, and for generating the .res file: + +$(_VC_MANIFEST_BASENAME).auto.res : $(_VC_MANIFEST_BASENAME).auto.rc + +$(_VC_MANIFEST_BASENAME).auto.rc : $(_VC_MANIFEST_BASENAME).auto.manifest + type <<$@ +#include <winuser.h> +1RT_MANIFEST"$(_VC_MANIFEST_BASENAME).auto.manifest" +<< KEEP + +$(_VC_MANIFEST_BASENAME).auto.manifest : + type <<$@ +<?xml version='1.0' encoding='UTF-8' standalone='yes'?> +<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'> +</assembly> +<< KEEP diff --git a/bin/win32/BINDInstall/BINDInstall.rc b/bin/win32/BINDInstall/BINDInstall.rc new file mode 100644 index 0000000..be9550b --- /dev/null +++ b/bin/win32/BINDInstall/BINDInstall.rc @@ -0,0 +1,324 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" + "#ifdef _WIN32\r\n" + "LANGUAGE 9, 1\r\n" + "#pragma code_page(1252)\r\n" + "#endif //_WIN32\r\n" + "#include ""res\\BINDInstall.rc2"" // non-Microsoft Visual C++ edited resources\r\n" + "#include ""afxres.rc"" // Standard components\r\n" + "#endif\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDR_MAINFRAME ICON "res\\BINDInstall.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_BINDINSTALL_DIALOG DIALOGEX 0, 0, 210, 311 +STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_APPWINDOW +CAPTION "BIND 9 Installer" +FONT 8, "MS Sans Serif", 0, 0, 0x1 +BEGIN + EDITTEXT IDC_TARGETDIR,7,62,196,14,ES_AUTOHSCROLL + EDITTEXT IDC_ACCOUNT_NAME,7,94,196,14,ES_AUTOHSCROLL + EDITTEXT IDC_ACCOUNT_PASSWORD,7,122,196,14,ES_PASSWORD | ES_AUTOHSCROLL + EDITTEXT IDC_ACCOUNT_PASSWORD_CONFIRM,7,151,196,14,ES_PASSWORD | ES_AUTOHSCROLL + DEFPUSHBUTTON "&Install",IDC_INSTALL,153,7,50,14 + PUSHBUTTON "E&xit",IDC_EXIT,153,39,50,14 + CONTROL "&Tools Only",IDC_TOOLS_ONLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,185,72,10 + CONTROL "&Automatic Startup",IDC_AUTO_START,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,195,72,10 + CONTROL "&Keep Config Files After Uninstall",IDC_KEEP_FILES, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,205,116,10 + CONTROL "&Start BIND Service After Install",IDC_START,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,215,113,10 + PUSHBUTTON "&Uninstall",IDC_UNINSTALL,153,23,50,14 + PUSHBUTTON "Browse",IDC_BROWSE,7,22,50,14 + LTEXT "Target Directory:",IDC_STATIC,7,53,54,8 + GROUPBOX "Progress",IDC_STATIC,7,234,196,70 + RTEXT "",IDC_COPY_TAG,14,271,78,8 + LTEXT "",IDC_COPY_FILE,105,271,90,8 + RTEXT "",IDC_SERVICE_TAG,15,281,77,8 + LTEXT "",IDC_REG_SERVICE,105,281,89,8 + RTEXT "",IDC_MESSAGE_TAG,15,291,77,8 + LTEXT "",IDC_REG_MESSAGE,105,291,88,8 + RTEXT "",IDC_DIR_TAG,15,261,77,8 + GROUPBOX "Options",IDC_STATIC,7,172,196,60 + CTEXT "Version Unknown",IDC_VERSION,7,7,61,10,SS_CENTERIMAGE | SS_SUNKEN + RTEXT "Current Operation:",IDC_CURRENT_TAG,34,245,58,8 + LTEXT "",IDC_CURRENT,105,245,90,8 + LTEXT "",IDC_CREATE_DIR,105,261,88,8 + LTEXT "Service Account Name",IDC_STATIC,7,84,74,8 + LTEXT "Service Account Password",IDC_STATIC,7,112,86,8 + LTEXT "Confirm Service Account Password",IDC_STATIC,7,140,112,8 +END + +IDD_BROWSE DIALOG 0, 0, 227, 117 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Select Directory" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,170,7,50,14 + PUSHBUTTON "Cancel",IDCANCEL,170,24,50,14 + LISTBOX IDC_DIRLIST,7,28,155,82,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + EDITTEXT IDC_CURDIR,7,7,155,14,ES_AUTOHSCROLL + COMBOBOX IDC_DRIVES,170,98,50,74,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP +END + +IDD_DIALOG1 DIALOG 0, 0, 186, 95 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Dialog" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,129,7,50,14 + PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 3,0,0,0 + PRODUCTVERSION 3,0,0,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "Internet Systems Consortium" + VALUE "FileDescription", "ISC BIND 9 Install Utility" + VALUE "FileVersion", "3.0.0" + VALUE "InternalName", "BINDInstall" + VALUE "LegalCopyright", "Copyright © 2000,2014" + VALUE "OriginalFilename", "BINDInstall.EXE" + VALUE "ProductName", "ISC BIND 9" + VALUE "ProductVersion", "9.10.0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_BINDINSTALL_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 203 + VERTGUIDE, 14 + VERTGUIDE, 92 + VERTGUIDE, 105 + TOPMARGIN, 7 + BOTTOMMARGIN, 294 + HORZGUIDE, 195 + HORZGUIDE, 205 + HORZGUIDE, 215 + HORZGUIDE, 239 + HORZGUIDE, 255 + HORZGUIDE, 265 + HORZGUIDE, 275 + HORZGUIDE, 285 + HORZGUIDE, 295 + END + + IDD_BROWSE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 220 + TOPMARGIN, 7 + BOTTOMMARGIN, 110 + END + + IDD_DIALOG1, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 179 + TOPMARGIN, 7 + BOTTOMMARGIN, 88 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDS_MAINFRAME "BIND 9 Installer" + IDS_CREATEDIR "Directory %s does not exist.\nDo you wish to create it?" + IDS_SUCCESS "BIND installation completed successfully" + IDS_FAIL "BIND installation failed" + IDS_DIREXIST "Directory %s exists.\n Install here anyway?" + IDS_INSTALL_DIR "Create Directories..." + IDS_INSTALL_FILE "Copy Files..." + IDS_INSTALL_SERVICE "Register Service..." + IDS_INSTALL_MESSAGE "Register Messages..." + IDS_UNINSTALL "Do you wish to uninstall BIND?" + IDS_UNINSTALL_DONE "BIND Uninstall Completed" +END + +STRINGTABLE +BEGIN + IDS_CREATE_KEY "Creating BIND registry key" + IDS_ADD_REMOVE "Setting up Add/Remove Programs entry" + IDS_CLEANUP "Cleaning up" + IDS_INSTALL_DONE "Finished Installing" + IDS_CREATE_DIR "Creating directory %s" + IDS_REMOVE_DIR "Removing directory %s" + IDS_COPY_FILE "Copying file %s" + IDS_DELETE_FILE "Deleting file %s" + IDS_OPEN_SCM "Opening Service Control Manager" + IDS_CREATE_SERVICE "Creating BIND service" + IDS_OPEN_SERVICE "Opening BIND service" + IDS_REMOVE_SERVICE "Removing BIND service" + IDS_REGISTER_MESSAGES "Registering BIND message source" + IDS_UNREGISTER_MESSAGES "Unregistering BIND message source" + IDS_STOP_SERVICE "Stopping BIND service" + IDS_START_SERVICE "Starting BIND service" +END + +STRINGTABLE +BEGIN + IDS_UNINSTALL_DIR "Remove Directories..." + IDS_UNINSTALL_FILES "Delete Files..." + IDS_UNINSTALL_SERVICE "Unregister Service..." + IDS_UNINSTALL_MESSAGE "Unregister Messages..." + IDS_ERR_OPEN_SCM "Could not open Service Control Manager\n(%s)" + IDS_ERR_OPEN_SERVICE "Could not open BIND Service\n(%s)" + IDS_ERR_STOP_SERVICE "Could not stop BIND Service\n(%s)" + IDS_ERR_NONCRIT_FILE "An error occurred while copying non-critical file %s\n(%s)\nDo you wish to continue?" + IDS_ERR_COPY_FILE "An error occurred while copying file %s\n(%s)\nInstallation will be terminated" + IDS_ERR_CREATE_SERVICE "Error creating service\n(%s)" + IDS_ERR_REMOVE_SERVICE "Error removing service\n(%s)" + IDS_REBOOT "BINDInstall needs to restart Windows.\nDo you wish to restart now?" + IDS_BAD_PRIVILEGES "This user cannot acquire the privileges necessary to install BIND. Please ensure you are logged on as a member of the Administrators group." + IDS_ERR_CREATE_DIR "An error occurred while creating directory %s\n(%s)" + IDS_VERSION "Version %s" + IDS_ERR_CREATE_KEY "An error occured while creating registry keys\n(%s)" +END + +STRINGTABLE +BEGIN + IDS_ERR_SET_VALUE "An error occured while setting registry key values\n(%s)" + IDS_NO_VERSION "Version Unknown" + IDS_EXISTING_NEWER "%s\nThe existing version of this file is newer than the version being installed.\nDo you wish to overwrite the existing file?" + IDS_FILE_BAD "Could not retrieve version info for file %s. Do you wish to continue?\n(Continuing may overwrite a newer version of the file) " + IDS_ERR_TOOPRIVED "Chosen account has too many privileges. Do you wish to choose a different account name?" + IDS_ERR_BADACCOUNT "Error Validating Account. Unable to install service using this account." + IDS_ERR_WRONGPRIV "The wrong privilege: %s was detected. Only the Service Logon Right privilege should be enabled for this account." + IDS_CREATEACCOUNT_FAILED "Unable to Create Account for the Service." + IDS_ERR_PASSWORD "Passwords entered did not match. Please reenter password." + IDS_ERR_UPDATE_SERVICE "Error updating service\n(%s)" + IDS_ERR_NULLPASSWORD "Service account password cannot be null" + IDS_ERR_WHITESPACE "Service account password has leading/trailing whitespace" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE 9, 1 +#pragma code_page(1252) +#endif //_WIN32 +#include "res\BINDInstall.rc2" // non-Microsoft Visual C++ edited resources +#include "afxres.rc" // Standard components +#endif + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/bin/win32/BINDInstall/BINDInstall.vcxproj.filters.in b/bin/win32/BINDInstall/BINDInstall.vcxproj.filters.in new file mode 100644 index 0000000..0cb0eb4 --- /dev/null +++ b/bin/win32/BINDInstall/BINDInstall.vcxproj.filters.in @@ -0,0 +1,79 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> + <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> + <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\..\..\lib\isc\win32\include\isc\ntgroups.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="AccountInfo.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="BINDInstall.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="BINDInstallDlg.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="DirBrowse.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="resource.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="StdAfx.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="VersionInfo.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> + <ItemGroup> + <ClCompile Include="AccountInfo.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="BINDInstall.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="BINDInstallDlg.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="DirBrowse.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="StdAfx.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="VersionInfo.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\..\lib\isc\win32\ntgroups.c"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <None Include="res\BINDInstall.ico"> + <Filter>Resource Files</Filter> + </None> + <None Include="res\BINDInstall.rc2"> + <Filter>Resource Files</Filter> + </None> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="BINDInstall.rc"> + <Filter>Resource Files</Filter> + </ResourceCompile> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/bin/win32/BINDInstall/BINDInstall.vcxproj.in b/bin/win32/BINDInstall/BINDInstall.vcxproj.in new file mode 100644 index 0000000..255b72b --- /dev/null +++ b/bin/win32/BINDInstall/BINDInstall.vcxproj.in @@ -0,0 +1,148 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|@PLATFORM@"> + <Configuration>Debug</Configuration> + <Platform>@PLATFORM@</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|@PLATFORM@"> + <Configuration>Release</Configuration> + <Platform>@PLATFORM@</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{190CC424-E8CC-46F2-9013-3152D6905118}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>BINDInstall</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + <UseOfMfc>Static</UseOfMfc> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + <UseOfMfc>Static</UseOfMfc> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'"> + <LinkIncremental>true</LinkIncremental> + <OutDir>..\..\..\Build\$(Configuration)\</OutDir> + <IntDir>.\$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'"> + <LinkIncremental>false</LinkIncremental> + <OutDir>..\..\..\Build\$(Configuration)\</OutDir> + <IntDir>.\$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'"> + <ClCompile> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> + <PrecompiledHeader>Use</PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;@CRYPTO@@USE_GSSAPI@@USE_PYTHON@_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>..\..\..;..\include;..\..\..\include;..\..\named\win32\include;..\..\..\lib\isc\win32\include;..\..\..\lib\isc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <StringPooling> + </StringPooling> + <FunctionLevelLinking>true</FunctionLevelLinking> + <PrecompiledHeaderOutputFile>.\$(Configuration)\$(TargetName).pch</PrecompiledHeaderOutputFile> + <PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile> + <AssemblerListingLocation>.\$(Configuration)\</AssemblerListingLocation> + <ObjectFileName>.\$(Configuration)\</ObjectFileName> + <ProgramDataBaseFileName>$(OutDir)$(TargetName).pdb</ProgramDataBaseFileName> + <BrowseInformation>true</BrowseInformation> + <CompileAs>CompileAsCpp</CompileAs> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <OutputFile>..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)</OutputFile> + <AdditionalDependencies>nafxcwd.lib;version.lib;netapi32.lib;%(AdditionalDependencies)</AdditionalDependencies> + <EnableUAC>false</EnableUAC> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'"> + <ClCompile> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader>Use</PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>false</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;@CRYPTO@@USE_GSSAPI@@USE_PYTHON@NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>..\..\..;..\include;..\..\..\include;..\..\named\win32\include;..\..\..\lib\isc\win32\include;..\..\..\lib\isc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> + <StringPooling>true</StringPooling> + <PrecompiledHeaderOutputFile>.\$(Configuration)\$(TargetName).pch</PrecompiledHeaderOutputFile> + <PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile> + <AssemblerListingLocation>.\$(Configuration)\</AssemblerListingLocation> + <ObjectFileName>.\$(Configuration)\</ObjectFileName> + <ProgramDataBaseFileName>$(OutDir)$(TargetName).pdb</ProgramDataBaseFileName> + <CompileAs>CompileAsCpp</CompileAs> + <WholeProgramOptimization>false</WholeProgramOptimization> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>false</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <OutputFile>..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)</OutputFile> + <AdditionalDependencies>nafxcw.lib;version.lib;netapi32.lib;%(AdditionalDependencies)</AdditionalDependencies> + <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration> + <EnableUAC>false</EnableUAC> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClInclude Include="..\..\..\lib\isc\win32\include\isc\ntgroups.h" /> + <ClInclude Include="AccountInfo.h" /> + <ClInclude Include="BINDInstall.h" /> + <ClInclude Include="BINDInstallDlg.h" /> + <ClInclude Include="DirBrowse.h" /> + <ClInclude Include="resource.h" /> + <ClInclude Include="StdAfx.h" /> + <ClInclude Include="VersionInfo.h" /> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\..\..\lib\isc\win32\ntgroups.c"> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + </ClCompile> + <ClCompile Include="AccountInfo.cpp"> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">UNICODE;WIN32;@CRYPTO@@USE_GSSAPI@@USE_PYTHON@NDEBUG;_WINDOWS;_MBCS</PreprocessorDefinitions> + <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">UNICODE;WIN32;@CRYPTO@@USE_GSSAPI@@USE_PYTHON@_DEBUG;_WINDOWS;_MBCS</PreprocessorDefinitions> + </ClCompile> + <ClCompile Include="BINDInstall.cpp" /> + <ClCompile Include="BINDInstallDlg.cpp" /> + <ClCompile Include="DirBrowse.cpp" /> + <ClCompile Include="StdAfx.cpp"> + <PrecompiledHeader>Create</PrecompiledHeader> + <PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile> + </ClCompile> + <ClCompile Include="VersionInfo.cpp" /> + </ItemGroup> + <ItemGroup> + <None Include="res\BINDInstall.ico" /> + <None Include="res\BINDInstall.rc2" /> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="BINDInstall.rc" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project> diff --git a/bin/win32/BINDInstall/BINDInstall.vcxproj.user b/bin/win32/BINDInstall/BINDInstall.vcxproj.user new file mode 100644 index 0000000..695b5c7 --- /dev/null +++ b/bin/win32/BINDInstall/BINDInstall.vcxproj.user @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+</Project>
\ No newline at end of file diff --git a/bin/win32/BINDInstall/BINDInstallDlg.cpp b/bin/win32/BINDInstall/BINDInstallDlg.cpp new file mode 100644 index 0000000..f3446e5 --- /dev/null +++ b/bin/win32/BINDInstall/BINDInstallDlg.cpp @@ -0,0 +1,1590 @@ +/* + * Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +/* + * Copyright (c) 1999-2000 by Nortel Networks Corporation + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND NORTEL NETWORKS DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NORTEL NETWORKS + * BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + * Define this to make a standalone installer that will copy msvcrt.dll + * and/or msvcrtd.dll during the install + */ +// #define BINARIES_INSTALL + +/* + * msvcrt.dll is the release c-runtime library for MSVC. msvcrtd.dll + * is the debug c-runtime library for MSVC. If you have debug + * binaries you want to have DEBUG_BINARIES defined. If you have + * release binaries you want to have RELEASE_BINARIES defined. + * If you have both, then define them both. + * Of course, you need msvcrt[d].dll present to install it! + */ +#ifdef BINARIES_INSTALL +// # define DEBUG_BINARIES +// # define RELEASE_BINARIES +#endif + +#include "stdafx.h" +#include "BINDInstall.h" +#include "BINDInstallDlg.h" +#include "DirBrowse.h" +#include <winsvc.h> +#include <shlobj.h> +#include <shlwapi.h> +#include <named/ntservice.h> +#include <isc/bind_registry.h> +#include <isc/ntgroups.h> +#include <direct.h> +#include "AccountInfo.h" +#include "versioninfo.h" + +#include <fstream> +#include <iostream> +#include <string> +#include <vector> + +#include <config.h> + +#undef open + +#define MAX_GROUPS 100 +#define MAX_PRIVS 50 + +#define LOCAL_SERVICE "NT AUTHORITY\\LocalService" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +typedef struct _xexception +{ + _xexception(UINT string, ...); + + CString resString; +} Exception; + +_xexception::_xexception(UINT string, ...) +{ + CString format; + va_list va; + + format.LoadString(string); + + va_start(va, string); + resString.FormatV(format, va); + va_end(va); +} + +typedef struct _filedata { + enum FileDestinations {TargetDir, BinDir, EtcDir, WinSystem}; + enum FileImportance {Trivial, Normal, Critical}; + + char filename[128]; + int destination; + int importance; + BOOL checkVer; + BOOL withTools; +} FileData; + +#if no_longer_used + +const FileData installFiles[] = +{ +#ifdef BINARIES_INSTALL +# ifdef DEBUG_BINARIES + {"msvcrtd.dll", FileData::WinSystem, FileData::Critical, TRUE, TRUE}, +# endif +# ifdef RELEASE_BINARIES + {"msvcrt.dll", FileData::WinSystem, FileData::Critical, TRUE, TRUE}, +# endif +#endif +#if _MSC_VER < 1400 +#if _MSC_VER >= 1310 + {"mfc71.dll", FileData::WinSystem, FileData::Critical, TRUE, TRUE}, + {"msvcr71.dll", FileData::WinSystem, FileData::Critical, TRUE, TRUE}, +#elif _MSC_VER > 1200 && _MSC_VER < 1310 + {"mfc70.dll", FileData::WinSystem, FileData::Critical, TRUE, TRUE}, + {"msvcr70.dll", FileData::WinSystem, FileData::Critical, TRUE, TRUE}, +#endif +#endif + {"bindevt.dll", FileData::BinDir, FileData::Normal, FALSE, TRUE}, + {"libbind9.dll", FileData::BinDir, FileData::Critical, FALSE, TRUE}, + {"libisc.dll", FileData::BinDir, FileData::Critical, FALSE, TRUE}, + {"libisccfg.dll", FileData::BinDir, FileData::Critical, FALSE, TRUE}, + {"libisccc.dll", FileData::BinDir, FileData::Critical, FALSE, TRUE}, + {"libdns.dll", FileData::BinDir, FileData::Critical, FALSE, TRUE}, + {"liblwres.dll", FileData::BinDir, FileData::Critical, FALSE, TRUE}, + {"libirs.dll", FileData::BinDir, FileData::Critical, FALSE, TRUE}, +#ifdef OPENSSL + {"libeay32.dll", FileData::BinDir, FileData::Critical, FALSE, TRUE}, +#endif +#ifdef HAVE_LIBXML2 + {"libxml2.dll", FileData::BinDir, FileData::Critical, FALSE, TRUE}, +#endif +#ifdef USE_GSSAPI +#ifndef _WIN64 + {"gssapi32.dll", FileData::BinDir, FileData::Critical, FALSE, TRUE}, + {"krb5_32.dll", FileData::BinDir, FileData::Critical, FALSE, TRUE}, +#else + {"gssapi64.dll", FileData::BinDir, FileData::Critical, FALSE, TRUE}, + {"krb5_64.dll", FileData::BinDir, FileData::Critical, FALSE, TRUE}, +#endif +#endif +#ifdef HAVE_GEOIP + {"libgeoip.dll", FileData::BinDir, FileData::Critical, FALSE, TRUE}, +#endif +#ifdef WITH_IDN + {"idnkit.dll", FileData::BinDir, FileData::Critical, FALSE, TRUE}, + {"iconv.dll", FileData::BinDir, FileData::Critical, FALSE, TRUE}, +#endif + {"named.exe", FileData::BinDir, FileData::Critical, FALSE, FALSE}, + {"nsupdate.exe", FileData::BinDir, FileData::Normal, FALSE, TRUE}, + {"BINDInstall.exe", FileData::BinDir, FileData::Normal, FALSE, TRUE}, + {"rndc.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"dig.exe", FileData::BinDir, FileData::Normal, FALSE, TRUE}, + {"host.exe", FileData::BinDir, FileData::Normal, FALSE, TRUE}, + {"mdig.exe", FileData::BinDir, FileData::Normal, FALSE, TRUE}, + {"nslookup.exe", FileData::BinDir, FileData::Normal, FALSE, TRUE}, + {"delv.exe", FileData::BinDir, FileData::Normal, FALSE, TRUE}, + {"arpaname.exe", FileData::BinDir, FileData::Normal, FALSE, TRUE}, + {"nsec3hash.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"genrandom.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"rndc-confgen.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"ddns-confgen.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"tsig-keygen.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"dnssec-keygen.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"dnssec-signzone.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"dnssec-dsfromkey.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"dnssec-importkey.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"dnssec-keyfromlabel.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"dnssec-revoke.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"dnssec-settime.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"dnssec-verify.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"named-checkconf.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"named-checkzone.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"named-compilezone.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"named-journalprint.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"named-rrchecker.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"isc-hmac-fixup.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, +#ifdef USE_PKCS11 + {"pkcs11-destroy.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"pkcs11-keygen.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"pkcs11-list.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"pkcs11-tokens.exe", FileData::BinDir, FileData::Normal, FALSE, FALSE}, +#endif +#ifdef USE_PYTHON + {"dnssec-checkds.py", FileData::BinDir, FileData::Normal, FALSE, FALSE}, + {"dnssec-coverage.py", FileData::BinDir, FileData::Normal, FALSE, FALSE}, +#endif + {"readme1st.txt", FileData::BinDir, FileData::Trivial, FALSE, TRUE}, + {NULL, -1, -1} +}; + +#else + +typedef std::vector<FileData> FileDatas; +FileDatas installFiles; +BOOL forwin64 = FALSE; +BOOL runvcredist = FALSE; + +#endif + +///////////////////////////////////////////////////////////////////////////// +// CBINDInstallDlg dialog + +CBINDInstallDlg::CBINDInstallDlg(CWnd* pParent /*=NULL*/) + : CDialog(CBINDInstallDlg::IDD, pParent) { + char winsys[MAX_PATH]; + + //{{AFX_DATA_INIT(CBINDInstallDlg) + m_targetDir = _T(""); + m_version = _T(""); + m_toolsOnly = FALSE; + m_autoStart = FALSE; + m_keepFiles = FALSE; + m_current = _T(""); + m_startOnInstall = FALSE; + m_accountName = _T(""); + m_accountPassword = _T(""); + //}}AFX_DATA_INIT + // Note that LoadIcon does not require a subsequent + // DestroyIcon in Win32 + m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); + + GetSystemDirectory(winsys, MAX_PATH); + m_winSysDir = winsys; + + m_defaultDir = "notyetknown"; + + m_installed = FALSE; + m_accountExists = FALSE; + m_accountUsed = FALSE; + m_serviceExists = TRUE; + GetCurrentServiceAccountName(); + m_currentAccount = m_accountName; + if (m_accountName == "") { + m_accountName = "named"; + } +} + +void CBINDInstallDlg::DoDataExchange(CDataExchange* pDX) { + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CBINDInstallDlg) + DDX_Text(pDX, IDC_TARGETDIR, m_targetDir); + DDX_Text(pDX, IDC_VERSION, m_version); + DDX_Text(pDX, IDC_ACCOUNT_NAME, m_accountName); + DDX_Text(pDX, IDC_ACCOUNT_PASSWORD, m_accountPassword); + DDX_Text(pDX, IDC_ACCOUNT_PASSWORD_CONFIRM, m_accountPasswordConfirm); + DDX_Check(pDX, IDC_TOOLS_ONLY, m_toolsOnly); + DDX_Check(pDX, IDC_AUTO_START, m_autoStart); + DDX_Check(pDX, IDC_KEEP_FILES, m_keepFiles); + DDX_Text(pDX, IDC_CURRENT, m_current); + DDX_Check(pDX, IDC_START, m_startOnInstall); + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CBINDInstallDlg, CDialog) + //{{AFX_MSG_MAP(CBINDInstallDlg) + ON_WM_PAINT() + ON_WM_QUERYDRAGICON() + ON_BN_CLICKED(IDC_BROWSE, OnBrowse) + ON_BN_CLICKED(IDC_INSTALL, OnInstall) + ON_BN_CLICKED(IDC_EXIT, OnExit) + ON_BN_CLICKED(IDC_UNINSTALL, OnUninstall) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CBINDInstallDlg message handlers + +BOOL CBINDInstallDlg::OnInitDialog() { + CDialog::OnInitDialog(); + + // Set the icon for this dialog. The framework does this automatically + // when the application's main window is not a dialog + SetIcon(m_hIcon, TRUE); // Set big icon + SetIcon(m_hIcon, FALSE); // Set small icon + + char filename[MAX_PATH]; + char dirname[MAX_PATH]; + char *fptr = &filename[0]; + GetModuleFileName(NULL, filename, MAX_PATH); + char *dptr = strrchr(filename,'\\'); + size_t index = dptr - fptr; + strncpy(dirname, filename, index); + dirname[index] = '\0'; + CString Dirname(dirname); + m_currentDir = Dirname; + + ReadInstallFlags(); + char progfiles[MAX_PATH]; + int id_program_files; + if (forwin64) + id_program_files = CSIDL_PROGRAM_FILES; + else + id_program_files = CSIDL_PROGRAM_FILESX86; + SHGetFolderPath(NULL, CSIDL_FLAG_CREATE|id_program_files, + NULL, SHGFP_TYPE_CURRENT, progfiles); + + m_defaultDir = progfiles; + m_defaultDir += "\\ISC BIND 9"; + + CVersionInfo bindInst(filename); + if(bindInst.IsValid()) + m_version.Format(IDS_VERSION, bindInst.GetFileVersionString()); + else + m_version.LoadString(IDS_NO_VERSION); + + DWORD dwBufLen = MAX_PATH; + char buf[MAX_PATH]; + HKEY hKey; + + m_startOnInstall = CheckBINDService(); + + /* See if we are installed already */ + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, BIND_SUBKEY, 0, KEY_READ, &hKey) + == ERROR_SUCCESS) { + m_installed = TRUE; + memset(buf, 0, MAX_PATH); + // Get the install directory + if (RegQueryValueEx(hKey, "InstallDir", NULL, NULL, (LPBYTE)buf, + &dwBufLen) == ERROR_SUCCESS) + if (strcmp(buf, "")) + m_defaultDir = buf; + + RegCloseKey(hKey); + } + m_targetDir = m_defaultDir; + + // Set checkbox defaults + m_autoStart = TRUE; + m_keepFiles = TRUE; + + UpdateData(FALSE); + + return (TRUE); /* return(TRUE) unless you set the focus to a control */ +} + +/* + * If you add a minimize button to your dialog, you will need the code below + * to draw the icon. For MFC applications using the document/view model, + * this is automatically done for you by the framework. + */ + +void CBINDInstallDlg::OnPaint() { + if (IsIconic()) { + CPaintDC dc(this); // device context for painting + + SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); + + // Center icon in client rectangle + int cxIcon = GetSystemMetrics(SM_CXICON); + int cyIcon = GetSystemMetrics(SM_CYICON); + CRect rect; + GetClientRect(&rect); + int x = (rect.Width() - cxIcon + 1) / 2; + int y = (rect.Height() - cyIcon + 1) / 2; + + // Draw the icon + dc.DrawIcon(x, y, m_hIcon); + } + else { + CDialog::OnPaint(); + } +} + +// The system calls this to obtain the cursor to display while the user drags +// the minimized window. +HCURSOR CBINDInstallDlg::OnQueryDragIcon() { + return((HCURSOR)m_hIcon); +} + +void CBINDInstallDlg::OnBrowse() { + + CDirBrowse browse; + + if (browse.DoModal() == IDOK) { + //m_targetDir = browse.m_selectedDir; + UpdateData(FALSE); + } +} + +/* + * User pressed the exit button + */ +void CBINDInstallDlg::OnExit() { + EndDialog(0); +} + +/* + * User pressed the uninstall button. Make it go. + */ +void CBINDInstallDlg::OnUninstall() { + UpdateData(); + + if (MsgBox(IDS_UNINSTALL, MB_YESNO) == IDYES) { + if (CheckBINDService()) + StopBINDService(); + + SC_HANDLE hSCManager = OpenSCManager(NULL, NULL, + SC_MANAGER_ALL_ACCESS); + if (!hSCManager) { + 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){ + MsgBox(IDS_ERR_OPEN_SERVICE, GetErrMessage()); + return; + } + + SERVICE_STATUS ss; + QueryServiceStatus(hService, &ss); + if (ss.dwCurrentState == SERVICE_RUNNING) { + BOOL rc = ControlService(hService, + 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"; + + UninstallTags(); + UnregisterMessages(TRUE); + UnregisterService(TRUE); + ReadInstallFileList(); + DeleteFiles(TRUE); + if (m_keepFiles == FALSE) + RemoveDirs(TRUE); + 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); + MsgBox(IDS_UNINSTALL_DONE); + } +} + +/* + * User pressed the install button. Make it go. + */ +void CBINDInstallDlg::OnInstall() { + BOOL success = FALSE; + int oldlen; + int n; + + if (CheckBINDService()) + StopBINDService(); + + InstallTags(); + + UpdateData(); + + if (!m_toolsOnly && m_accountName != LOCAL_SERVICE) { + /* + * Check that the Passwords entered match. + */ + if (m_accountPassword != m_accountPasswordConfirm) { + MsgBox(IDS_ERR_PASSWORD); + return; + } + + /* + * Check that there is not leading / trailing whitespace. + * This is for compatibility with the standard password dialog. + * Passwords really should be treated as opaque blobs. + */ + oldlen = m_accountPassword.GetLength(); + m_accountPassword.TrimLeft(); + m_accountPassword.TrimRight(); + if (m_accountPassword.GetLength() != oldlen) { + MsgBox(IDS_ERR_WHITESPACE); + return; + } + + /* + * Check the entered account name. + */ + if (ValidateServiceAccount() == FALSE) + return; + + /* + * For Registration we need to know if account was changed. + */ + if (m_accountName != m_currentAccount) + m_accountUsed = FALSE; + + if (m_accountUsed == FALSE && m_serviceExists == FALSE) + { + /* + * Check that the Password is not null. + */ + if (m_accountPassword.GetLength() == 0) { + MsgBox(IDS_ERR_NULLPASSWORD); + return; + } + } + } else if (m_accountName == LOCAL_SERVICE) { + /* The LocalService always exists. */ + m_accountExists = TRUE; + if (m_accountName != m_currentAccount) + m_accountUsed = FALSE; + } + + /* Directories */ + m_etcDir = m_targetDir + "\\etc"; + m_binDir = m_targetDir + "\\bin"; + + if (m_defaultDir != m_targetDir) { + if (GetFileAttributes(m_targetDir) != 0xFFFFFFFF) + { + int install = MsgBox(IDS_DIREXIST, + MB_YESNO | MB_ICONQUESTION, m_targetDir); + if (install == IDNO) + return; + } + else { + int createDir = MsgBox(IDS_CREATEDIR, + MB_YESNO | MB_ICONQUESTION, m_targetDir); + if (createDir == IDNO) + return; + } + } + + if (!m_toolsOnly) { + if (m_accountExists == FALSE) { + success = CreateServiceAccount(m_accountName.GetBuffer(30), + m_accountPassword.GetBuffer(30)); + if (success == FALSE) { + MsgBox(IDS_CREATEACCOUNT_FAILED); + return; + } + m_accountExists = TRUE; + } + } + + ProgramGroup(FALSE); + + /* + * Install Visual Studio libraries. As per: + * http://blogs.msdn.com/astebner/archive/2006/08/23/715755.aspx + * + * Vcredist_x86.exe /q:a /c:"msiexec /i vcredist.msi /qn /l*v %temp%\vcredist_x86.log" + */ + /*system(".\\Vcredist_x86.exe /q:a /c:\"msiexec /i vcredist.msi /qn /l*v %temp%\vcredist_x86.log\"");*/ + + /* + * Enclose full path to Vcredist_x86.exe in quotes as + * m_currentDir may contain spaces. + */ + if (runvcredist) { + char Vcredist_x86[MAX_PATH]; + if (forwin64) + n = snprintf(Vcredist_x86, sizeof(Vcredist_x86), + "\"%s\\Vcredist_x64.exe\"", + (LPCTSTR) m_currentDir); + else + n = snprintf(Vcredist_x86, sizeof(Vcredist_x86), + "\"%s\\Vcredist_x86.exe\"", + (LPCTSTR) m_currentDir); + if (n >= 0 && (size_t)n < sizeof(Vcredist_x86)) + system(Vcredist_x86); + } + try { + CreateDirs(); + ReadInstallFileList(); + CopyFiles(); + if (!m_toolsOnly) + RegisterService(); + RegisterMessages(); + + HKEY hKey; + + /* Create a new key for named */ + SetCurrent(IDS_CREATE_KEY); + if (RegCreateKey(HKEY_LOCAL_MACHINE, BIND_SUBKEY, + &hKey) == ERROR_SUCCESS) { + // Get the install directory + RegSetValueEx(hKey, "InstallDir", 0, REG_SZ, + (LPBYTE)(LPCTSTR)m_targetDir, + m_targetDir.GetLength()); + RegCloseKey(hKey); + } + + + SetCurrent(IDS_ADD_REMOVE); + if (RegCreateKey(HKEY_LOCAL_MACHINE, BIND_UNINSTALL_SUBKEY, + &hKey) == ERROR_SUCCESS) { + CString buf(BIND_DISPLAY_NAME); + + RegSetValueEx(hKey, "DisplayName", 0, REG_SZ, + (LPBYTE)(LPCTSTR)buf, buf.GetLength()); + + buf.Format("%s\\BINDInstall.exe", m_binDir); + + CStringA installLocA(buf); + const char *str = (const char *) installLocA; + char pathBuffer[2 * MAX_PATH]; + strncpy(pathBuffer, str, sizeof(pathBuffer) - 1); + pathBuffer[sizeof(pathBuffer) - 1] = 0; + PathQuoteSpaces(pathBuffer); + + RegSetValueEx(hKey, "UninstallString", 0, REG_SZ, + (LPBYTE)(LPCTSTR)pathBuffer, strlen(pathBuffer)); + RegCloseKey(hKey); + } + + ProgramGroup(FALSE); + + if (m_startOnInstall) + StartBINDService(); + } + catch(Exception e) { + MessageBox(e.resString); + SetCurrent(IDS_CLEANUP); + FailedInstall(); + MsgBox(IDS_FAIL); + return; + } + catch(DWORD dw) { + CString msg; + msg.Format("A fatal error occured\n(%s)", GetErrMessage(dw)); + MessageBox(msg); + SetCurrent(IDS_CLEANUP); + FailedInstall(); + MsgBox(IDS_FAIL); + return; + } + + SetCurrent(IDS_INSTALL_DONE); + MsgBox(IDS_SUCCESS); +} + +/* + * Methods to do the work + */ +void CBINDInstallDlg::CreateDirs() { + /* s'OK if the directories already exist */ + SetCurrent(IDS_CREATE_DIR, m_targetDir); + if (!CreateDirectory(m_targetDir, NULL) && GetLastError() != ERROR_ALREADY_EXISTS) + throw(Exception(IDS_ERR_CREATE_DIR, m_targetDir, GetErrMessage())); + + SetCurrent(IDS_CREATE_DIR, m_etcDir); + if (!CreateDirectory(m_etcDir, NULL) && GetLastError() != ERROR_ALREADY_EXISTS) + throw(Exception(IDS_ERR_CREATE_DIR, m_etcDir, GetErrMessage())); + + 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); +} + +void CBINDInstallDlg::RemoveDirs(BOOL uninstall) { + if (!m_keepFiles) { + SetCurrent(IDS_REMOVE_DIR, m_binDir); + // Check for existence then remove if present + if (GetFileAttributes(m_binDir) != 0xFFFFFFFF) + RemoveDirectory(m_binDir); + + SetCurrent(IDS_REMOVE_DIR, m_etcDir); + if (GetFileAttributes(m_etcDir) != 0xFFFFFFFF) + RemoveDirectory(m_etcDir); + + SetCurrent(IDS_REMOVE_DIR, m_targetDir); + if (GetFileAttributes(m_targetDir) != 0xFFFFFFFF) + RemoveDirectory(m_targetDir); + } + + if (uninstall) + SetItemStatus(IDC_CREATE_DIR, TRUE); +} + +// InstallFlags: runvcredist and forwin64 options +void CBINDInstallDlg::ReadInstallFlags() { + std::ifstream ff(m_currentDir + "\\InstallFlags"); + if (!ff) { + throw(Exception(IDS_FILE_BAD, "InstallFlags", "can't open")); + } + while (!ff.eof()) { + std::string line; + getline(ff, line); + if (line.compare("runvcredist") == 0) + runvcredist = TRUE; + else if (line.compare("forwin64") == 0) + forwin64 = TRUE; + } +} + +// InstallFiles: {filename-divt}* +// destination: TBEW +// importance: TNC +// checkVer and withTools: TF (boolean) +void CBINDInstallDlg::ReadInstallFileList() { + std::ifstream fl(m_currentDir + "\\InstallFiles"); + if (!fl) { + throw(Exception(IDS_FILE_BAD, "InstallFiles", "can't open")); + } + while (!fl.eof()) { + std::string line; + getline(fl, line); + if (line.empty()) + continue; + if (line[0] == '#') + continue; + // zip -l adds spurious \r: remove trailing space chars + size_t finish = line.find_last_not_of(" \t\r\n\t\v"); + if ((finish != std::string::npos) && + (finish + 1 != line.size())) { + line.erase(finish + 1); + } + size_t flags = line.find_last_of('-'); + if ((flags == std::string::npos) || + (flags + 5 != line.size())) + goto bad; + std::string file = line.substr(0, flags); + if (file.empty() || (file.size() > 127)) + goto bad; + FileData entry; + memmove(entry.filename, file.c_str(), file.size() + 1); + switch (line[flags + 1]) { + case 'T': + entry.destination = FileData::TargetDir; + break; + case 'B': + entry.destination = FileData::BinDir; + break; + case 'E': + entry.destination = FileData::EtcDir; + break; + case 'W': + entry.destination = FileData::WinSystem; + break; + default: + goto bad; + } + switch (line[flags + 2]) { + case 'T': + entry.importance = FileData::Trivial; + break; + case 'N': + entry.importance = FileData::Normal; + break; + case 'C': + entry.importance = FileData::Critical; + break; + default: + goto bad; + } + switch (line[flags + 3]) { + case 'T': + entry.checkVer = TRUE; + break; + case 'F': + entry.checkVer = FALSE; + break; + default: + goto bad; + } + switch (line[flags + 4]) { + case 'T': + entry.withTools = TRUE; + break; + case 'F': + entry.withTools = FALSE; + break; + default: + goto bad; + } + installFiles.push_back(entry); + } + return; + +bad: + throw(Exception(IDS_FILE_BAD, "InstallFiles", "syntax error")); +} + +void CBINDInstallDlg::CopyFiles() { + CString destFile; + + for (FileDatas::iterator fd = installFiles.begin(); + fd != installFiles.end(); ++fd) { + if (m_toolsOnly && !fd->withTools) + continue; + SetCurrent(IDS_COPY_FILE, fd->filename); + + destFile = DestDir(fd->destination) + "\\" + fd->filename; + CString filespec = m_currentDir + "\\" + fd->filename; + CVersionInfo bindFile(destFile); + + CVersionInfo origFile(filespec); + if (!origFile.IsValid() && fd->checkVer) { + if (MsgBox(IDS_FILE_BAD, MB_YESNO, + fd->filename) == IDNO) + throw(Exception(IDS_ERR_COPY_FILE, + fd->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. + */ + bindFile.CopyFileNoVersion(origFile); + } + catch(...) { + if (fd->importance != FileData::Trivial) { + if (fd->importance == FileData::Critical || + MsgBox(IDS_ERR_NONCRIT_FILE, MB_YESNO, + fd->filename, + GetErrMessage()) == IDNO) + { + SetItemStatus(IDC_COPY_FILE, FALSE); + throw(Exception(IDS_ERR_COPY_FILE, + fd->filename, + GetErrMessage())); + } + } + } + } + + SetItemStatus(IDC_COPY_FILE); +} + +void CBINDInstallDlg::DeleteFiles(BOOL uninstall) { + CString destFile; + + for (FileDatas::iterator fd = installFiles.begin(); + fd != installFiles.end(); ++fd) { + if (fd->checkVer) + continue; + + destFile = DestDir(fd->destination) + "\\" + fd->filename; + + if (uninstall) + SetCurrent(IDS_DELETE_FILE, fd->filename); + + DeleteFile(destFile); + } + + if (!m_keepFiles) { + WIN32_FIND_DATA findData; + 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, "..")) { + file = m_etcDir + "\\" + findData.cFileName; + SetCurrent(IDS_DELETE_FILE, file); + DeleteFile(file); + } + rc = FindNextFile(hFile, &findData); + } + FindClose(hFile); + } + + if (uninstall) + SetItemStatus(IDC_COPY_FILE, TRUE); +} + +/* + * Get the service account name out of the registry, if any + */ +void +CBINDInstallDlg::GetCurrentServiceAccountName() { + HKEY hKey; + BOOL keyFound = FALSE; + char accountName[MAX_PATH]; + DWORD nameLen = MAX_PATH; + CString Tmp; + m_accountUsed = FALSE; + + memset(accountName, 0, nameLen); + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, BIND_SERVICE_SUBKEY, 0, KEY_READ, + &hKey) == ERROR_SUCCESS) { + keyFound = TRUE; + } + else { + m_serviceExists = FALSE; + } + + if (keyFound == TRUE) { + /* Get the named service account, if one was specified */ + if (RegQueryValueEx(hKey, "ObjectName", NULL, NULL, + (LPBYTE)accountName, &nameLen) != ERROR_SUCCESS) + keyFound = FALSE; + } + + RegCloseKey(hKey); + if (keyFound == FALSE) + m_accountName = ""; + else if (!strcmp(accountName, LOCAL_SERVICE)) { + m_accountName = LOCAL_SERVICE; + m_accountUsed = TRUE; + } else { + /* + * LocalSystem is not a regular account and is equivalent + * to no account but with lots of privileges + */ + Tmp = accountName; + if (Tmp == ".\\LocalSystem") + m_accountName = ""; + /* Found account strip any ".\" from it */ + if (Tmp.Left(2) == ".\\") { + m_accountName = Tmp.Mid(2); + m_accountUsed = TRUE; + } + } +} + +BOOL +CBINDInstallDlg::ValidateServiceAccount() { + wchar_t *PrivList[MAX_PRIVS]; + unsigned int PrivCount = 0; + char *Groups[MAX_GROUPS]; + unsigned int totalGroups = 0; + int status; + char *name; + + name = m_accountName.GetBuffer(30); + + status = GetAccountPrivileges(name, PrivList, &PrivCount, + Groups, &totalGroups, MAX_GROUPS); + if (status == RTN_NOACCOUNT) { + m_accountExists = FALSE; + /* We need to do this in case an account was previously used */ + m_accountUsed = FALSE; + return (TRUE); + } + if (status != RTN_OK) { + MsgBox(IDS_ERR_BADACCOUNT); + return (FALSE); + } + + m_accountExists = TRUE; + if (PrivCount > 1) { + if (MsgBox(IDS_ERR_TOOPRIVED, MB_YESNO) == IDYES) + return (FALSE); + else + return (TRUE); + } + + /* See if we have the correct privilege */ + if (wcscmp(PrivList[0], SE_SERVICE_LOGON_PRIV) != 0) { + MsgBox(IDS_ERR_WRONGPRIV, PrivList[0]); + return (FALSE); + } + return (TRUE); +} + +void +CBINDInstallDlg::RegisterService() { + SC_HANDLE hSCManager; + SC_HANDLE hService; + CString StartName; + + if (m_accountName == LOCAL_SERVICE) + StartName = LOCAL_SERVICE; + else + StartName = ".\\" + m_accountName; + /* + * We need to change the service rather than create it + * if the service already exists. Do nothing if we are already + * using that account + */ + if (m_serviceExists == TRUE) { + if (m_accountUsed == FALSE) { + UpdateService(StartName); + SetItemStatus(IDC_REG_SERVICE); + return; + } else { + SetItemStatus(IDC_REG_SERVICE); + return; + } + } + + SetCurrent(IDS_OPEN_SCM); + hSCManager= OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + if (!hSCManager) + throw(Exception(IDS_ERR_OPEN_SCM, GetErrMessage())); + + DWORD dwStart = SERVICE_DEMAND_START; + if (m_autoStart) + dwStart = SERVICE_AUTO_START; + + DWORD dwServiceType = SERVICE_WIN32_OWN_PROCESS; + + CString namedLoc; + namedLoc.Format("%s\\bin\\named.exe", m_targetDir); + + CStringA namedLocA(namedLoc); + const char *str = (const char *) namedLocA; + char pathBuffer[2 * MAX_PATH]; + strncpy(pathBuffer, str, sizeof(pathBuffer) - 1); + pathBuffer[sizeof(pathBuffer) - 1] = 0; + PathQuoteSpaces(pathBuffer); + + SetCurrent(IDS_CREATE_SERVICE); + hService = CreateService(hSCManager, BIND_SERVICE_NAME, + BIND_DISPLAY_NAME, SERVICE_ALL_ACCESS, dwServiceType, dwStart, + SERVICE_ERROR_NORMAL, pathBuffer, NULL, NULL, NULL, StartName, + m_accountPassword); + + if (!hService && GetLastError() != ERROR_SERVICE_EXISTS) + throw(Exception(IDS_ERR_CREATE_SERVICE, GetErrMessage())); + + if (hService) + CloseServiceHandle(hService); + + if (hSCManager) + CloseServiceHandle(hSCManager); + + SetItemStatus(IDC_REG_SERVICE); +} + +void +CBINDInstallDlg::UpdateService(CString StartName) { + SC_HANDLE hSCManager; + SC_HANDLE hService; + + if(m_toolsOnly) + return; + + SetCurrent(IDS_OPEN_SCM); + hSCManager= OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + if (!hSCManager) { + MsgBox(IDS_ERR_OPEN_SCM, GetErrMessage()); + return; + } + + DWORD dwStart = SERVICE_DEMAND_START; + if (m_autoStart) + dwStart = SERVICE_AUTO_START; + + DWORD dwServiceType = SERVICE_WIN32_OWN_PROCESS; + + CString namedLoc; + namedLoc.Format("%s\\bin\\named.exe", m_targetDir); + + CStringA namedLocA(namedLoc); + const char *str = (const char *) namedLocA; + char pathBuffer[2 * MAX_PATH]; + strncpy(pathBuffer, str, sizeof(pathBuffer) - 1); + pathBuffer[sizeof(pathBuffer) - 1] = 0; + PathQuoteSpaces(pathBuffer); + + SetCurrent(IDS_OPEN_SERVICE); + hService = OpenService(hSCManager, BIND_SERVICE_NAME, + SERVICE_CHANGE_CONFIG); + if (!hService) + { + MsgBox(IDS_ERR_OPEN_SERVICE, GetErrMessage()); + if (hSCManager) + CloseServiceHandle(hSCManager); + return; + } else { + if (ChangeServiceConfig(hService, dwServiceType, dwStart, + SERVICE_ERROR_NORMAL, pathBuffer, NULL, NULL, NULL, + StartName, m_accountPassword, BIND_DISPLAY_NAME) + != TRUE) { + DWORD err = GetLastError(); + MsgBox(IDS_ERR_UPDATE_SERVICE, GetErrMessage()); + } + } + + if (hService) + CloseServiceHandle(hService); + + if (hSCManager) + CloseServiceHandle(hSCManager); + + SetItemStatus(IDC_REG_SERVICE); +} + +void CBINDInstallDlg::UnregisterService(BOOL uninstall) { + BOOL rc = FALSE; + SC_HANDLE hSCManager; + SC_HANDLE hService; + + while(1) { + SetCurrent(IDS_OPEN_SCM); + hSCManager= OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + if (!hSCManager && uninstall == TRUE) { + MsgBox(IDS_ERR_OPEN_SCM, GetErrMessage()); + break; + } + + SetCurrent(IDS_OPEN_SERVICE); + hService = OpenService(hSCManager, BIND_SERVICE_NAME, + STANDARD_RIGHTS_REQUIRED); + if (!hService && uninstall == TRUE) + { + if (GetLastError() != ERROR_SERVICE_DOES_NOT_EXIST) { + MsgBox(IDS_ERR_OPEN_SERVICE, GetErrMessage()); + break; + } + } + else { + SetCurrent(IDS_REMOVE_SERVICE); + if (!DeleteService(hService) && uninstall == TRUE) { + DWORD err = GetLastError(); + if (err != ERROR_SERVICE_MARKED_FOR_DELETE && + err != ERROR_SERVICE_DOES_NOT_EXIST) { + MsgBox(IDS_ERR_REMOVE_SERVICE, + GetErrMessage()); + break; + } + } + } + + rc = TRUE; + break; + } + + if (hService) + CloseServiceHandle(hService); + + if (hSCManager) + CloseServiceHandle(hSCManager); + + if (uninstall) + SetItemStatus(IDC_REG_SERVICE, rc); +} + +void CBINDInstallDlg::RegisterMessages() { + HKEY hKey; + DWORD dwData; + char pszMsgDLL[MAX_PATH]; + int n; + + n = snprintf(pszMsgDLL, sizeof(pszMsgDLL), "%s\\%s", + (LPCTSTR)m_binDir, "bindevt.dll"); + if (n < 0 || (size_t)n >= sizeof(pszMsgDLL)) + throw(Exception(IDS_ERR_CREATE_KEY, + "<m_binDir>\\bindevt.dll too long")); + + SetCurrent(IDS_REGISTER_MESSAGES); + /* Create a new key for named */ + 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, (DWORD)(strlen(pszMsgDLL) + 1)) != ERROR_SUCCESS) + throw(Exception(IDS_ERR_SET_VALUE, GetErrMessage())); + + /* Set the supported types flags and addit to the subkey. */ + dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE; + if (RegSetValueEx(hKey, "TypesSupported", 0, REG_DWORD, + (LPBYTE)&dwData, sizeof(DWORD)) != ERROR_SUCCESS) + throw(Exception(IDS_ERR_SET_VALUE, GetErrMessage())); + + RegCloseKey(hKey); + + SetItemStatus(IDC_REG_MESSAGE); +} + +void CBINDInstallDlg::UnregisterMessages(BOOL uninstall) { + BOOL rc = FALSE; + HKEY hKey = NULL; + + while(1) { + SetCurrent(IDS_UNREGISTER_MESSAGES); + /* Open key for Application Event Log */ + if (RegOpenKey(HKEY_LOCAL_MACHINE, EVENTLOG_APP_SUBKEY, &hKey) + != ERROR_SUCCESS) + break; + + /* Remove named from the list of messages sources */ + if (RegDeleteKey(hKey, BIND_MESSAGE_NAME) != ERROR_SUCCESS) + break; + + rc = TRUE; + break; + } + + if (hKey) + RegCloseKey(hKey); + + if (uninstall) + SetItemStatus(IDC_REG_MESSAGE, rc); +} + +/* + * Install failed - clean up quietly + */ +void CBINDInstallDlg::FailedInstall() { + UnregisterMessages(FALSE); + UnregisterService(FALSE); + DeleteFiles(FALSE); + RemoveDirs(FALSE); +} + +/* + * Set the checklist tags for install + */ +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_DIR); + GetDlgItem(IDC_DIR_TAG)->SetWindowText(tag); + GetDlgItem(IDC_CREATE_DIR)->SetWindowText(""); + GetDlgItem(IDC_REG_SERVICE)->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(""); +} + +/* + * Set the checklist tags for uninstall + */ +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_DIR); + GetDlgItem(IDC_DIR_TAG)->SetWindowText(tag); + GetDlgItem(IDC_CREATE_DIR)->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(""); +} + +void CBINDInstallDlg::SetItemStatus(UINT nID, BOOL bSuccess) { + GetDlgItem(nID)->SetWindowText(bSuccess == TRUE ? "Done" : "Failed"); +} + + +/* + * Set the text in the current operation field - use a string table string + */ +void CBINDInstallDlg::SetCurrent(int id, ...) { + CString format; + va_list va; + char buf[128]; + + format.LoadString(id); + memset(buf, 0, 128); + + va_start(va, id); + (void)vsnprintf(buf, sizeof(buf), format, va); + buf[sizeof(buf) - 1] = 0; + va_end(va); + + m_current.Format("%s", buf); + UpdateData(FALSE); +} + +/* + * Stop the BIND service + */ +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); +} + +/* + * Start the BIND service + */ +void CBINDInstallDlg::StartBINDService() { + SetCurrent(IDS_START_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 = StartService(hBINDSvc, 0, NULL); +} + +/* + * Check to see if the BIND service is running or not + */ +BOOL CBINDInstallDlg::CheckBINDService() { + SERVICE_STATUS svcStatus; + + SC_HANDLE hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + if (hSCManager) { + SC_HANDLE hBINDSvc = OpenService(hSCManager, BIND_SERVICE_NAME, + SERVICE_ALL_ACCESS); + if (hBINDSvc) { + BOOL rc = ControlService(hBINDSvc, + SERVICE_CONTROL_INTERROGATE, &svcStatus); + if (!rc) + DWORD err = GetLastError(); + + return (svcStatus.dwCurrentState == SERVICE_RUNNING); + } + } + return (FALSE); +} + +/* + * Display message boxes with variable args, using string table strings + * for the format specifiers + */ +int CBINDInstallDlg::MsgBox(int id, ...) { + CString format; + va_list va; + char buf[BUFSIZ]; + + format.LoadString(id); + memset(buf, 0, BUFSIZ); + + va_start(va, id); + (void)vsnprintf(buf, sizeof(buf), format, va); + buf[sizeof(buf) - 1] = 0; + va_end(va); + + return (MessageBox(buf)); +} + +int CBINDInstallDlg::MsgBox(int id, UINT type, ...) { + CString format; + va_list va; + char buf[BUFSIZ]; + + format.LoadString(id); + memset(buf, 0, BUFSIZ); + + va_start(va, type); + (void)vsnprintf(buf, sizeof(buf), format, va); + buf[sizeof(buf) - 1] = 0; + va_end(va); + + return(MessageBox(buf, NULL, type)); +} + +/* + * Call GetLastError(), retrieve the message associated with the error + */ +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 ); + + + strcpy(buf, (LPTSTR)msgBuf); + LocalFree(msgBuf); + /* Strip off the period and the \n */ + buf[len - 3] = 0; + return(buf); +} + +void CBINDInstallDlg::ProgramGroupCreate(TCHAR *commonPath) { + HRESULT hres; + IShellLink *psl = NULL; + ITEMIDLIST *itemList = NULL; + TCHAR fileloc[MAX_PATH]; + TCHAR linkpath[MAX_PATH]; + TCHAR path[MAX_PATH]; + int n; + + n = snprintf(path, sizeof(path), "%s\\ISC", commonPath); + if (n < 0 || (size_t)n >= sizeof(path)) + return; + CreateDirectory(path, NULL); + + n = snprintf(path, sizeof(path), "%s\\ISC\\BIND", commonPath); + if (n < 0 || (size_t)n >= sizeof(path)) + return; + CreateDirectory(path, NULL); + + hres = CoInitialize(NULL); + if (!SUCCEEDED(hres)) + return; + + // Get a pointer to the IShellLink interface. + hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, + IID_IShellLink, (LPVOID *)&psl); + if (!SUCCEEDED(hres)) { + goto cleanup; + } + + IPersistFile* ppf; + n = snprintf(linkpath, sizeof(linkpath), "%s\\BINDCtrl.lnk", path); + if (n < 0 || (size_t)n >= sizeof(path)) { + goto cleanup; + } + + n = snprintf(fileloc, sizeof(fileloc), "%s\\BINDCtrl.exe", + (LPCTSTR) m_binDir); + if (n < 0 || (size_t)n >= sizeof(path)) { + goto cleanup; + } + + psl->SetPath(fileloc); + psl->SetDescription("BIND Control Panel"); + + 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) { + goto cleanup; + } + + n = snprintf(fileloc, sizeof(fileloc), "%s\\Readme.txt", + (LPCTSTR) m_targetDir); + if (n < 0 || (size_t)n >= sizeof(fileloc)) { + goto cleanup; + } + + n = snprintf(linkpath, sizeof(linkpath), "%s\\Readme.lnk", path); + if (n < 0 || (size_t)n >= sizeof(linkpath)) { + goto cleanup; + } + + psl->SetPath(fileloc); + psl->SetDescription("BIND Readme"); + + 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(); + } + + cleanup: + if (psl) + psl->Release(); + CoUninitialize(); +} + +void CBINDInstallDlg::ProgramGroupRemove(TCHAR *commonPath) { + HANDLE hFind; + TCHAR filename[MAX_PATH]; + TCHAR path[MAX_PATH]; + WIN32_FIND_DATA fd; + int n; + + n = snprintf(path, sizeof(path), "%s\\ISC\\BIND", commonPath); + if (n < 0 || (size_t)n >= sizeof(path)) + goto remove_isc; + + n = snprintf(filename, sizeof(filename), "%s\\*.*", path); + if (n < 0 || (size_t)n >= sizeof(path)) + goto remove_isc_bind; + + hFind = FindFirstFile(filename, &fd); + if (hFind != INVALID_HANDLE_VALUE) { + do { + if (strcmp(fd.cFileName, ".") == 0 || + strcmp(fd.cFileName, "..") == 0) + continue; + n = snprintf(filename, sizeof(filename), "%s\\%s", + path, fd.cFileName); + if (n >= 0 && (size_t)n < sizeof(filename)) { + DeleteFile(filename); + } + } while (FindNextFile(hFind, &fd)); + FindClose(hFind); + } + + remove_isc_bind: + RemoveDirectory(path); + + remove_isc: + n = snprintf(path, sizeof(path), "%s\\ISC", commonPath); + if (n >= 0 && (size_t)n < sizeof(path)) + RemoveDirectory(path); +} + +void CBINDInstallDlg::ProgramGroup(BOOL create) { + HRESULT hr; + ITEMIDLIST *itemList = NULL; + LPMALLOC pMalloc = NULL; + TCHAR commonPath[MAX_PATH]; + + hr = SHGetMalloc(&pMalloc); + if (hr != NOERROR) { + MessageBox("Could not get a handle to Shell memory object"); + return; + } + + hr = SHGetSpecialFolderLocation(m_hWnd, CSIDL_COMMON_PROGRAMS, + &itemList); + if (hr != NOERROR) { + MessageBox("Could not get a handle to the Common Programs " + "folder"); + if (itemList) { + pMalloc->Free(itemList); + } + return; + } + + hr = SHGetPathFromIDList(itemList, commonPath); + pMalloc->Free(itemList); + + if (create) { + ProgramGroupCreate(commonPath); + } else { + ProgramGroupRemove(commonPath); + } +} + +CString CBINDInstallDlg::DestDir(int destination) { + switch(destination) { + case FileData::TargetDir: + return m_targetDir; + case FileData::BinDir: + return m_binDir; + case FileData::EtcDir: + return m_etcDir; + case FileData::WinSystem: + return m_winSysDir; + } + return(""); +} diff --git a/bin/win32/BINDInstall/BINDInstallDlg.h b/bin/win32/BINDInstall/BINDInstallDlg.h new file mode 100644 index 0000000..cdc3a43 --- /dev/null +++ b/bin/win32/BINDInstall/BINDInstallDlg.h @@ -0,0 +1,126 @@ +/* + * Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + + +/* + * Copyright (c) 1999-2000 by Nortel Networks Corporation + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND NORTEL NETWORKS DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NORTEL NETWORKS + * BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#ifndef BINDINSTALLDLG_H +#define BINDINSTALLDLG_H + +class CBINDInstallDlg : public CDialog +{ +public: + CBINDInstallDlg(CWnd* pParent = NULL); // standard constructor + + //{{AFX_DATA(CBINDInstallDlg) + enum { IDD = IDD_BINDINSTALL_DIALOG }; + CString m_targetDir; + CString m_version; + BOOL m_autoStart; + BOOL m_keepFiles; + BOOL m_toolsOnly; + CString m_current; + BOOL m_startOnInstall; + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CBINDInstallDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +protected: + void StartBINDService(); + void StopBINDService(); + + void InstallTags(); + void UninstallTags(); + + void CreateDirs(); + void RemoveDirs(BOOL uninstall); + + void ReadInstallFlags(); + void ReadInstallFileList(); + + void CopyFiles(); + void DeleteFiles(BOOL uninstall); + + void RegisterService(); + void UpdateService(CString StartName); + void UnregisterService(BOOL uninstall); + + void RegisterMessages(); + void UnregisterMessages(BOOL uninstall); + + void FailedInstall(); + void SetItemStatus(UINT nID, BOOL bSuccess = TRUE); + + void GetCurrentServiceAccountName(); + BOOL ValidateServiceAccount(); +protected: + CString DestDir(int destination); + int MsgBox(int id, ...); + int MsgBox(int id, UINT type, ...); + CString GetErrMessage(DWORD err = -1); + BOOL CheckBINDService(); + void SetCurrent(int id, ...); + void ProgramGroup(BOOL create = TRUE); + void ProgramGroupCreate(TCHAR *commonPath); + void ProgramGroupRemove(TCHAR *commonPath); + + HICON m_hIcon; + CString m_defaultDir; + CString m_etcDir; + CString m_binDir; + CString m_winSysDir; + BOOL m_installed; + CString m_currentDir; + BOOL m_accountExists; + BOOL m_accountUsed; + CString m_currentAccount; + CString m_accountName; + CString m_accountPasswordConfirm; + CString m_accountPassword; + BOOL m_serviceExists; + + // Generated message map functions + //{{AFX_MSG(CBINDInstallDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnPaint(); + afx_msg HCURSOR OnQueryDragIcon(); + afx_msg void OnBrowse(); + afx_msg void OnChangeTargetdir(); + afx_msg void OnInstall(); + afx_msg void OnExit(); + afx_msg void OnUninstall(); + afx_msg void OnAutoStart(); + afx_msg void OnKeepFiles(); + afx_msg void OnStartOnInstall(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +#endif diff --git a/bin/win32/BINDInstall/DirBrowse.cpp b/bin/win32/BINDInstall/DirBrowse.cpp new file mode 100644 index 0000000..758dc60 --- /dev/null +++ b/bin/win32/BINDInstall/DirBrowse.cpp @@ -0,0 +1,95 @@ +/* + * Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +/* + * Copyright (c) 1999-2000 by Nortel Networks Corporation + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND NORTEL NETWORKS DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NORTEL NETWORKS + * BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#include "stdafx.h" +#include "BINDInstall.h" +#include "DirBrowse.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CDirBrowse dialog + + +CDirBrowse::CDirBrowse(CString initialDir, CWnd* pParent /*=NULL*/) + : CDialog(CDirBrowse::IDD, pParent) +{ + //{{AFX_DATA_INIT(CDirBrowse) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + m_selectedDir = initialDir; +} + + +void CDirBrowse::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CDirBrowse) + // NOTE: the ClassWizard will add DDX and DDV calls here + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CDirBrowse, CDialog) + //{{AFX_MSG_MAP(CDirBrowse) + ON_LBN_DBLCLK(IDC_DIRLIST, OnDblclkDirlist) + ON_LBN_SELCHANGE(IDC_DIRLIST, OnSelchangeDirlist) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CDirBrowse message handlers + +BOOL CDirBrowse::OnInitDialog() +{ + CDialog::OnInitDialog(); + + DlgDirList((LPTSTR)(LPCTSTR)m_selectedDir, IDC_DIRLIST, IDC_CURDIR, DDL_DIRECTORY); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CDirBrowse::OnDblclkDirlist() +{ + CListBox *lb = (CListBox *)GetDlgItem(IDC_DIRLIST); + CString curSel; + + lb->GetText(lb->GetCurSel(), curSel); + DlgDirList((LPTSTR)(LPCTSTR)curSel, IDC_DIRLIST, IDC_CURDIR, DDL_DIRECTORY); +} + +void CDirBrowse::OnSelchangeDirlist() +{ + // TODO: Add your control notification handler code here + +} diff --git a/bin/win32/BINDInstall/DirBrowse.h b/bin/win32/BINDInstall/DirBrowse.h new file mode 100644 index 0000000..080cacf --- /dev/null +++ b/bin/win32/BINDInstall/DirBrowse.h @@ -0,0 +1,64 @@ +/* + * Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + + +/* + * Copyright (c) 1999-2000 by Nortel Networks Corporation + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND NORTEL NETWORKS DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NORTEL NETWORKS + * BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#ifndef DIRBROWSE_H +#define DIRBROWSE_H + +class CDirBrowse : public CDialog +{ +// Construction +public: + CDirBrowse(CString initialDir = "\\", CWnd* pParent = NULL); // standard constructor + CString GetSelectedDir() {return(m_selectedDir);} + + //{{AFX_DATA(CDirBrowse) + enum { IDD = IDD_BROWSE }; + // NOTE: the ClassWizard will add data members here + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CDirBrowse) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +protected: + // Generated message map functions + //{{AFX_MSG(CDirBrowse) + virtual BOOL OnInitDialog(); + afx_msg void OnDblclkDirlist(); + afx_msg void OnSelchangeDirlist(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + +private: + CString m_selectedDir; +}; + +#endif diff --git a/bin/win32/BINDInstall/StdAfx.cpp b/bin/win32/BINDInstall/StdAfx.cpp new file mode 100644 index 0000000..a4195ca --- /dev/null +++ b/bin/win32/BINDInstall/StdAfx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// BINDInstall.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + + diff --git a/bin/win32/BINDInstall/StdAfx.h b/bin/win32/BINDInstall/StdAfx.h new file mode 100644 index 0000000..099ecb2 --- /dev/null +++ b/bin/win32/BINDInstall/StdAfx.h @@ -0,0 +1,36 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +/* + * Minimum version is Windows XP SP1 + */ +#define _WIN32_WINNT 0x0501 +#define NTDDI_VERSION 0x05010100 + +#ifndef _CRT_SECURE_NO_DEPRECATE +#define _CRT_SECURE_NO_DEPRECATE 1 +#endif + +#if !defined(AFX_STDAFX_H__61537819_39FC_11D3_A97A_00105A12BD65__INCLUDED_) +#define AFX_STDAFX_H__61537819_39FC_11D3_A97A_00105A12BD65__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers + +#include <afxwin.h> // MFC core and standard components +#include <afxext.h> // MFC extensions +#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include <afxcmn.h> // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT + + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__61537819_39FC_11D3_A97A_00105A12BD65__INCLUDED_) diff --git a/bin/win32/BINDInstall/VersionInfo.cpp b/bin/win32/BINDInstall/VersionInfo.cpp new file mode 100644 index 0000000..e83348f --- /dev/null +++ b/bin/win32/BINDInstall/VersionInfo.cpp @@ -0,0 +1,293 @@ +// VersionInfo.cpp: implementation of the CVersionInfo class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "bindinstall.h" +#include "VersionInfo.h" +#include <winver.h> + +#include <config.h> + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CVersionInfo::CVersionInfo(CString filename) +{ + HANDLE hFile; + WIN32_FIND_DATA fd; + memset(&fd, 0, sizeof(WIN32_FIND_DATA)); + + m_status = ERROR_SUCCESS; + m_isValid = FALSE; + m_filename = filename; + + // See if the given file exists + hFile = FindFirstFile(filename, &fd); + if(hFile == INVALID_HANDLE_VALUE) + { + m_status = ERROR_FILE_NOT_FOUND; + m_versionInfo = NULL; + return; + } + FindClose(hFile); + + // Extract the file info + DWORD handle; + DWORD viSize = GetFileVersionInfoSize((LPTSTR)(LPCTSTR)filename, &handle); + m_versionInfo = NULL; + + if(viSize == 0) + { + m_status = GetLastError(); + } + else + { + m_versionInfo = new char[viSize]; + + // Get the block of version info from the file + if(!GetFileVersionInfo((LPTSTR)(LPCTSTR)filename, handle, viSize, m_versionInfo)) + { + if(m_versionInfo) + { + delete [] m_versionInfo; + m_versionInfo = NULL; + } + return; + } + + // Now extract the sub block we are interested in + UINT versionLen = 0; + LPVOID viBlob = NULL; + if(!VerQueryValue(m_versionInfo, "\\", &viBlob, &versionLen)) + { + if(m_versionInfo) + { + delete [] m_versionInfo; + m_versionInfo = NULL; + } + return; + } + + // And finally the version info is ours + m_fixedInfo = (VS_FIXEDFILEINFO *)viBlob; + + UINT blobLen = 0; + + // If we got here, all is good + } + m_isValid = TRUE; +} + +CVersionInfo::~CVersionInfo() +{ + m_fixedInfo = NULL; + if(m_versionInfo) + { + delete [] m_versionInfo; + m_versionInfo = NULL; + } +} + +CString CVersionInfo::GetFileVersionString() +{ + return(QueryStringValue("FileVersion")); +} + +CString CVersionInfo::GetProductVersionString() +{ + return(QueryStringValue("ProductVersion")); +} + +CString CVersionInfo::GetComments() +{ + return(QueryStringValue("Comments")); +} + +CString CVersionInfo::GetFileDescription() +{ + return(QueryStringValue("FileDescription")); +} + +CString CVersionInfo::GetInternalName() +{ + return(QueryStringValue("InternalName")); +} + +CString CVersionInfo::GetLegalCopyright() +{ + return(QueryStringValue("LegalCopyright")); +} + +CString CVersionInfo::GetLegalTrademarks() +{ + return(QueryStringValue("LegalTrademarks")); +} + +CString CVersionInfo::GetOriginalFileName() +{ + return(QueryStringValue("OriginalFilename")); +} + +CString CVersionInfo::GetProductName() +{ + return(QueryStringValue("ProductName")); +} + +CString CVersionInfo::GetSpecialBuildString() +{ + return(QueryStringValue("SpecialBuild")); +} + +CString CVersionInfo::GetPrivateBuildString() +{ + return(QueryStringValue("PrivateBuild")); +} + +CString CVersionInfo::GetCompanyName() +{ + return(QueryStringValue("CompanyName")); +} + +#ifdef NOTUSED +BOOL CVersionInfo::CopyFileCheckVersion(CVersionInfo &originalFile) +{ + _int64 myVer = GetFileVersion(); + _int64 origVer = originalFile.GetFileVersion(); + + if(origVer > myVer) + { + CString msg; + msg.Format(IDS_EXISTING_NEWER, m_filename); + DWORD query = AfxMessageBox(msg, MB_YESNO); + if(query == IDNO) + return(TRUE); + } + + return(CopyFileNoVersion(originalFile)); +} +#endif + +BOOL CVersionInfo::CopyFileNoVersion(CVersionInfo &originalFile) +{ + return(CopyFile(originalFile.GetFilename(), m_filename, FALSE)); +} + + +_int64 CVersionInfo::GetFileVersion() +{ + _int64 ver = 0; + + if(m_versionInfo) + { + ver = m_fixedInfo->dwFileVersionMS; + ver <<= 32; + ver += m_fixedInfo->dwFileVersionLS; + } + return(ver); +} + +_int64 CVersionInfo::GetProductVersion() +{ + _int64 ver = 0; + + if(m_versionInfo) + { + ver = m_fixedInfo->dwProductVersionMS; + ver <<= 32; + ver += m_fixedInfo->dwProductVersionLS; + } + return(ver); +} + +_int64 CVersionInfo::GetFileDate() +{ + _int64 fDate = 0; + + if(m_versionInfo) + { + fDate = m_fixedInfo->dwFileDateMS; + fDate <<= 32; + fDate += m_fixedInfo->dwFileDateLS; + } + return(fDate); +} + +DWORD CVersionInfo::GetFileFlagMask() +{ + if(m_versionInfo) + { + return(m_fixedInfo->dwFileFlagsMask); + } + return(0); +} + +DWORD CVersionInfo::GetFileFlags() +{ + if(m_versionInfo) + { + return(m_fixedInfo->dwFileFlags); + } + return(0); +} + +DWORD CVersionInfo::GetFileOS() +{ + if(m_versionInfo) + { + return(m_fixedInfo->dwFileOS); + } + return(VOS_UNKNOWN); +} + +DWORD CVersionInfo::GetFileType() +{ + if(m_versionInfo) + { + return(m_fixedInfo->dwFileType); + } + return(VFT_UNKNOWN); +} + +DWORD CVersionInfo::GetFileSubType() +{ + if(m_versionInfo) + { + return(m_fixedInfo->dwFileSubtype); + } + return(VFT2_UNKNOWN); +} + +CString CVersionInfo::QueryStringValue(CString value) +{ + UINT blobLen = 0; + LPVOID viBlob = NULL; + int n; + + if(m_versionInfo) + { + char queryString[256]; + + // This code page value is for American English. + // If you change the resources to be other than that + // You probably should change this to match it. + DWORD codePage = 0x040904B0; + + n = snprintf(queryString, sizeof(queryString), + "\\StringFileInfo\\%08X\\%s", + codePage, (LPCTSTR) value); + if (n >= 0 && (size_t)n < sizeof(queryString)) { + if(VerQueryValue(m_versionInfo, queryString, + &viBlob, &blobLen)) + return((char *)viBlob); + } + } + return("Not Available"); +} diff --git a/bin/win32/BINDInstall/VersionInfo.h b/bin/win32/BINDInstall/VersionInfo.h new file mode 100644 index 0000000..ec21540 --- /dev/null +++ b/bin/win32/BINDInstall/VersionInfo.h @@ -0,0 +1,62 @@ +// VersionInfo.h: interface for the CVersionInfo class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_VERSIONINFO_H__F82E9FF3_5298_11D4_AB87_00C04F789BA0__INCLUDED_) +#define AFX_VERSIONINFO_H__F82E9FF3_5298_11D4_AB87_00C04F789BA0__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +class CVersionInfo +{ +public: + CVersionInfo(CString filename); + virtual ~CVersionInfo(); + BOOL IsValid() {return m_isValid;} + DWORD GetStatus() {return m_status;} + + BOOL CopyFileCheckVersion(CVersionInfo &originalFile); + BOOL CopyFileNoVersion(CVersionInfo &originalFile); + + const CString &GetFilename() {return m_filename;} + + // Extract the elements of the file's string info block + CString GetFileVersionString(); + CString GetProductVersionString(); + CString GetComments(); + CString GetFileDescription(); + CString GetInternalName(); + CString GetLegalCopyright(); + CString GetLegalTrademarks(); + CString GetOriginalFileName(); + CString GetProductName(); + CString GetSpecialBuildString(); + CString GetPrivateBuildString(); + CString GetCompanyName(); + + + // Extract the elements of the file's VS_FIXEDFILEINFO block + _int64 GetFileVersion(); + _int64 GetProductVersion(); + _int64 GetFileDate(); + + DWORD GetFileFlagMask(); + DWORD GetFileFlags(); + DWORD GetFileOS(); + DWORD GetFileType(); + DWORD GetFileSubType(); + +private: + CString m_filename; + BOOL m_isValid; + LPVOID m_versionInfo; + VS_FIXEDFILEINFO *m_fixedInfo; + DWORD m_codePage; + DWORD m_status; + + CString QueryStringValue(CString value); +}; + +#endif // !defined(AFX_VERSIONINFO_H__F82E9FF3_5298_11D4_AB87_00C04F789BA0__INCLUDED_) diff --git a/bin/win32/BINDInstall/res/BINDInstall.ico b/bin/win32/BINDInstall/res/BINDInstall.ico Binary files differnew file mode 100644 index 0000000..2cf25fe --- /dev/null +++ b/bin/win32/BINDInstall/res/BINDInstall.ico diff --git a/bin/win32/BINDInstall/res/BINDInstall.rc2 b/bin/win32/BINDInstall/res/BINDInstall.rc2 new file mode 100644 index 0000000..4fc93bb --- /dev/null +++ b/bin/win32/BINDInstall/res/BINDInstall.rc2 @@ -0,0 +1,13 @@ +// +// BINDINSTALL.RC2 - resources Microsoft Visual C++ does not edit directly +// + +#ifdef APSTUDIO_INVOKED + #error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// Add manually edited resources here... + +///////////////////////////////////////////////////////////////////////////// diff --git a/bin/win32/BINDInstall/resource.h b/bin/win32/BINDInstall/resource.h new file mode 100644 index 0000000..b176fe0 --- /dev/null +++ b/bin/win32/BINDInstall/resource.h @@ -0,0 +1,104 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by BINDInstall.rc +// +#define IDS_MAINFRAME 1 +#define IDS_CREATEDIR 2 +#define IDS_SUCCESS 3 +#define IDS_FAIL 4 +#define IDS_DIREXIST 5 +#define IDS_INSTALL_DIR 6 +#define IDS_INSTALL_FILE 7 +#define IDS_INSTALL_SERVICE 8 +#define IDS_INSTALL_MESSAGE 9 +#define IDS_UNINSTALL 14 +#define IDS_UNINSTALL_DONE 15 +#define IDS_CREATE_KEY 16 +#define IDS_ADD_REMOVE 17 +#define IDS_CLEANUP 18 +#define IDS_INSTALL_DONE 19 +#define IDS_CREATE_DIR 20 +#define IDS_REMOVE_DIR 21 +#define IDS_COPY_FILE 22 +#define IDS_DELETE_FILE 23 +#define IDS_OPEN_SCM 24 +#define IDS_CREATE_SERVICE 25 +#define IDS_OPEN_SERVICE 26 +#define IDS_REMOVE_SERVICE 27 +#define IDS_REGISTER_MESSAGES 28 +#define IDS_UNREGISTER_MESSAGES 29 +#define IDS_STOP_SERVICE 30 +#define IDS_START_SERVICE 31 +#define IDS_UNINSTALL_DIR 32 +#define IDS_UNINSTALL_FILES 33 +#define IDS_UNINSTALL_SERVICE 34 +#define IDS_UNINSTALL_MESSAGE 35 +#define IDS_ERR_OPEN_SCM 36 +#define IDS_ERR_OPEN_SERVICE 37 +#define IDS_ERR_STOP_SERVICE 38 +#define IDS_ERR_NONCRIT_FILE 39 +#define IDS_ERR_CRITICAL_FILE 40 +#define IDS_ERR_COPY_FILE 40 +#define IDS_ERR_CREATE_SERVICE 41 +#define IDS_ERR_REMOVE_SERVICE 42 +#define IDS_REBOOT 43 +#define IDS_BAD_PRIVILEGES 44 +#define IDS_ERR_CREATE_DIR 45 +#define IDS_VERSION 46 +#define IDS_ERR_CREATE_KEY 47 +#define IDS_ERR_SET_VALUE 48 +#define IDS_NO_VERSION 49 +#define IDS_EXISTING_NEWER 50 +#define IDS_FILE_BAD 51 +#define IDS_ERR_TOOPRIVED 52 +#define IDS_ERR_BADACCOUNT 53 +#define IDS_ERR_WRONGPRIV 54 +#define IDS_CREATEACCOUNT_FAILED 55 +#define IDS_ERR_PASSWORD 56 +#define IDS_ERR_UPDATE_SERVICE 57 +#define IDS_ERR_NULLPASSWORD 58 +#define IDS_ERR_WHITESPACE 59 +#define IDD_BINDINSTALL_DIALOG 102 +#define IDR_MAINFRAME 128 +#define IDD_BROWSE 129 +#define IDI_CHECK 130 +#define IDI_X 132 +#define IDC_CURSOR1 142 +#define IDD_DIALOG1 143 +#define IDC_TARGETDIR 1001 +#define IDC_BROWSE 1002 +#define IDC_DIRLIST 1004 +#define IDC_CURDIR 1005 +#define IDC_INSTALL 1006 +#define IDC_COPY_FILE 1007 +#define IDC_REG_SERVICE 1008 +#define IDC_REG_MESSAGE 1009 +#define IDC_CREATE_DIR 1010 +#define IDC_EXIT 1011 +#define IDC_DIR_TAG 1012 +#define IDC_COPY_TAG 1013 +#define IDC_SERVICE_TAG 1014 +#define IDC_MESSAGE_TAG 1015 +#define IDC_AUTO_START 1016 +#define IDC_UNINSTALL 1017 +#define IDC_VERSION 1018 +#define IDC_KEEP_FILES 1019 +#define IDC_CURRENT_TAG 1020 +#define IDC_DRIVES 1021 +#define IDC_CURRENT 1021 +#define IDC_START 1022 +#define IDC_ACCOUNT_NAME 1030 +#define IDC_ACCOUNT_PASSWORD 1031 +#define IDC_ACCOUNT_PASSWORD_CONFIRM 1032 +#define IDC_TOOLS_ONLY 1033 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 144 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1027 +#define _APS_NEXT_SYMED_VALUE 104 +#endif +#endif |