Author: ekohl
Date: Sun Sep 30 23:50:30 2012
New Revision: 57449
URL:
http://svn.reactos.org/svn/reactos?rev=57449&view=rev
Log:
[LSASRV]
Get rid of the ugly container object code. Let LsapCreateDbObject and LsapOpenDbObject
handle container objects instead.
Modified:
trunk/reactos/dll/win32/lsasrv/database.c
trunk/reactos/dll/win32/lsasrv/lsarpc.c
trunk/reactos/dll/win32/lsasrv/lsasrv.h
Modified: trunk/reactos/dll/win32/lsasrv/database.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/database.…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/database.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/database.c [iso-8859-1] Sun Sep 30 23:50:30 2012
@@ -283,6 +283,7 @@
/* Open the 'Policy' object */
Status = LsapOpenDbObject(NULL,
+ NULL,
L"Policy",
LsaDbPolicyObject,
0,
@@ -427,6 +428,7 @@
NTSTATUS
LsapCreateDbObject(IN PLSA_DB_OBJECT ParentObject,
+ IN LPWSTR ContainerName,
IN LPWSTR ObjectName,
IN LSA_DB_OBJECT_TYPE ObjectType,
IN ACCESS_MASK DesiredAccess,
@@ -436,7 +438,8 @@
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName;
HANDLE ParentKeyHandle;
- HANDLE ObjectKeyHandle;
+ HANDLE ContainerKeyHandle = NULL;
+ HANDLE ObjectKeyHandle = NULL;
NTSTATUS Status;
if (DbObject == NULL)
@@ -447,25 +450,73 @@
else
ParentKeyHandle = ParentObject->KeyHandle;
- RtlInitUnicodeString(&KeyName,
- ObjectName);
-
- InitializeObjectAttributes(&ObjectAttributes,
- &KeyName,
- OBJ_CASE_INSENSITIVE,
- ParentKeyHandle,
- NULL);
-
- Status = NtCreateKey(&ObjectKeyHandle,
- KEY_ALL_ACCESS,
- &ObjectAttributes,
- 0,
- NULL,
- 0,
- NULL);
- if (!NT_SUCCESS(Status))
- {
- return Status;
+ if (ContainerName != NULL)
+ {
+ /* Open the container key */
+ RtlInitUnicodeString(&KeyName,
+ ContainerName);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE,
+ ParentKeyHandle,
+ NULL);
+
+ Status = NtOpenKey(&ContainerKeyHandle,
+ KEY_ALL_ACCESS,
+ &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ {
+ return Status;
+ }
+
+ /* Open the object key */
+ RtlInitUnicodeString(&KeyName,
+ ObjectName);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE,
+ ContainerKeyHandle,
+ NULL);
+
+ Status = NtCreateKey(&ObjectKeyHandle,
+ KEY_ALL_ACCESS,
+ &ObjectAttributes,
+ 0,
+ NULL,
+ 0,
+ NULL);
+
+ NtClose(ContainerKeyHandle);
+
+ if (!NT_SUCCESS(Status))
+ {
+ return Status;
+ }
+ }
+ else
+ {
+ RtlInitUnicodeString(&KeyName,
+ ObjectName);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE,
+ ParentKeyHandle,
+ NULL);
+
+ Status = NtCreateKey(&ObjectKeyHandle,
+ KEY_ALL_ACCESS,
+ &ObjectAttributes,
+ 0,
+ NULL,
+ 0,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ return Status;
+ }
}
NewObject = RtlAllocateHeap(RtlGetProcessHeap(),
@@ -495,6 +546,7 @@
NTSTATUS
LsapOpenDbObject(IN PLSA_DB_OBJECT ParentObject,
+ IN LPWSTR ContainerName,
IN LPWSTR ObjectName,
IN LSA_DB_OBJECT_TYPE ObjectType,
IN ACCESS_MASK DesiredAccess,
@@ -504,7 +556,8 @@
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName;
HANDLE ParentKeyHandle;
- HANDLE ObjectKeyHandle;
+ HANDLE ContainerKeyHandle = NULL;
+ HANDLE ObjectKeyHandle = NULL;
NTSTATUS Status;
if (DbObject == NULL)
@@ -515,26 +568,71 @@
else
ParentKeyHandle = ParentObject->KeyHandle;
- RtlInitUnicodeString(&KeyName,
- ObjectName);
-
- InitializeObjectAttributes(&ObjectAttributes,
- &KeyName,
- OBJ_CASE_INSENSITIVE,
- ParentKeyHandle,
- NULL);
-
- Status = NtOpenKey(&ObjectKeyHandle,
- KEY_ALL_ACCESS,
- &ObjectAttributes);
- if (!NT_SUCCESS(Status))
- {
- return Status;
+ if (ContainerName != NULL)
+ {
+ /* Open the container key */
+ RtlInitUnicodeString(&KeyName,
+ ContainerName);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE,
+ ParentKeyHandle,
+ NULL);
+
+ Status = NtOpenKey(&ContainerKeyHandle,
+ KEY_ALL_ACCESS,
+ &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ {
+ return Status;
+ }
+
+ /* Open the object key */
+ RtlInitUnicodeString(&KeyName,
+ ObjectName);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE,
+ ContainerKeyHandle,
+ NULL);
+
+ Status = NtOpenKey(&ObjectKeyHandle,
+ KEY_ALL_ACCESS,
+ &ObjectAttributes);
+
+ NtClose(ContainerKeyHandle);
+
+ if (!NT_SUCCESS(Status))
+ {
+ return Status;
+ }
+ }
+ else
+ {
+ /* Open the object key */
+ RtlInitUnicodeString(&KeyName,
+ ObjectName);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE,
+ ParentKeyHandle,
+ NULL);
+
+ Status = NtOpenKey(&ObjectKeyHandle,
+ KEY_ALL_ACCESS,
+ &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ {
+ return Status;
+ }
}
NewObject = RtlAllocateHeap(RtlGetProcessHeap(),
- 0,
- sizeof(LSA_DB_OBJECT));
+ 0,
+ sizeof(LSA_DB_OBJECT));
if (NewObject == NULL)
{
NtClose(ObjectKeyHandle);
Modified: trunk/reactos/dll/win32/lsasrv/lsarpc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsarpc.c?…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/lsarpc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/lsarpc.c [iso-8859-1] Sun Sep 30 23:50:30 2012
@@ -183,6 +183,7 @@
RtlEnterCriticalSection(&PolicyHandleTableLock);
Status = LsapOpenDbObject(NULL,
+ NULL,
L"Policy",
LsaDbPolicyObject,
DesiredAccess,
@@ -435,7 +436,6 @@
LSAPR_HANDLE *AccountHandle)
{
PLSA_DB_OBJECT PolicyObject;
- PLSA_DB_OBJECT AccountsObject = NULL;
PLSA_DB_OBJECT AccountObject = NULL;
LPWSTR SidString = NULL;
NTSTATUS Status = STATUS_SUCCESS;
@@ -455,18 +455,6 @@
return Status;
}
- /* Open the Accounts object */
- Status = LsapOpenDbObject(PolicyObject,
- L"Accounts",
- LsaDbContainerObject,
- 0,
- &AccountsObject);
- if (!NT_SUCCESS(Status))
- {
- ERR("LsapCreateDbObject (Accounts) failed (Status 0x%08lx)\n",
Status);
- goto done;
- }
-
/* Create SID string */
if (!ConvertSidToStringSid((PSID)AccountSid,
&SidString))
@@ -477,14 +465,15 @@
}
/* Create the Account object */
- Status = LsapCreateDbObject(AccountsObject,
+ Status = LsapCreateDbObject(PolicyObject,
+ L"Accounts",
SidString,
LsaDbAccountObject,
DesiredAccess,
&AccountObject);
if (!NT_SUCCESS(Status))
{
- ERR("LsapCreateDbObject (Account) failed (Status 0x%08lx)\n", Status);
+ ERR("LsapCreateDbObject failed (Status 0x%08lx)\n", Status);
goto done;
}
@@ -507,9 +496,6 @@
{
*AccountHandle = (LSAPR_HANDLE)AccountObject;
}
-
- if (AccountsObject != NULL)
- LsapCloseDbObject(AccountsObject);
return STATUS_SUCCESS;
}
@@ -750,7 +736,6 @@
LSAPR_HANDLE *SecretHandle)
{
PLSA_DB_OBJECT PolicyObject;
- PLSA_DB_OBJECT SecretsObject = NULL;
PLSA_DB_OBJECT SecretObject = NULL;
LARGE_INTEGER Time;
NTSTATUS Status = STATUS_SUCCESS;
@@ -766,18 +751,6 @@
return Status;
}
- /* Open the Secrets object */
- Status = LsapOpenDbObject(PolicyObject,
- L"Secrets",
- LsaDbContainerObject,
- 0,
- &SecretsObject);
- if (!NT_SUCCESS(Status))
- {
- ERR("LsapCreateDbObject (Secrets) failed (Status 0x%08lx)\n", Status);
- goto done;
- }
-
/* Get the current time */
Status = NtQuerySystemTime(&Time);
if (!NT_SUCCESS(Status))
@@ -787,14 +760,15 @@
}
/* Create the Secret object */
- Status = LsapCreateDbObject(SecretsObject,
+ Status = LsapCreateDbObject(PolicyObject,
+ L"Secrets",
SecretName->Buffer,
LsaDbSecretObject,
DesiredAccess,
&SecretObject);
if (!NT_SUCCESS(Status))
{
- ERR("LsapCreateDbObject (Secret) failed (Status 0x%08lx)\n", Status);
+ ERR("LsapCreateDbObject failed (Status 0x%08lx)\n", Status);
goto done;
}
@@ -826,9 +800,6 @@
*SecretHandle = (LSAPR_HANDLE)SecretObject;
}
- if (SecretsObject != NULL)
- LsapCloseDbObject(SecretsObject);
-
return STATUS_SUCCESS;
}
@@ -841,7 +812,6 @@
LSAPR_HANDLE *AccountHandle)
{
PLSA_DB_OBJECT PolicyObject;
- PLSA_DB_OBJECT AccountsObject = NULL;
PLSA_DB_OBJECT AccountObject = NULL;
LPWSTR SidString = NULL;
NTSTATUS Status = STATUS_SUCCESS;
@@ -861,18 +831,6 @@
return Status;
}
- /* Open the Accounts object */
- Status = LsapOpenDbObject(PolicyObject,
- L"Accounts",
- LsaDbContainerObject,
- 0,
- &AccountsObject);
- if (!NT_SUCCESS(Status))
- {
- ERR("LsapOpenDbObject (Accounts) failed (Status 0x%08lx)\n", Status);
- goto done;
- }
-
/* Create SID string */
if (!ConvertSidToStringSid((PSID)AccountSid,
&SidString))
@@ -883,14 +841,15 @@
}
/* Create the Account object */
- Status = LsapOpenDbObject(AccountsObject,
+ Status = LsapOpenDbObject(PolicyObject,
+ L"Accounts",
SidString,
LsaDbAccountObject,
DesiredAccess,
&AccountObject);
if (!NT_SUCCESS(Status))
{
- ERR("LsapOpenDbObject (Account) failed (Status 0x%08lx)\n", Status);
+ ERR("LsapOpenDbObject failed (Status 0x%08lx)\n", Status);
goto done;
}
@@ -913,9 +872,6 @@
{
*AccountHandle = (LSAPR_HANDLE)AccountObject;
}
-
- if (AccountsObject != NULL)
- LsapCloseDbObject(AccountsObject);
return Status;
}
@@ -1257,7 +1213,6 @@
LSAPR_HANDLE *SecretHandle)
{
PLSA_DB_OBJECT PolicyObject;
- PLSA_DB_OBJECT SecretsObject = NULL;
PLSA_DB_OBJECT SecretObject = NULL;
NTSTATUS Status = STATUS_SUCCESS;
@@ -1272,27 +1227,16 @@
return Status;
}
- /* Open the Secrets object */
+ /* Create the secret object */
Status = LsapOpenDbObject(PolicyObject,
L"Secrets",
- LsaDbContainerObject,
- 0,
- &SecretsObject);
- if (!NT_SUCCESS(Status))
- {
- ERR("LsapCreateDbObject (Secrets) failed (Status 0x%08lx)\n", Status);
- goto done;
- }
-
- /* Create the secret object */
- Status = LsapOpenDbObject(SecretsObject,
SecretName->Buffer,
LsaDbSecretObject,
DesiredAccess,
&SecretObject);
if (!NT_SUCCESS(Status))
{
- ERR("LsapOpenDbObject (Secret) failed (Status 0x%08lx)\n", Status);
+ ERR("LsapOpenDbObject failed (Status 0x%08lx)\n", Status);
goto done;
}
@@ -1306,9 +1250,6 @@
{
*SecretHandle = (LSAPR_HANDLE)SecretObject;
}
-
- if (SecretsObject != NULL)
- LsapCloseDbObject(SecretsObject);
return STATUS_SUCCESS;
}
Modified: trunk/reactos/dll/win32/lsasrv/lsasrv.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsasrv.h?…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] Sun Sep 30 23:50:30 2012
@@ -33,7 +33,6 @@
typedef enum _LSA_DB_OBJECT_TYPE
{
LsaDbIgnoreObject,
- LsaDbContainerObject,
LsaDbPolicyObject,
LsaDbAccountObject,
LsaDbDomainObject,
@@ -71,6 +70,7 @@
NTSTATUS
LsapCreateDbObject(IN PLSA_DB_OBJECT ParentObject,
+ IN LPWSTR ContainerName,
IN LPWSTR ObjectName,
IN LSA_DB_OBJECT_TYPE HandleType,
IN ACCESS_MASK DesiredAccess,
@@ -78,6 +78,7 @@
NTSTATUS
LsapOpenDbObject(IN PLSA_DB_OBJECT ParentObject,
+ IN LPWSTR ContainerName,
IN LPWSTR ObjectName,
IN LSA_DB_OBJECT_TYPE ObjectType,
IN ACCESS_MASK DesiredAccess,