mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
Code cleanup. Checks now for out-of-memory errors on mallocs, and privides additional error information on failure. Fixed missing Done message in GUI
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: AccountInfo.cpp,v 1.2 2001/09/29 00:01:43 gson Exp $ */
|
||||
/* $Id: AccountInfo.cpp,v 1.3 2001/10/05 05:45:48 mayer Exp $ */
|
||||
|
||||
#ifndef UNICODE
|
||||
#define UNICODE
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <ntsecapi.h>
|
||||
|
||||
#include <isc/ntgroups.h>
|
||||
#include <isc/result.h>
|
||||
#include "AccountInfo.h"
|
||||
|
||||
#define MAX_NAME_LENGTH 256
|
||||
@@ -114,6 +115,7 @@ GetAccountPrivileges(char *name, wchar_t **PrivList, unsigned int *PrivCount,
|
||||
PSID pSid;
|
||||
unsigned int i;
|
||||
NTSTATUS Status;
|
||||
isc_result_t istatus;
|
||||
int iRetVal=RTN_ERROR; /* assume error from main */
|
||||
|
||||
/*
|
||||
@@ -133,8 +135,14 @@ GetAccountPrivileges(char *name, wchar_t **PrivList, unsigned int *PrivCount,
|
||||
/*
|
||||
* Find out what groups the account belongs to
|
||||
*/
|
||||
Status = isc_ntsecurity_getaccountgroups(name, Accounts, maxAccounts,
|
||||
totalAccounts);
|
||||
istatus = isc_ntsecurity_getaccountgroups(name, Accounts, maxAccounts,
|
||||
totalAccounts);
|
||||
if (istatus == ISC_R_NOMEMORY) {
|
||||
return (RTN_NOMEMORY);
|
||||
}
|
||||
else if (istatus != ISC_R_SUCCESS) {
|
||||
return (RTN_ERROR);
|
||||
}
|
||||
|
||||
Accounts[*totalAccounts] = name; /* Add the account to the list */
|
||||
(*totalAccounts)++;
|
||||
@@ -179,10 +187,8 @@ CreateServiceAccount(char *name, char *password) {
|
||||
|
||||
unsigned int namelen = strlen(name);
|
||||
unsigned int passwdlen = strlen(password);
|
||||
wchar_t *AccountName = (wchar_t *)malloc((namelen + 1)*
|
||||
sizeof(wchar_t));
|
||||
wchar_t *AccountPassword = (wchar_t *)malloc((passwdlen + 1)*
|
||||
sizeof(wchar_t));
|
||||
wchar_t AccountName[MAX_NAME_LENGTH];
|
||||
wchar_t AccountPassword[MAX_NAME_LENGTH];
|
||||
|
||||
mbstowcs(AccountName, name, namelen + 1);
|
||||
mbstowcs(AccountPassword, password, passwdlen + 1);
|
||||
@@ -193,8 +199,8 @@ CreateServiceAccount(char *name, char *password) {
|
||||
* rather than an administrator or a guest.
|
||||
*/
|
||||
|
||||
ui.usri1_name = AccountName;
|
||||
ui.usri1_password = AccountPassword;
|
||||
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";
|
||||
@@ -205,8 +211,6 @@ CreateServiceAccount(char *name, char *password) {
|
||||
*/
|
||||
nStatus = NetUserAdd(NULL, dwLevel, (LPBYTE)&ui, &dwError);
|
||||
|
||||
free(AccountPassword);
|
||||
free(AccountName);
|
||||
if (nStatus != NERR_Success)
|
||||
return (FALSE);
|
||||
|
||||
@@ -394,6 +398,9 @@ GetPrivilegesOnAccount(LSA_HANDLE PolicyHandle, PSID AccountSid,
|
||||
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';
|
||||
|
@@ -15,11 +15,13 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: AccountInfo.h,v 1.2 2001/09/29 00:01:44 gson Exp $ */
|
||||
/* $Id: AccountInfo.h,v 1.3 2001/10/05 05:45:50 mayer Exp $ */
|
||||
|
||||
#define RTN_OK 0
|
||||
#define RTN_NOACCOUNT 1
|
||||
#define RTN_ERROR 10
|
||||
|
||||
#define RTN_OK 0
|
||||
#define RTN_NOACCOUNT 1
|
||||
#define RTN_NOMEMORY 2
|
||||
#define RTN_ERROR 10
|
||||
|
||||
#define SE_SERVICE_LOGON_PRIV L"SeServiceLogonRight"
|
||||
|
||||
|
@@ -25,10 +25,6 @@ NULL=
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "BINDInstall - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
@@ -53,8 +49,42 @@ CLEAN :
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /MD /W3 /GX /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" /D "_AFXDLL" /Fp"$(INTDIR)\BINDInstall.pch" /Yu"stdafx.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /TP /c
|
||||
|
||||
.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) $<
|
||||
<<
|
||||
|
||||
MTL=midl.exe
|
||||
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\BINDInstall.res" /d "NDEBUG" /d "_AFXDLL"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\BINDInstall.bsc"
|
||||
@@ -63,14 +93,14 @@ BSC32_SBRS= \
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=version.lib netapi32.lib /nologo /subsystem:windows /pdb:none /machine:I386 /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" \
|
||||
"$(INTDIR)\AccountInfo.obj" \
|
||||
"$(INTDIR)\ntgroups.obj"
|
||||
"$(INTDIR)\BINDInstall.res"
|
||||
|
||||
"..\..\..\Build\Release\BINDInstall.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
@@ -113,43 +143,8 @@ CLEAN :
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /MDd /W3 /Gm /GX /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" /D "_AFXDLL" /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" /d "_AFXDLL"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\BINDInstall.bsc"
|
||||
BSC32_SBRS= \
|
||||
"$(INTDIR)\BINDInstall.sbr" \
|
||||
"$(INTDIR)\BINDInstallDlg.sbr" \
|
||||
"$(INTDIR)\DirBrowse.sbr" \
|
||||
"$(INTDIR)\StdAfx.sbr" \
|
||||
"$(INTDIR)\VersionInfo.sbr" \
|
||||
"$(INTDIR)\AccountInfo.sbr" \
|
||||
"$(INTDIR)\ntgroups.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:I386 /out:"..\..\..\Build\Debug\BINDInstall.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\BINDInstall.obj" \
|
||||
"$(INTDIR)\BINDInstallDlg.obj" \
|
||||
"$(INTDIR)\DirBrowse.obj" \
|
||||
"$(INTDIR)\StdAfx.obj" \
|
||||
"$(INTDIR)\VersionInfo.obj" \
|
||||
"$(INTDIR)\BINDInstall.res" \
|
||||
"$(INTDIR)\AccountInfo.obj" \
|
||||
"$(INTDIR)\ntgroups.obj"
|
||||
|
||||
"..\..\..\Build\Debug\BINDInstall.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
@@ -181,6 +176,45 @@ LINK32_OBJS= \
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
MTL=midl.exe
|
||||
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\BINDInstall.res" /d "_DEBUG" /d "_AFXDLL"
|
||||
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:I386 /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)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("BINDInstall.dep")
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: BINDInstallDlg.cpp,v 1.9 2001/09/26 02:22:25 mayer Exp $ */
|
||||
/* $Id: BINDInstallDlg.cpp,v 1.10 2001/10/05 05:45:52 mayer Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999-2000 by Nortel Networks Corporation
|
||||
@@ -726,9 +726,11 @@ CBINDInstallDlg::RegisterService() {
|
||||
if(m_serviceExists == TRUE) {
|
||||
if(m_accountUsed == FALSE) {
|
||||
UpdateService();
|
||||
SetItemStatus(IDC_REG_SERVICE);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
SetItemStatus(IDC_REG_SERVICE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user