mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
- Implemented RtlAdjustPrivileges().
- Implemented NtAdjustPrivilegesToken() partially. - Fixed declaration of LUID. svn path=/trunk/; revision=4804
This commit is contained in:
parent
5f47cf8a2a
commit
ba5a26559b
10 changed files with 359 additions and 192 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: rtl.h,v 1.38 2003/04/02 00:05:59 hyperion Exp $
|
/* $Id: rtl.h,v 1.39 2003/05/31 11:07:00 ekohl Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -518,6 +518,12 @@ RtlIsValidIndexHandle (
|
||||||
IN ULONG Index
|
IN ULONG Index
|
||||||
);
|
);
|
||||||
|
|
||||||
|
NTSTATUS STDCALL
|
||||||
|
RtlAdjustPrivilege(IN ULONG Privilege,
|
||||||
|
IN BOOLEAN Enable,
|
||||||
|
IN BOOLEAN CurrentThread,
|
||||||
|
OUT PBOOLEAN Enabled);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
RtlImpersonateSelf (
|
RtlImpersonateSelf (
|
||||||
|
|
|
@ -239,7 +239,11 @@ typedef enum _ACL_INFORMATION_CLASS
|
||||||
|
|
||||||
typedef USHORT SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
|
typedef USHORT SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
|
||||||
|
|
||||||
typedef LARGE_INTEGER LUID, *PLUID;
|
typedef struct _LUID
|
||||||
|
{
|
||||||
|
ULONG LowPart;
|
||||||
|
LONG HighPart;
|
||||||
|
} LUID, *PLUID;
|
||||||
|
|
||||||
typedef struct _SECURITY_DESCRIPTOR
|
typedef struct _SECURITY_DESCRIPTOR
|
||||||
{
|
{
|
||||||
|
@ -255,7 +259,7 @@ typedef struct _SECURITY_DESCRIPTOR
|
||||||
typedef struct _LUID_AND_ATTRIBUTES
|
typedef struct _LUID_AND_ATTRIBUTES
|
||||||
{
|
{
|
||||||
LUID Luid;
|
LUID Luid;
|
||||||
DWORD Attributes;
|
ULONG Attributes;
|
||||||
} LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
|
} LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
|
||||||
|
|
||||||
typedef struct _TOKEN_SOURCE
|
typedef struct _TOKEN_SOURCE
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
; $Id: ntdll.def,v 1.99 2003/05/15 11:02:03 ekohl Exp $
|
; $Id: ntdll.def,v 1.100 2003/05/31 11:08:08 ekohl Exp $
|
||||||
;
|
;
|
||||||
; ReactOS Operating System
|
; ReactOS Operating System
|
||||||
;
|
;
|
||||||
|
@ -286,7 +286,7 @@ RtlAddAtomToAtomTable@12
|
||||||
;RtlAddAttributeActionToRXact
|
;RtlAddAttributeActionToRXact
|
||||||
RtlAddAuditAccessAce@24
|
RtlAddAuditAccessAce@24
|
||||||
;RtlAddCompoundAce
|
;RtlAddCompoundAce
|
||||||
;RtlAdjustPrivilege
|
RtlAdjustPrivilege@16
|
||||||
RtlAllocateAndInitializeSid@44
|
RtlAllocateAndInitializeSid@44
|
||||||
RtlAllocateHandle@8
|
RtlAllocateHandle@8
|
||||||
RtlAllocateHeap@12
|
RtlAllocateHeap@12
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
; $Id: ntdll.edf,v 1.88 2003/05/15 11:02:03 ekohl Exp $
|
; $Id: ntdll.edf,v 1.89 2003/05/31 11:08:08 ekohl Exp $
|
||||||
;
|
;
|
||||||
; ReactOS Operating System
|
; ReactOS Operating System
|
||||||
;
|
;
|
||||||
|
@ -286,7 +286,7 @@ RtlAddAtomToAtomTable=RtlAddAtomToAtomTable@12
|
||||||
;RtlAddAttributeActionToRXact
|
;RtlAddAttributeActionToRXact
|
||||||
RtlAddAuditAccessAce=RtlAddAuditAccessAce@24
|
RtlAddAuditAccessAce=RtlAddAuditAccessAce@24
|
||||||
;RtlAddCompoundAce
|
;RtlAddCompoundAce
|
||||||
;RtlAdjustPrivilege
|
RtlAdjustPrivilege=RtlAdjustPrivilege@16
|
||||||
RtlAllocateAndInitializeSid=RtlAllocateAndInitializeSid@44
|
RtlAllocateAndInitializeSid=RtlAllocateAndInitializeSid@44
|
||||||
RtlAllocateHandle=RtlAllocateHandle@8
|
RtlAllocateHandle=RtlAllocateHandle@8
|
||||||
RtlAllocateHeap=RtlAllocateHeap@12
|
RtlAllocateHeap=RtlAllocateHeap@12
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: luid.c,v 1.5 2002/09/08 10:23:05 chorns Exp $
|
/* $Id: luid.c,v 1.6 2003/05/31 11:08:50 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -13,13 +13,15 @@
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
RtlCopyLuid(PLUID LuidDest,
|
RtlCopyLuid(PLUID LuidDest,
|
||||||
PLUID LuidSrc)
|
PLUID LuidSrc)
|
||||||
{
|
{
|
||||||
LuidDest->QuadPart = LuidSrc->QuadPart;
|
LuidDest->LowPart = LuidSrc->LowPart;
|
||||||
|
LuidDest->HighPart = LuidSrc->HighPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,7 +45,8 @@ BOOLEAN STDCALL
|
||||||
RtlEqualLuid(PLUID Luid1,
|
RtlEqualLuid(PLUID Luid1,
|
||||||
PLUID Luid2)
|
PLUID Luid2)
|
||||||
{
|
{
|
||||||
return((Luid1->QuadPart == Luid2->QuadPart) ? TRUE : FALSE);
|
return (Luid1->LowPart == Luid2->LowPart &&
|
||||||
|
Luid1->HighPart == Luid2->HighPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: security.c,v 1.7 2002/09/08 10:23:06 chorns Exp $
|
/* $Id: security.c,v 1.8 2003/05/31 11:08:50 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -12,6 +12,11 @@
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <ntdll/rtl.h>
|
#include <ntdll/rtl.h>
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <ntdll/ntdll.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
|
RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
|
||||||
|
@ -62,4 +67,76 @@ RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS STDCALL
|
||||||
|
RtlAdjustPrivilege(IN ULONG Privilege,
|
||||||
|
IN BOOLEAN Enable,
|
||||||
|
IN BOOLEAN CurrentThread,
|
||||||
|
OUT PBOOLEAN Enabled)
|
||||||
|
{
|
||||||
|
TOKEN_PRIVILEGES NewState;
|
||||||
|
TOKEN_PRIVILEGES OldState;
|
||||||
|
ULONG ReturnLength;
|
||||||
|
HANDLE TokenHandle;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DPRINT1("RtlAdjustPrivilege() called\n");
|
||||||
|
|
||||||
|
if (CurrentThread)
|
||||||
|
{
|
||||||
|
Status = NtOpenThreadToken (NtCurrentThread (),
|
||||||
|
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
|
||||||
|
FALSE,
|
||||||
|
&TokenHandle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = NtOpenProcessToken (NtCurrentProcess (),
|
||||||
|
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
|
||||||
|
&TokenHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!NT_SUCCESS (Status))
|
||||||
|
{
|
||||||
|
DPRINT1("Retrieving token handle failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
NewState.PrivilegeCount = 1;
|
||||||
|
NewState.Privileges[0].Luid.LowPart = Privilege;
|
||||||
|
NewState.Privileges[0].Luid.HighPart = 0;
|
||||||
|
NewState.Privileges[0].Attributes = (Enable) ? SE_PRIVILEGE_ENABLED : 0;
|
||||||
|
|
||||||
|
Status = NtAdjustPrivilegesToken (TokenHandle,
|
||||||
|
FALSE,
|
||||||
|
&NewState,
|
||||||
|
sizeof(TOKEN_PRIVILEGES),
|
||||||
|
&OldState,
|
||||||
|
&ReturnLength);
|
||||||
|
NtClose (TokenHandle);
|
||||||
|
if (Status == STATUS_NOT_ALL_ASSIGNED)
|
||||||
|
{
|
||||||
|
DPRINT1("Failed to assign all privileges\n");
|
||||||
|
return STATUS_PRIVILEGE_NOT_HELD;
|
||||||
|
}
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("NtAdjustPrivilegesToken() failed (Status %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OldState.PrivilegeCount == 0)
|
||||||
|
{
|
||||||
|
*Enabled = Enable;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*Enabled = (OldState.Privileges[0].Attributes & SE_PRIVILEGE_ENABLED);
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINT1("RtlAdjustPrivilege() done\n");
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -120,7 +120,8 @@ NTSTATUS SeExchangePrimaryToken(struct _EPROCESS* Process,
|
||||||
PACCESS_TOKEN NewToken,
|
PACCESS_TOKEN NewToken,
|
||||||
PACCESS_TOKEN* OldTokenP);
|
PACCESS_TOKEN* OldTokenP);
|
||||||
|
|
||||||
NTSTATUS SeCaptureLuidAndAttributesArray(PLUID_AND_ATTRIBUTES Src,
|
NTSTATUS
|
||||||
|
SeCaptureLuidAndAttributesArray(PLUID_AND_ATTRIBUTES Src,
|
||||||
ULONG PrivilegeCount,
|
ULONG PrivilegeCount,
|
||||||
KPROCESSOR_MODE PreviousMode,
|
KPROCESSOR_MODE PreviousMode,
|
||||||
PLUID_AND_ATTRIBUTES AllocatedMem,
|
PLUID_AND_ATTRIBUTES AllocatedMem,
|
||||||
|
@ -130,6 +131,11 @@ NTSTATUS SeCaptureLuidAndAttributesArray(PLUID_AND_ATTRIBUTES Src,
|
||||||
PLUID_AND_ATTRIBUTES* Dest,
|
PLUID_AND_ATTRIBUTES* Dest,
|
||||||
PULONG Length);
|
PULONG Length);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
SeReleaseLuidAndAttributesArray(PLUID_AND_ATTRIBUTES Privilege,
|
||||||
|
KPROCESSOR_MODE PreviousMode,
|
||||||
|
ULONG a);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_SE_H */
|
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_SE_H */
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: luid.c,v 1.6 2002/09/08 10:23:43 chorns Exp $
|
/* $Id: luid.c,v 1.7 2003/05/31 11:10:30 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -19,7 +19,9 @@
|
||||||
|
|
||||||
static KSPIN_LOCK LuidLock;
|
static KSPIN_LOCK LuidLock;
|
||||||
static LARGE_INTEGER LuidIncrement;
|
static LARGE_INTEGER LuidIncrement;
|
||||||
static LUID Luid;
|
static LARGE_INTEGER LuidValue;
|
||||||
|
|
||||||
|
#define SYSTEM_LUID 0x3E7;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
@ -27,7 +29,7 @@ VOID
|
||||||
SepInitLuid(VOID)
|
SepInitLuid(VOID)
|
||||||
{
|
{
|
||||||
KeInitializeSpinLock(&LuidLock);
|
KeInitializeSpinLock(&LuidLock);
|
||||||
Luid.QuadPart = 999; /* SYSTEM_LUID */
|
LuidValue.QuadPart = SYSTEM_LUID;
|
||||||
LuidIncrement.QuadPart = 1;
|
LuidIncrement.QuadPart = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,17 +37,19 @@ SepInitLuid(VOID)
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
NtAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId)
|
NtAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId)
|
||||||
{
|
{
|
||||||
KIRQL oldIrql;
|
LARGE_INTEGER ReturnedLuid;
|
||||||
LUID ReturnedLuid;
|
KIRQL Irql;
|
||||||
|
|
||||||
KeAcquireSpinLock(&LuidLock,
|
KeAcquireSpinLock(&LuidLock,
|
||||||
&oldIrql);
|
&Irql);
|
||||||
ReturnedLuid = Luid;
|
ReturnedLuid = LuidValue;
|
||||||
Luid = RtlLargeIntegerAdd(Luid,
|
LuidValue = RtlLargeIntegerAdd(LuidValue,
|
||||||
LuidIncrement);
|
LuidIncrement);
|
||||||
KeReleaseSpinLock(&LuidLock,
|
KeReleaseSpinLock(&LuidLock,
|
||||||
oldIrql);
|
Irql);
|
||||||
*LocallyUniqueId = ReturnedLuid;
|
|
||||||
|
LocallyUniqueId->LowPart = ReturnedLuid.u.LowPart;
|
||||||
|
LocallyUniqueId->HighPart = ReturnedLuid.u.HighPart;
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -55,7 +59,8 @@ VOID STDCALL
|
||||||
RtlCopyLuid(IN PLUID LuidDest,
|
RtlCopyLuid(IN PLUID LuidDest,
|
||||||
IN PLUID LuidSrc)
|
IN PLUID LuidSrc)
|
||||||
{
|
{
|
||||||
LuidDest->QuadPart = LuidSrc->QuadPart;
|
LuidDest->LowPart = LuidSrc->LowPart;
|
||||||
|
LuidDest->HighPart = LuidSrc->HighPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,7 +68,8 @@ BOOLEAN STDCALL
|
||||||
RtlEqualLuid(IN PLUID Luid1,
|
RtlEqualLuid(IN PLUID Luid1,
|
||||||
IN PLUID Luid2)
|
IN PLUID Luid2)
|
||||||
{
|
{
|
||||||
return((Luid1->QuadPart == Luid2->QuadPart) ? TRUE : FALSE);
|
return (Luid1->LowPart == Luid2->LowPart &&
|
||||||
|
Luid1->HighPart == Luid2->HighPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: priv.c,v 1.5 2002/09/08 10:23:43 chorns Exp $
|
/* $Id: priv.c,v 1.6 2003/05/31 11:10:30 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -49,46 +49,70 @@ LUID SeRemoteShutdownPrivilege;
|
||||||
VOID
|
VOID
|
||||||
SepInitPrivileges (VOID)
|
SepInitPrivileges (VOID)
|
||||||
{
|
{
|
||||||
SeCreateTokenPrivilege.QuadPart = SE_CREATE_TOKEN_PRIVILEGE;
|
SeCreateTokenPrivilege.LowPart = SE_CREATE_TOKEN_PRIVILEGE;
|
||||||
SeAssignPrimaryTokenPrivilege.QuadPart = SE_ASSIGNPRIMARYTOKEN_PRIVILEGE;
|
SeCreateTokenPrivilege.HighPart = 0;
|
||||||
SeLockMemoryPrivilege.QuadPart = SE_LOCK_MEMORY_PRIVILEGE;
|
SeAssignPrimaryTokenPrivilege.LowPart = SE_ASSIGNPRIMARYTOKEN_PRIVILEGE;
|
||||||
SeIncreaseQuotaPrivilege.QuadPart = SE_INCREASE_QUOTA_PRIVILEGE;
|
SeAssignPrimaryTokenPrivilege.HighPart = 0;
|
||||||
SeUnsolicitedInputPrivilege.QuadPart = SE_UNSOLICITED_INPUT_PRIVILEGE;
|
SeLockMemoryPrivilege.LowPart = SE_LOCK_MEMORY_PRIVILEGE;
|
||||||
SeTcbPrivilege.QuadPart = SE_TCB_PRIVILEGE;
|
SeLockMemoryPrivilege.HighPart = 0;
|
||||||
SeSecurityPrivilege.QuadPart = SE_SECURITY_PRIVILEGE;
|
SeIncreaseQuotaPrivilege.LowPart = SE_INCREASE_QUOTA_PRIVILEGE;
|
||||||
SeTakeOwnershipPrivilege.QuadPart = SE_TAKE_OWNERSHIP_PRIVILEGE;
|
SeIncreaseQuotaPrivilege.HighPart = 0;
|
||||||
SeLoadDriverPrivilege.QuadPart = SE_LOAD_DRIVER_PRIVILEGE;
|
SeUnsolicitedInputPrivilege.LowPart = SE_UNSOLICITED_INPUT_PRIVILEGE;
|
||||||
SeSystemProfilePrivilege.QuadPart = SE_SYSTEM_PROFILE_PRIVILEGE;
|
SeUnsolicitedInputPrivilege.HighPart = 0;
|
||||||
SeSystemtimePrivilege.QuadPart = SE_SYSTEMTIME_PRIVILEGE;
|
SeTcbPrivilege.LowPart = SE_TCB_PRIVILEGE;
|
||||||
SeProfileSingleProcessPrivilege.QuadPart = SE_PROF_SINGLE_PROCESS_PRIVILEGE;
|
SeTcbPrivilege.HighPart = 0;
|
||||||
SeIncreaseBasePriorityPrivilege.QuadPart = SE_INC_BASE_PRIORITY_PRIVILEGE;
|
SeSecurityPrivilege.LowPart = SE_SECURITY_PRIVILEGE;
|
||||||
SeCreatePagefilePrivilege.QuadPart = SE_CREATE_PAGEFILE_PRIVILEGE;
|
SeSecurityPrivilege.HighPart = 0;
|
||||||
SeCreatePermanentPrivilege.QuadPart = SE_CREATE_PERMANENT_PRIVILEGE;
|
SeTakeOwnershipPrivilege.LowPart = SE_TAKE_OWNERSHIP_PRIVILEGE;
|
||||||
SeBackupPrivilege.QuadPart = SE_BACKUP_PRIVILEGE;
|
SeTakeOwnershipPrivilege.HighPart = 0;
|
||||||
SeRestorePrivilege.QuadPart = SE_RESTORE_PRIVILEGE;
|
SeLoadDriverPrivilege.LowPart = SE_LOAD_DRIVER_PRIVILEGE;
|
||||||
SeShutdownPrivilege.QuadPart = SE_SHUTDOWN_PRIVILEGE;
|
SeLoadDriverPrivilege.HighPart = 0;
|
||||||
SeDebugPrivilege.QuadPart = SE_DEBUG_PRIVILEGE;
|
SeSystemProfilePrivilege.LowPart = SE_SYSTEM_PROFILE_PRIVILEGE;
|
||||||
SeAuditPrivilege.QuadPart = SE_AUDIT_PRIVILEGE;
|
SeSystemProfilePrivilege.HighPart = 0;
|
||||||
SeSystemEnvironmentPrivilege.QuadPart = SE_SYSTEM_ENVIRONMENT_PRIVILEGE;
|
SeSystemtimePrivilege.LowPart = SE_SYSTEMTIME_PRIVILEGE;
|
||||||
SeChangeNotifyPrivilege.QuadPart = SE_CHANGE_NOTIFY_PRIVILEGE;
|
SeSystemtimePrivilege.HighPart = 0;
|
||||||
SeRemoteShutdownPrivilege.QuadPart = SE_REMOTE_SHUTDOWN_PRIVILEGE;
|
SeProfileSingleProcessPrivilege.LowPart = SE_PROF_SINGLE_PROCESS_PRIVILEGE;
|
||||||
|
SeProfileSingleProcessPrivilege.HighPart = 0;
|
||||||
|
SeIncreaseBasePriorityPrivilege.LowPart = SE_INC_BASE_PRIORITY_PRIVILEGE;
|
||||||
|
SeIncreaseBasePriorityPrivilege.HighPart = 0;
|
||||||
|
SeCreatePagefilePrivilege.LowPart = SE_CREATE_PAGEFILE_PRIVILEGE;
|
||||||
|
SeCreatePagefilePrivilege.HighPart = 0;
|
||||||
|
SeCreatePermanentPrivilege.LowPart = SE_CREATE_PERMANENT_PRIVILEGE;
|
||||||
|
SeCreatePermanentPrivilege.HighPart = 0;
|
||||||
|
SeBackupPrivilege.LowPart = SE_BACKUP_PRIVILEGE;
|
||||||
|
SeBackupPrivilege.HighPart = 0;
|
||||||
|
SeRestorePrivilege.LowPart = SE_RESTORE_PRIVILEGE;
|
||||||
|
SeRestorePrivilege.HighPart = 0;
|
||||||
|
SeShutdownPrivilege.LowPart = SE_SHUTDOWN_PRIVILEGE;
|
||||||
|
SeShutdownPrivilege.HighPart = 0;
|
||||||
|
SeDebugPrivilege.LowPart = SE_DEBUG_PRIVILEGE;
|
||||||
|
SeDebugPrivilege.HighPart = 0;
|
||||||
|
SeAuditPrivilege.LowPart = SE_AUDIT_PRIVILEGE;
|
||||||
|
SeAuditPrivilege.HighPart = 0;
|
||||||
|
SeSystemEnvironmentPrivilege.LowPart = SE_SYSTEM_ENVIRONMENT_PRIVILEGE;
|
||||||
|
SeSystemEnvironmentPrivilege.HighPart = 0;
|
||||||
|
SeChangeNotifyPrivilege.LowPart = SE_CHANGE_NOTIFY_PRIVILEGE;
|
||||||
|
SeChangeNotifyPrivilege.HighPart = 0;
|
||||||
|
SeRemoteShutdownPrivilege.LowPart = SE_REMOTE_SHUTDOWN_PRIVILEGE;
|
||||||
|
SeRemoteShutdownPrivilege.HighPart = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOLEAN SepPrivilegeCheck(PACCESS_TOKEN Token,
|
BOOLEAN
|
||||||
|
SepPrivilegeCheck (PACCESS_TOKEN Token,
|
||||||
PLUID_AND_ATTRIBUTES Privileges,
|
PLUID_AND_ATTRIBUTES Privileges,
|
||||||
ULONG PrivilegeCount,
|
ULONG PrivilegeCount,
|
||||||
ULONG PrivilegeControl,
|
ULONG PrivilegeControl,
|
||||||
KPROCESSOR_MODE PreviousMode)
|
KPROCESSOR_MODE PreviousMode)
|
||||||
{
|
{
|
||||||
ULONG i;
|
|
||||||
PLUID_AND_ATTRIBUTES Current;
|
PLUID_AND_ATTRIBUTES Current;
|
||||||
|
ULONG i;
|
||||||
ULONG j;
|
ULONG j;
|
||||||
ULONG k;
|
ULONG k;
|
||||||
|
|
||||||
if (PreviousMode == KernelMode)
|
if (PreviousMode == KernelMode)
|
||||||
{
|
{
|
||||||
return(TRUE);
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
|
@ -102,39 +126,37 @@ BOOLEAN SepPrivilegeCheck(PACCESS_TOKEN Token,
|
||||||
for (i = 0; i < Token->PrivilegeCount; i++)
|
for (i = 0; i < Token->PrivilegeCount; i++)
|
||||||
{
|
{
|
||||||
if (!(Current[i].Attributes & SE_PRIVILEGE_ENABLED) &&
|
if (!(Current[i].Attributes & SE_PRIVILEGE_ENABLED) &&
|
||||||
Privileges[i].Luid.u.LowPart ==
|
Privileges[i].Luid.LowPart == Current[i].Luid.LowPart &&
|
||||||
Current[i].Luid.u.LowPart &&
|
Privileges[i].Luid.HighPart == Current[i].Luid.HighPart)
|
||||||
Privileges[i].Luid.u.HighPart ==
|
|
||||||
Current[i].Luid.u.HighPart)
|
|
||||||
{
|
{
|
||||||
Privileges[i].Attributes =
|
Privileges[i].Attributes |= SE_PRIVILEGE_USED_FOR_ACCESS;
|
||||||
Privileges[i].Attributes |
|
|
||||||
SE_PRIVILEGE_USED_FOR_ACCESS;
|
|
||||||
j++;
|
j++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
k--;
|
k--;
|
||||||
} while (k > 0);
|
}
|
||||||
|
while (k > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((PrivilegeControl & PRIVILEGE_SET_ALL_NECESSARY) &&
|
if ((PrivilegeControl & PRIVILEGE_SET_ALL_NECESSARY) &&
|
||||||
PrivilegeCount == j)
|
PrivilegeCount == j)
|
||||||
{
|
{
|
||||||
return(TRUE);
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j > 0 &&
|
if (j > 0 &&
|
||||||
!(PrivilegeControl & PRIVILEGE_SET_ALL_NECESSARY))
|
!(PrivilegeControl & PRIVILEGE_SET_ALL_NECESSARY))
|
||||||
{
|
{
|
||||||
return(TRUE);
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(FALSE);
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS SeCaptureLuidAndAttributesArray(PLUID_AND_ATTRIBUTES Src,
|
NTSTATUS
|
||||||
|
SeCaptureLuidAndAttributesArray (PLUID_AND_ATTRIBUTES Src,
|
||||||
ULONG PrivilegeCount,
|
ULONG PrivilegeCount,
|
||||||
KPROCESSOR_MODE PreviousMode,
|
KPROCESSOR_MODE PreviousMode,
|
||||||
PLUID_AND_ATTRIBUTES AllocatedMem,
|
PLUID_AND_ATTRIBUTES AllocatedMem,
|
||||||
|
@ -181,6 +203,7 @@ NTSTATUS SeCaptureLuidAndAttributesArray(PLUID_AND_ATTRIBUTES Src,
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
SeReleaseLuidAndAttributesArray(PLUID_AND_ATTRIBUTES Privilege,
|
SeReleaseLuidAndAttributesArray(PLUID_AND_ATTRIBUTES Privilege,
|
||||||
KPROCESSOR_MODE PreviousMode,
|
KPROCESSOR_MODE PreviousMode,
|
||||||
|
@ -189,6 +212,7 @@ SeReleaseLuidAndAttributesArray(PLUID_AND_ATTRIBUTES Privilege,
|
||||||
ExFreePool(Privilege);
|
ExFreePool(Privilege);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
NtPrivilegeCheck(IN HANDLE ClientToken,
|
NtPrivilegeCheck(IN HANDLE ClientToken,
|
||||||
IN PPRIVILEGE_SET RequiredPrivileges,
|
IN PPRIVILEGE_SET RequiredPrivileges,
|
||||||
|
@ -246,6 +270,7 @@ NtPrivilegeCheck(IN HANDLE ClientToken,
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOLEAN STDCALL
|
BOOLEAN STDCALL
|
||||||
SePrivilegeCheck(PPRIVILEGE_SET Privileges,
|
SePrivilegeCheck(PPRIVILEGE_SET Privileges,
|
||||||
PSECURITY_SUBJECT_CONTEXT SubjectContext,
|
PSECURITY_SUBJECT_CONTEXT SubjectContext,
|
||||||
|
@ -273,6 +298,7 @@ SePrivilegeCheck(PPRIVILEGE_SET Privileges,
|
||||||
PreviousMode));
|
PreviousMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOLEAN STDCALL
|
BOOLEAN STDCALL
|
||||||
SeSinglePrivilegeCheck(IN LUID PrivilegeValue,
|
SeSinglePrivilegeCheck(IN LUID PrivilegeValue,
|
||||||
IN KPROCESSOR_MODE PreviousMode)
|
IN KPROCESSOR_MODE PreviousMode)
|
||||||
|
@ -304,3 +330,4 @@ SeSinglePrivilegeCheck(IN LUID PrivilegeValue,
|
||||||
return(r);
|
return(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: token.c,v 1.22 2002/10/25 21:48:00 chorns Exp $
|
/* $Id: token.c,v 1.23 2003/05/31 11:10:30 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -172,10 +172,14 @@ SepDuplicateToken(PACCESS_TOKEN Token,
|
||||||
AccessToken->TokenInUse = 0;
|
AccessToken->TokenInUse = 0;
|
||||||
AccessToken->TokenType = TokenType;
|
AccessToken->TokenType = TokenType;
|
||||||
AccessToken->ImpersonationLevel = Level;
|
AccessToken->ImpersonationLevel = Level;
|
||||||
AccessToken->AuthenticationId.QuadPart = SYSTEM_LUID;
|
AccessToken->AuthenticationId.LowPart = SYSTEM_LUID;
|
||||||
|
AccessToken->AuthenticationId.HighPart = 0;
|
||||||
|
|
||||||
AccessToken->TokenSource.SourceIdentifier.QuadPart = Token->TokenSource.SourceIdentifier.QuadPart;
|
AccessToken->TokenSource.SourceIdentifier.LowPart = Token->TokenSource.SourceIdentifier.LowPart;
|
||||||
memcpy(AccessToken->TokenSource.SourceName, Token->TokenSource.SourceName, sizeof(Token->TokenSource.SourceName));
|
AccessToken->TokenSource.SourceIdentifier.HighPart = Token->TokenSource.SourceIdentifier.HighPart;
|
||||||
|
memcpy(AccessToken->TokenSource.SourceName,
|
||||||
|
Token->TokenSource.SourceName,
|
||||||
|
sizeof(Token->TokenSource.SourceName));
|
||||||
AccessToken->ExpirationTime.QuadPart = Token->ExpirationTime.QuadPart;
|
AccessToken->ExpirationTime.QuadPart = Token->ExpirationTime.QuadPart;
|
||||||
AccessToken->UserAndGroupCount = Token->UserAndGroupCount;
|
AccessToken->UserAndGroupCount = Token->UserAndGroupCount;
|
||||||
AccessToken->DefaultOwnerIndex = Token->DefaultOwnerIndex;
|
AccessToken->DefaultOwnerIndex = Token->DefaultOwnerIndex;
|
||||||
|
@ -820,27 +824,28 @@ NtAdjustGroupsToken(IN HANDLE TokenHandle,
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
NTSTATUS SepAdjustPrivileges(PACCESS_TOKEN Token, // 0x8
|
NTSTATUS
|
||||||
ULONG a, // 0xC
|
SepAdjustPrivileges(PACCESS_TOKEN Token,
|
||||||
KPROCESSOR_MODE PreviousMode, // 0x10
|
ULONG a,
|
||||||
ULONG PrivilegeCount, // 0x14
|
KPROCESSOR_MODE PreviousMode,
|
||||||
PLUID_AND_ATTRIBUTES Privileges, // 0x18
|
ULONG PrivilegeCount,
|
||||||
PTOKEN_PRIVILEGES* PreviousState, // 0x1C
|
PLUID_AND_ATTRIBUTES Privileges,
|
||||||
PULONG b, // 0x20
|
PTOKEN_PRIVILEGES* PreviousState,
|
||||||
PULONG c, // 0x24
|
PULONG b,
|
||||||
PULONG d) // 0x28
|
PULONG c,
|
||||||
|
PULONG d)
|
||||||
{
|
{
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
|
||||||
*c = 0;
|
*c = 0;
|
||||||
|
|
||||||
if (Token->PrivilegeCount > 0)
|
if (Token->PrivilegeCount > 0)
|
||||||
{
|
{
|
||||||
for (i = 0; i < Token->PrivilegeCount; i++)
|
for (i = 0; i < Token->PrivilegeCount; i++)
|
||||||
{
|
{
|
||||||
if (PreviousMode != 0)
|
if (PreviousMode != KernelMode)
|
||||||
{
|
{
|
||||||
if (!(Token->Privileges[i]->Attributes &
|
if (Token->Privileges[i]->Attributes & SE_PRIVILEGE_ENABLED == 0)
|
||||||
SE_PRIVILEGE_ENABLED))
|
|
||||||
{
|
{
|
||||||
if (a != 0)
|
if (a != 0)
|
||||||
{
|
{
|
||||||
|
@ -850,15 +855,14 @@ NTSTATUS SepAdjustPrivileges(PACCESS_TOKEN Token, // 0x8
|
||||||
&Token->Privileges[i],
|
&Token->Privileges[i],
|
||||||
sizeof(LUID_AND_ATTRIBUTES));
|
sizeof(LUID_AND_ATTRIBUTES));
|
||||||
}
|
}
|
||||||
Token->Privileges[i].Attributes =
|
Token->Privileges[i].Attributes &= (~SE_PRIVILEGE_ENABLED);
|
||||||
Token->Privileges[i].Attributes &
|
|
||||||
(~SE_PRIVILEGE_ENABLED);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (PreviousMode != 0)
|
|
||||||
|
if (PreviousMode != KernelMode)
|
||||||
{
|
{
|
||||||
Token->TokenFlags = Token->TokenFlags & (~1);
|
Token->TokenFlags = Token->TokenFlags & (~1);
|
||||||
}
|
}
|
||||||
|
@ -866,7 +870,6 @@ NTSTATUS SepAdjustPrivileges(PACCESS_TOKEN Token, // 0x8
|
||||||
{
|
{
|
||||||
if (PrivilegeCount <= ?)
|
if (PrivilegeCount <= ?)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
|
@ -882,37 +885,69 @@ NtAdjustPrivilegesToken(IN HANDLE TokenHandle,
|
||||||
OUT PTOKEN_PRIVILEGES PreviousState,
|
OUT PTOKEN_PRIVILEGES PreviousState,
|
||||||
OUT PULONG ReturnLength)
|
OUT PULONG ReturnLength)
|
||||||
{
|
{
|
||||||
#if 0
|
PLUID_AND_ATTRIBUTES Privileges;
|
||||||
|
KPROCESSOR_MODE PreviousMode;
|
||||||
ULONG PrivilegeCount;
|
ULONG PrivilegeCount;
|
||||||
|
PACCESS_TOKEN Token;
|
||||||
ULONG Length;
|
ULONG Length;
|
||||||
PSID_AND_ATTRIBUTES Privileges;
|
#if 0
|
||||||
ULONG a;
|
ULONG a;
|
||||||
ULONG b;
|
ULONG b;
|
||||||
ULONG c;
|
ULONG c;
|
||||||
|
#endif
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DPRINT1("NtAdjustPrivilegesToken() called\n");
|
||||||
|
|
||||||
PrivilegeCount = NewState->PrivilegeCount;
|
PrivilegeCount = NewState->PrivilegeCount;
|
||||||
|
PreviousMode = KeGetPreviousMode();
|
||||||
SeCaptureLuidAndAttributesArray(NewState->Privileges,
|
SeCaptureLuidAndAttributesArray(NewState->Privileges,
|
||||||
&PrivilegeCount,
|
PrivilegeCount,
|
||||||
KeGetPreviousMode(),
|
PreviousMode,
|
||||||
NULL,
|
NULL,
|
||||||
0,
|
0,
|
||||||
NonPagedPool,
|
NonPagedPool,
|
||||||
1,
|
1,
|
||||||
&Privileges.
|
&Privileges,
|
||||||
&Length);
|
&Length);
|
||||||
|
|
||||||
|
Status = ObReferenceObjectByHandle(TokenHandle,
|
||||||
|
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
|
||||||
|
SepTokenObjectType,
|
||||||
|
PreviousMode,
|
||||||
|
(PVOID*)&Token,
|
||||||
|
NULL);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("Failed to reference token (Status %lx)\n", Status);
|
||||||
|
SeReleaseLuidAndAttributesArray(Privileges,
|
||||||
|
PreviousMode,
|
||||||
|
0);
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
SepAdjustPrivileges(Token,
|
SepAdjustPrivileges(Token,
|
||||||
0,
|
0,
|
||||||
KeGetPreviousMode(),
|
PreviousMode,
|
||||||
PrivilegeCount,
|
PrivilegeCount,
|
||||||
Privileges,
|
Privileges,
|
||||||
PreviousState,
|
PreviousState,
|
||||||
&a,
|
&a,
|
||||||
&b,
|
&b,
|
||||||
&c);
|
&c);
|
||||||
#else
|
|
||||||
UNIMPLEMENTED;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
ObDereferenceObject(Token);
|
||||||
|
|
||||||
|
SeReleaseLuidAndAttributesArray(Privileges,
|
||||||
|
PreviousMode,
|
||||||
|
0);
|
||||||
|
|
||||||
|
DPRINT1("NtAdjustPrivilegesToken() done\n");
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -955,11 +990,13 @@ SepCreateSystemProcessToken(struct _EPROCESS* Process)
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
AccessToken->AuthenticationId.QuadPart = SYSTEM_LUID;
|
AccessToken->AuthenticationId.LowPart = SYSTEM_LUID;
|
||||||
|
AccessToken->AuthenticationId.HighPart = 0;
|
||||||
|
|
||||||
AccessToken->TokenType = TokenPrimary;
|
AccessToken->TokenType = TokenPrimary;
|
||||||
AccessToken->ImpersonationLevel = SecurityDelegation;
|
AccessToken->ImpersonationLevel = SecurityDelegation;
|
||||||
AccessToken->TokenSource.SourceIdentifier.QuadPart = 0;
|
AccessToken->TokenSource.SourceIdentifier.LowPart = 0;
|
||||||
|
AccessToken->TokenSource.SourceIdentifier.HighPart = 0;
|
||||||
memcpy(AccessToken->TokenSource.SourceName, "SeMgr\0\0\0", 8);
|
memcpy(AccessToken->TokenSource.SourceName, "SeMgr\0\0\0", 8);
|
||||||
AccessToken->ExpirationTime.QuadPart = -1;
|
AccessToken->ExpirationTime.QuadPart = -1;
|
||||||
AccessToken->UserAndGroupCount = 4;
|
AccessToken->UserAndGroupCount = 4;
|
||||||
|
@ -1106,6 +1143,7 @@ SepCreateSystemProcessToken(struct _EPROCESS* Process)
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
NtCreateToken(OUT PHANDLE UnsafeTokenHandle,
|
NtCreateToken(OUT PHANDLE UnsafeTokenHandle,
|
||||||
IN ACCESS_MASK DesiredAccess,
|
IN ACCESS_MASK DesiredAccess,
|
||||||
|
|
Loading…
Reference in a new issue