mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
- fixed a possible endless loop in GetSecurityInfo()
- implemented the SE_REGISTRY_KEY, SE_FILE_OBJECT, SE_KERNEL_OBJECT, SE_SERVICE and SE_WINDOW_OBJECT object types for SetSecurityInfo() svn path=/trunk/; revision=20976
This commit is contained in:
parent
5302f6c169
commit
5d1053c60e
1 changed files with 97 additions and 20 deletions
|
@ -52,13 +52,15 @@ AccRewriteGetHandleRights(HANDLE handle,
|
|||
ULONG SDSize = 0;
|
||||
NTSTATUS Status;
|
||||
DWORD LastErr;
|
||||
DWORD Ret = ERROR_SUCCESS;
|
||||
DWORD Ret;
|
||||
|
||||
/* save the last error code */
|
||||
LastErr = GetLastError();
|
||||
|
||||
do
|
||||
{
|
||||
Ret = ERROR_SUCCESS;
|
||||
|
||||
/* allocate a buffer large enough to hold the
|
||||
security descriptor we need to return */
|
||||
SDSize += 0x100;
|
||||
|
@ -89,7 +91,7 @@ AccRewriteGetHandleRights(HANDLE handle,
|
|||
{
|
||||
case SE_REGISTRY_KEY:
|
||||
{
|
||||
Ret = RegGetKeySecurity((HKEY)handle,
|
||||
Ret = (DWORD)RegGetKeySecurity((HKEY)handle,
|
||||
SecurityInfo,
|
||||
pSD,
|
||||
&SDSize);
|
||||
|
@ -97,6 +99,7 @@ AccRewriteGetHandleRights(HANDLE handle,
|
|||
}
|
||||
|
||||
case SE_FILE_OBJECT:
|
||||
/* FIXME - handle console handles? */
|
||||
case SE_KERNEL_OBJECT:
|
||||
{
|
||||
Status = NtQuerySecurityObject(handle,
|
||||
|
@ -104,27 +107,36 @@ AccRewriteGetHandleRights(HANDLE handle,
|
|||
pSD,
|
||||
SDSize,
|
||||
&SDSize);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
Ret = RtlNtStatusToDosError(Status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SE_SERVICE:
|
||||
{
|
||||
Ret = QueryServiceObjectSecurity((SC_HANDLE)handle,
|
||||
if (!QueryServiceObjectSecurity((SC_HANDLE)handle,
|
||||
SecurityInfo,
|
||||
pSD,
|
||||
SDSize,
|
||||
&SDSize);
|
||||
&SDSize))
|
||||
{
|
||||
Ret = GetLastError();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SE_WINDOW_OBJECT:
|
||||
{
|
||||
Ret = GetUserObjectSecurity(handle,
|
||||
if (!GetUserObjectSecurity(handle,
|
||||
&SecurityInfo,
|
||||
pSD,
|
||||
SDSize,
|
||||
&SDSize);
|
||||
&SDSize))
|
||||
{
|
||||
Ret = GetLastError();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -220,9 +232,74 @@ AccRewriteSetHandleRights(HANDLE handle,
|
|||
SE_OBJECT_TYPE ObjectType,
|
||||
SECURITY_INFORMATION SecurityInfo,
|
||||
PSECURITY_DESCRIPTOR pSecurityDescriptor)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
DWORD LastErr;
|
||||
DWORD Ret = ERROR_SUCCESS;
|
||||
|
||||
/* save the last error code */
|
||||
LastErr = GetLastError();
|
||||
|
||||
/* set the security according to the object type */
|
||||
switch (ObjectType)
|
||||
{
|
||||
case SE_REGISTRY_KEY:
|
||||
{
|
||||
Ret = (DWORD)RegSetKeySecurity((HKEY)handle,
|
||||
SecurityInfo,
|
||||
pSecurityDescriptor);
|
||||
break;
|
||||
}
|
||||
|
||||
case SE_FILE_OBJECT:
|
||||
/* FIXME - handle console handles? */
|
||||
case SE_KERNEL_OBJECT:
|
||||
{
|
||||
Status = NtSetSecurityObject(handle,
|
||||
SecurityInfo,
|
||||
pSecurityDescriptor);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
Ret = RtlNtStatusToDosError(Status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SE_SERVICE:
|
||||
{
|
||||
if (!SetServiceObjectSecurity((SC_HANDLE)handle,
|
||||
SecurityInfo,
|
||||
pSecurityDescriptor))
|
||||
{
|
||||
Ret = GetLastError();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SE_WINDOW_OBJECT:
|
||||
{
|
||||
if (!SetUserObjectSecurity(handle,
|
||||
&SecurityInfo,
|
||||
pSecurityDescriptor))
|
||||
{
|
||||
Ret = GetLastError();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return ERROR_CALL_NOT_IMPLEMENTED;
|
||||
Ret = ERROR_CALL_NOT_IMPLEMENTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* restore the last error code */
|
||||
SetLastError(LastErr);
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -362,9 +439,9 @@ DllMain(IN HINSTANCE hinstDLL,
|
|||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
hDllInstance = hinstDLL;
|
||||
DisableThreadLibraryCalls(hinstDLL);
|
||||
break;
|
||||
case DLL_THREAD_ATTACH:
|
||||
case DLL_THREAD_DETACH:
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue