Author: ekohl
Date: Mon May 28 15:04:26 2012
New Revision: 56670
URL:
http://svn.reactos.org/svn/reactos?rev=56670&view=rev
Log:
[SAMSRV]
Add Names sub keys to the Alias, Groups and Users keys of the Account an Builtin domains.
These will later contain the 'Name to SID' entries that will simplify lookup by
name operations.
Modified:
trunk/reactos/dll/win32/samsrv/setup.c
Modified: trunk/reactos/dll/win32/samsrv/setup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samsrv/setup.c?r…
==============================================================================
--- trunk/reactos/dll/win32/samsrv/setup.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/samsrv/setup.c [iso-8859-1] Mon May 28 15:04:26 2012
@@ -56,6 +56,28 @@
static BOOL
+CreateNamesKey(HKEY hParentKey)
+{
+ DWORD dwDisposition;
+ HKEY hNamesKey;
+
+ if (RegCreateKeyExW(hParentKey,
+ L"Names",
+ 0,
+ NULL,
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hNamesKey,
+ &dwDisposition))
+ return FALSE;
+
+ RegCloseKey(hNamesKey);
+ return TRUE;
+}
+
+
+static BOOL
CreateBuiltinAliases(HKEY hAliasesKey)
{
return TRUE;
@@ -80,13 +102,14 @@
SampInitializeSAM(VOID)
{
DWORD dwDisposition;
- HKEY hSamKey;
- HKEY hDomainsKey;
- HKEY hAccountKey;
- HKEY hBuiltinKey;
- HKEY hAliasesKey;
- HKEY hGroupsKey;
- HKEY hUsersKey;
+ HKEY hSamKey = NULL;
+ HKEY hDomainsKey = NULL;
+ HKEY hAccountKey = NULL;
+ HKEY hBuiltinKey = NULL;
+ HKEY hAliasesKey = NULL;
+ HKEY hGroupsKey = NULL;
+ HKEY hUsersKey = NULL;
+ BOOL bResult = TRUE;
TRACE("SampInitializeSAM() called\n");
@@ -115,11 +138,12 @@
&dwDisposition))
{
ERR("Failed to create 'Domains' key! (Error %lu)\n",
GetLastError());
- RegCloseKey(hSamKey);
- return FALSE;
- }
-
- RegCloseKey (hSamKey);
+ bResult = FALSE;
+ goto done;
+ }
+
+ RegCloseKey(hSamKey);
+ hSamKey = NULL;
/* Create the 'Domains\\Account' key */
if (RegCreateKeyExW(hDomainsKey,
@@ -133,8 +157,8 @@
&dwDisposition))
{
ERR("Failed to create 'Domains\\Account' key! (Error %lu)\n",
GetLastError());
- RegCloseKey(hDomainsKey);
- return FALSE;
+ bResult = FALSE;
+ goto done;
}
@@ -150,13 +174,19 @@
&dwDisposition))
{
ERR("Failed to create 'Account\\Aliases' key! (Error %lu)\n",
GetLastError());
- RegCloseKey(hAccountKey);
- RegCloseKey(hDomainsKey);
- return FALSE;
- }
-
- RegCloseKey (hAliasesKey);
-
+ bResult = FALSE;
+ goto done;
+ }
+
+ if (!CreateNamesKey(hAliasesKey))
+ {
+ ERR("Failed to create 'Account\\Aliases\\Names' key! (Error
%lu)\n", GetLastError());
+ bResult = FALSE;
+ goto done;
+ }
+
+ RegCloseKey(hAliasesKey);
+ hAliasesKey = NULL;
/* Create the 'Account\Groups' key */
if (RegCreateKeyExW(hAccountKey,
@@ -170,12 +200,19 @@
&dwDisposition))
{
ERR("Failed to create 'Account\\Groups' key! (Error %lu)\n",
GetLastError());
- RegCloseKey(hAccountKey);
- RegCloseKey(hDomainsKey);
- return FALSE;
+ bResult = FALSE;
+ goto done;
+ }
+
+ if (!CreateNamesKey(hGroupsKey))
+ {
+ ERR("Failed to create 'Account\\Groups\\Names' key! (Error
%lu)\n", GetLastError());
+ bResult = FALSE;
+ goto done;
}
RegCloseKey(hGroupsKey);
+ hGroupsKey = NULL;
/* Create the 'Account\Users' key */
@@ -190,15 +227,22 @@
&dwDisposition))
{
ERR("Failed to create 'Account\\Users' key! (Error %lu)\n",
GetLastError());
- RegCloseKey(hAccountKey);
- RegCloseKey(hDomainsKey);
- return FALSE;
+ bResult = FALSE;
+ goto done;
+ }
+
+ if (!CreateNamesKey(hUsersKey))
+ {
+ ERR("Failed to create 'Account\\Aliases\\Users' key! (Error
%lu)\n", GetLastError());
+ bResult = FALSE;
+ goto done;
}
RegCloseKey(hUsersKey);
+ hUsersKey = NULL;
RegCloseKey(hAccountKey);
-
+ hAccountKey = NULL;
/* Create the 'Domains\\Builtin' */
if (RegCreateKeyExW(hDomainsKey,
@@ -212,8 +256,8 @@
&dwDisposition))
{
ERR("Failed to create Builtin key! (Error %lu)\n", GetLastError());
- RegCloseKey(hDomainsKey);
- return FALSE;
+ bResult = FALSE;
+ goto done;
}
@@ -229,23 +273,27 @@
&dwDisposition))
{
ERR("Failed to create 'Builtin\\Aliases' key! (Error %lu)\n",
GetLastError());
- RegCloseKey(hBuiltinKey);
- RegCloseKey(hDomainsKey);
- return FALSE;
+ bResult = FALSE;
+ goto done;
+ }
+
+ if (!CreateNamesKey(hAliasesKey))
+ {
+ ERR("Failed to create 'Builtin\\Aliases\\Names' key! (Error
%lu)\n", GetLastError());
+ bResult = FALSE;
+ goto done;
}
/* Create builtin aliases */
if (!CreateBuiltinAliases(hAliasesKey))
{
ERR("Failed to create builtin aliases!\n");
- RegCloseKey(hAliasesKey);
- RegCloseKey(hBuiltinKey);
- RegCloseKey(hDomainsKey);
- return FALSE;
+ bResult = FALSE;
+ goto done;
}
RegCloseKey(hAliasesKey);
-
+ hAliasesKey = NULL;
/* Create the 'Builtin\Groups' key */
if (RegCreateKeyExW(hBuiltinKey,
@@ -259,22 +307,27 @@
&dwDisposition))
{
ERR("Failed to create 'Builtin\\Groups' key! (Error %lu)\n",
GetLastError());
- RegCloseKey(hBuiltinKey);
- RegCloseKey(hDomainsKey);
- return FALSE;
+ bResult = FALSE;
+ goto done;
+ }
+
+ if (!CreateNamesKey(hGroupsKey))
+ {
+ ERR("Failed to create 'Builtin\\Groups\\Names' key! (Error
%lu)\n", GetLastError());
+ bResult = FALSE;
+ goto done;
}
/* Create builtin groups */
if (!CreateBuiltinGroups(hGroupsKey))
{
ERR("Failed to create builtin groups!\n");
- RegCloseKey(hGroupsKey);
- RegCloseKey(hBuiltinKey);
- RegCloseKey(hDomainsKey);
- return FALSE;
+ bResult = FALSE;
+ goto done;
}
RegCloseKey(hGroupsKey);
+ hGroupsKey = NULL;
/* Create the 'Builtin\Users' key */
@@ -289,28 +342,48 @@
&dwDisposition))
{
ERR("Failed to create 'Builtin\\Users' key! (Error %lu)\n",
GetLastError());
- RegCloseKey(hBuiltinKey);
- RegCloseKey(hDomainsKey);
- return FALSE;
+ bResult = FALSE;
+ goto done;
+ }
+
+ if (!CreateNamesKey(hUsersKey))
+ {
+ ERR("Failed to create 'Builtin\\Users\\Names' key! (Error
%lu)\n", GetLastError());
+ bResult = FALSE;
+ goto done;
}
/* Create builtin users */
if (!CreateBuiltinUsers(hUsersKey))
{
ERR("Failed to create builtin users!\n");
+ bResult = FALSE;
+ goto done;
+ }
+
+done:
+ if (hAliasesKey)
+ RegCloseKey(hAliasesKey);
+
+ if (hGroupsKey)
+ RegCloseKey(hGroupsKey);
+
+ if (hUsersKey)
RegCloseKey(hUsersKey);
+
+ if (hAccountKey)
+ RegCloseKey(hAccountKey);
+
+ if (hBuiltinKey)
RegCloseKey(hBuiltinKey);
+
+ if (hDomainsKey)
RegCloseKey(hDomainsKey);
- return FALSE;
- }
-
- RegCloseKey(hUsersKey);
-
- RegCloseKey(hBuiltinKey);
-
- RegCloseKey(hDomainsKey);
+
+ if (hSamKey)
+ RegCloseKey(hSamKey);
TRACE("SampInitializeSAM() done\n");
- return TRUE;
-}
+ return bResult;
+}