[SYSSETUP] Open the security settings inf file only once in order to apply the settings

This commit is contained in:
Eric Kohl 2018-05-29 01:32:52 +02:00
parent 6e4e772e6c
commit 67e45c41ee

View file

@ -271,9 +271,9 @@ InstallBuiltinAccounts(VOID)
static static
VOID VOID
InstallPrivileges(VOID) InstallPrivileges(
HINF hSecurityInf)
{ {
HINF hSecurityInf = INVALID_HANDLE_VALUE;
LSA_OBJECT_ATTRIBUTES ObjectAttributes; LSA_OBJECT_ATTRIBUTES ObjectAttributes;
WCHAR szPrivilegeString[256]; WCHAR szPrivilegeString[256];
WCHAR szSidString[256]; WCHAR szSidString[256];
@ -287,16 +287,6 @@ InstallPrivileges(VOID)
DPRINT("InstallPrivileges()\n"); DPRINT("InstallPrivileges()\n");
hSecurityInf = SetupOpenInfFileW(L"defltws.inf", //szNameBuffer,
NULL,
INF_STYLE_WIN4,
NULL);
if (hSecurityInf == INVALID_HANDLE_VALUE)
{
DPRINT1("SetupOpenInfFileW failed\n");
return;
}
memset(&ObjectAttributes, 0, sizeof(LSA_OBJECT_ATTRIBUTES)); memset(&ObjectAttributes, 0, sizeof(LSA_OBJECT_ATTRIBUTES));
Status = LsaOpenPolicy(NULL, Status = LsaOpenPolicy(NULL,
@ -394,17 +384,14 @@ InstallPrivileges(VOID)
done: done:
if (PolicyHandle != NULL) if (PolicyHandle != NULL)
LsaClose(PolicyHandle); LsaClose(PolicyHandle);
if (hSecurityInf != INVALID_HANDLE_VALUE)
SetupCloseInfFile(hSecurityInf);
} }
static static
VOID VOID
ApplyRegistryValues(VOID) ApplyRegistryValues(
HINF hSecurityInf)
{ {
HINF hSecurityInf = INVALID_HANDLE_VALUE;
WCHAR szRegistryPath[MAX_PATH]; WCHAR szRegistryPath[MAX_PATH];
WCHAR szRootName[MAX_PATH]; WCHAR szRootName[MAX_PATH];
WCHAR szKeyName[MAX_PATH]; WCHAR szKeyName[MAX_PATH];
@ -418,23 +405,13 @@ ApplyRegistryValues(VOID)
DPRINT("ApplyRegistryValues()\n"); DPRINT("ApplyRegistryValues()\n");
hSecurityInf = SetupOpenInfFileW(L"defltws.inf", //szNameBuffer,
NULL,
INF_STYLE_WIN4,
NULL);
if (hSecurityInf == INVALID_HANDLE_VALUE)
{
DPRINT1("SetupOpenInfFileW failed\n");
return;
}
if (!SetupFindFirstLineW(hSecurityInf, if (!SetupFindFirstLineW(hSecurityInf,
L"Registry Values", L"Registry Values",
NULL, NULL,
&InfContext)) &InfContext))
{ {
DPRINT1("SetupFindFirstLineW failed\n"); DPRINT1("SetupFindFirstLineW failed\n");
goto done; return;
} }
do do
@ -447,7 +424,7 @@ ApplyRegistryValues(VOID)
NULL)) NULL))
{ {
DPRINT1("SetupGetStringFieldW() failed\n"); DPRINT1("SetupGetStringFieldW() failed\n");
goto done; return;
} }
DPRINT("RegistryPath: %S\n", szRegistryPath); DPRINT("RegistryPath: %S\n", szRegistryPath);
@ -606,19 +583,36 @@ ApplyRegistryValues(VOID)
} }
} }
while (SetupFindNextLine(&InfContext, &InfContext)); while (SetupFindNextLine(&InfContext, &InfContext));
done:
if (hSecurityInf != INVALID_HANDLE_VALUE)
SetupCloseInfFile(hSecurityInf);
} }
VOID VOID
InstallSecurity(VOID) InstallSecurity(VOID)
{ {
HINF hSecurityInf = INVALID_HANDLE_VALUE;
PWSTR pszSecurityInf;
// if (IsServer())
// pszSecurityInf = L"defltsv.inf";
// else
pszSecurityInf = L"defltws.inf";
InstallBuiltinAccounts(); InstallBuiltinAccounts();
InstallPrivileges();
ApplyRegistryValues(); hSecurityInf = SetupOpenInfFileW(pszSecurityInf,
NULL,
INF_STYLE_WIN4,
NULL);
if (hSecurityInf == INVALID_HANDLE_VALUE)
{
DPRINT1("SetupOpenInfFileW failed\n");
return;
}
InstallPrivileges(hSecurityInf);
ApplyRegistryValues(hSecurityInf);
SetupCloseInfFile(hSecurityInf);
/* Hack */ /* Hack */
SetPrimaryDomain(L"WORKGROUP", NULL); SetPrimaryDomain(L"WORKGROUP", NULL);