mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 18:46:29 +00:00
- Return a default security descriptor when someone wants to retrieve the key security.
- Disable debug messages. svn path=/trunk/; revision=10839
This commit is contained in:
parent
f34a907c7a
commit
00443884ee
2 changed files with 158 additions and 21 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: registry.c,v 1.125 2004/08/15 16:39:00 chorns Exp $
|
/* $Id: registry.c,v 1.126 2004/09/13 11:46:07 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -245,6 +245,9 @@ CmInitializeRegistry(VOID)
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
UNICODE_STRING KeyName;
|
UNICODE_STRING KeyName;
|
||||||
PKEY_OBJECT RootKey;
|
PKEY_OBJECT RootKey;
|
||||||
|
#if 0
|
||||||
|
PSECURITY_CELL RootSecurityCell;
|
||||||
|
#endif
|
||||||
HANDLE RootKeyHandle;
|
HANDLE RootKeyHandle;
|
||||||
HANDLE KeyHandle;
|
HANDLE KeyHandle;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -313,6 +316,18 @@ CmInitializeRegistry(VOID)
|
||||||
Status = RtlCreateUnicodeString(&RootKey->Name, L"Registry");
|
Status = RtlCreateUnicodeString(&RootKey->Name, L"Registry");
|
||||||
assert(NT_SUCCESS(Status));
|
assert(NT_SUCCESS(Status));
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
Status = CmiAllocateCell(CmiVolatileHive,
|
||||||
|
0x10, //LONG CellSize,
|
||||||
|
(PVOID *)&RootSecurityCell,
|
||||||
|
&RootKey->KeyCell->SecurityKeyOffset);
|
||||||
|
assert(NT_SUCCESS(Status));
|
||||||
|
|
||||||
|
/* Copy the security descriptor */
|
||||||
|
|
||||||
|
CmiVolatileHive->RootSecurityCell = RootSecurityCell;
|
||||||
|
#endif
|
||||||
|
|
||||||
KeInitializeSpinLock(&CmiKeyListLock);
|
KeInitializeSpinLock(&CmiKeyListLock);
|
||||||
|
|
||||||
/* Create '\Registry\Machine' key. */
|
/* Create '\Registry\Machine' key. */
|
||||||
|
@ -355,7 +370,7 @@ VOID INIT_FUNCTION
|
||||||
CmInit2(PCHAR CommandLine)
|
CmInit2(PCHAR CommandLine)
|
||||||
{
|
{
|
||||||
ULONG PiceStart = 4;
|
ULONG PiceStart = 4;
|
||||||
BOOL MiniNT = FALSE;
|
BOOLEAN MiniNT = FALSE;
|
||||||
PWCHAR SystemBootDevice;
|
PWCHAR SystemBootDevice;
|
||||||
PWCHAR SystemStartOptions;
|
PWCHAR SystemStartOptions;
|
||||||
ULONG Position;
|
ULONG Position;
|
||||||
|
@ -370,9 +385,13 @@ CmInit2(PCHAR CommandLine)
|
||||||
* Parse the system boot device.
|
* Parse the system boot device.
|
||||||
*/
|
*/
|
||||||
Position = 0;
|
Position = 0;
|
||||||
SystemBootDevice = ExAllocatePool(PagedPool, (strlen(CommandLine) + 1) * sizeof(WCHAR));
|
SystemBootDevice = ExAllocatePool(PagedPool,
|
||||||
|
(strlen(CommandLine) + 1) * sizeof(WCHAR));
|
||||||
if (SystemBootDevice == NULL)
|
if (SystemBootDevice == NULL)
|
||||||
|
{
|
||||||
KEBUGCHECK(CONFIG_INITIALIZATION_FAILED);
|
KEBUGCHECK(CONFIG_INITIALIZATION_FAILED);
|
||||||
|
}
|
||||||
|
|
||||||
while (*CommandLine != 0 && *CommandLine != ' ')
|
while (*CommandLine != 0 && *CommandLine != ' ')
|
||||||
SystemBootDevice[Position++] = *(CommandLine++);
|
SystemBootDevice[Position++] = *(CommandLine++);
|
||||||
SystemBootDevice[Position++] = 0;
|
SystemBootDevice[Position++] = 0;
|
||||||
|
@ -380,15 +399,16 @@ CmInit2(PCHAR CommandLine)
|
||||||
/*
|
/*
|
||||||
* Write the system boot device to registry.
|
* Write the system boot device to registry.
|
||||||
*/
|
*/
|
||||||
Status = RtlWriteRegistryValue(
|
Status = RtlWriteRegistryValue(RTL_REGISTRY_ABSOLUTE,
|
||||||
RTL_REGISTRY_ABSOLUTE,
|
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control",
|
||||||
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control",
|
L"SystemBootDevice",
|
||||||
L"SystemBootDevice",
|
REG_SZ,
|
||||||
REG_SZ,
|
SystemBootDevice,
|
||||||
SystemBootDevice,
|
Position * sizeof(WCHAR));
|
||||||
Position * sizeof(WCHAR));
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
KEBUGCHECK(CONFIG_INITIALIZATION_FAILED);
|
KEBUGCHECK(CONFIG_INITIALIZATION_FAILED);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse the system start options.
|
* Parse the system start options.
|
||||||
|
@ -419,15 +439,16 @@ CmInit2(PCHAR CommandLine)
|
||||||
/*
|
/*
|
||||||
* Write the system start options to registry.
|
* Write the system start options to registry.
|
||||||
*/
|
*/
|
||||||
Status = RtlWriteRegistryValue(
|
Status = RtlWriteRegistryValue(RTL_REGISTRY_ABSOLUTE,
|
||||||
RTL_REGISTRY_ABSOLUTE,
|
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control",
|
||||||
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control",
|
L"SystemStartOptions",
|
||||||
L"SystemStartOptions",
|
REG_SZ,
|
||||||
REG_SZ,
|
SystemStartOptions,
|
||||||
SystemStartOptions,
|
Position * sizeof(WCHAR));
|
||||||
Position * sizeof(WCHAR));
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
KEBUGCHECK(CONFIG_INITIALIZATION_FAILED);
|
KEBUGCHECK(CONFIG_INITIALIZATION_FAILED);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a CurrentControlSet\Control\MiniNT key that is used
|
* Create a CurrentControlSet\Control\MiniNT key that is used
|
||||||
|
@ -1032,7 +1053,7 @@ CmShutdownRegistry(VOID)
|
||||||
PREGISTRY_HIVE Hive;
|
PREGISTRY_HIVE Hive;
|
||||||
PLIST_ENTRY Entry;
|
PLIST_ENTRY Entry;
|
||||||
|
|
||||||
DPRINT1("CmShutdownRegistry() called\n");
|
DPRINT("CmShutdownRegistry() called\n");
|
||||||
|
|
||||||
/* Stop automatic hive synchronization */
|
/* Stop automatic hive synchronization */
|
||||||
CmiHiveSyncEnabled = FALSE;
|
CmiHiveSyncEnabled = FALSE;
|
||||||
|
@ -1073,7 +1094,7 @@ CmShutdownRegistry(VOID)
|
||||||
ExReleaseResourceLite(&CmiHiveListLock);
|
ExReleaseResourceLite(&CmiHiveListLock);
|
||||||
KeLeaveCriticalRegion();
|
KeLeaveCriticalRegion();
|
||||||
|
|
||||||
DPRINT1("CmShutdownRegistry() done\n");
|
DPRINT("CmShutdownRegistry() done\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -312,6 +312,118 @@ CmiObjectDelete(PVOID DeletedObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static NTSTATUS
|
||||||
|
CmiQuerySecurityDescriptor(PKEY_OBJECT KeyObject,
|
||||||
|
SECURITY_INFORMATION SecurityInformation,
|
||||||
|
PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
|
PULONG BufferLength)
|
||||||
|
{
|
||||||
|
ULONG_PTR Current;
|
||||||
|
ULONG SidSize;
|
||||||
|
ULONG SdSize;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DPRINT("CmiQuerySecurityDescriptor() called\n");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FIXME:
|
||||||
|
* This is a big hack!!
|
||||||
|
* We need to retrieve the security descriptor from the keys security cell!
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (SecurityInformation == 0)
|
||||||
|
{
|
||||||
|
return STATUS_ACCESS_DENIED;
|
||||||
|
}
|
||||||
|
|
||||||
|
SidSize = RtlLengthSid(SeWorldSid);
|
||||||
|
SdSize = sizeof(SECURITY_DESCRIPTOR) + (2 * SidSize);
|
||||||
|
|
||||||
|
if (*BufferLength < SdSize)
|
||||||
|
{
|
||||||
|
*BufferLength = SdSize;
|
||||||
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*BufferLength = SdSize;
|
||||||
|
|
||||||
|
Status = RtlCreateSecurityDescriptor(SecurityDescriptor,
|
||||||
|
SECURITY_DESCRIPTOR_REVISION);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
SecurityDescriptor->Control |= SE_SELF_RELATIVE;
|
||||||
|
Current = (ULONG_PTR)SecurityDescriptor + sizeof(SECURITY_DESCRIPTOR);
|
||||||
|
|
||||||
|
if (SecurityInformation & OWNER_SECURITY_INFORMATION)
|
||||||
|
{
|
||||||
|
RtlCopyMemory((PVOID)Current,
|
||||||
|
SeWorldSid,
|
||||||
|
SidSize);
|
||||||
|
SecurityDescriptor->Owner = (PSID)((ULONG_PTR)Current - (ULONG_PTR)SecurityDescriptor);
|
||||||
|
Current += SidSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SecurityInformation & GROUP_SECURITY_INFORMATION)
|
||||||
|
{
|
||||||
|
RtlCopyMemory((PVOID)Current,
|
||||||
|
SeWorldSid,
|
||||||
|
SidSize);
|
||||||
|
SecurityDescriptor->Group = (PSID)((ULONG_PTR)Current - (ULONG_PTR)SecurityDescriptor);
|
||||||
|
Current += SidSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SecurityInformation & DACL_SECURITY_INFORMATION)
|
||||||
|
{
|
||||||
|
SecurityDescriptor->Control |= SE_DACL_PRESENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SecurityInformation & SACL_SECURITY_INFORMATION)
|
||||||
|
{
|
||||||
|
SecurityDescriptor->Control |= SE_SACL_PRESENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static NTSTATUS
|
||||||
|
CmiAssignSecurityDescriptor(PKEY_OBJECT KeyObject,
|
||||||
|
PSECURITY_DESCRIPTOR SecurityDescriptor)
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
PREGISTRY_HIVE Hive;
|
||||||
|
|
||||||
|
DPRINT1("CmiAssignSecurityDescriptor() callled\n");
|
||||||
|
|
||||||
|
DPRINT1("KeyObject %p\n", KeyObject);
|
||||||
|
DPRINT1("KeyObject->RegistryHive %p\n", KeyObject->RegistryHive);
|
||||||
|
|
||||||
|
Hive = KeyObject->RegistryHive;
|
||||||
|
if (Hive == NULL)
|
||||||
|
{
|
||||||
|
DPRINT1("Create new root security cell\n");
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Hive->RootSecurityCell == NULL)
|
||||||
|
{
|
||||||
|
DPRINT1("Create new root security cell\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DPRINT1("Search for security cell\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
CmiObjectSecurity(PVOID ObjectBody,
|
CmiObjectSecurity(PVOID ObjectBody,
|
||||||
SECURITY_OPERATION_CODE OperationCode,
|
SECURITY_OPERATION_CODE OperationCode,
|
||||||
|
@ -329,7 +441,10 @@ CmiObjectSecurity(PVOID ObjectBody,
|
||||||
|
|
||||||
case QuerySecurityDescriptor:
|
case QuerySecurityDescriptor:
|
||||||
DPRINT("Query security descriptor\n");
|
DPRINT("Query security descriptor\n");
|
||||||
return STATUS_UNSUCCESSFUL;
|
return CmiQuerySecurityDescriptor((PKEY_OBJECT)ObjectBody,
|
||||||
|
SecurityInformation,
|
||||||
|
SecurityDescriptor,
|
||||||
|
BufferLength);
|
||||||
|
|
||||||
case DeleteSecurityDescriptor:
|
case DeleteSecurityDescriptor:
|
||||||
DPRINT("Delete security descriptor\n");
|
DPRINT("Delete security descriptor\n");
|
||||||
|
@ -337,7 +452,8 @@ CmiObjectSecurity(PVOID ObjectBody,
|
||||||
|
|
||||||
case AssignSecurityDescriptor:
|
case AssignSecurityDescriptor:
|
||||||
DPRINT("Assign security descriptor\n");
|
DPRINT("Assign security descriptor\n");
|
||||||
return STATUS_SUCCESS;
|
return CmiAssignSecurityDescriptor((PKEY_OBJECT)ObjectBody,
|
||||||
|
SecurityDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
return STATUS_UNSUCCESSFUL;
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
|
Loading…
Reference in a new issue