4ceaa19c4afa3bbcad61ea7c4dda20d84ff93821
[reactos.git] / reactos / ntoskrnl / se / semgr.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/se/semgr.c
5 * PURPOSE: Security manager
6 *
7 * PROGRAMMERS: No programmer listed.
8 */
9
10 /* INCLUDES *******************************************************************/
11
12 #include <ntoskrnl.h>
13 #define NDEBUG
14 #include <debug.h>
15
16 /* GLOBALS ********************************************************************/
17
18 PSE_EXPORTS SeExports = NULL;
19 SE_EXPORTS SepExports;
20
21 extern ULONG ExpInitializationPhase;
22 extern ERESOURCE SepSubjectContextLock;
23
24 /* PRIVATE FUNCTIONS **********************************************************/
25
26 static BOOLEAN INIT_FUNCTION
27 SepInitExports(VOID)
28 {
29 SepExports.SeCreateTokenPrivilege = SeCreateTokenPrivilege;
30 SepExports.SeAssignPrimaryTokenPrivilege = SeAssignPrimaryTokenPrivilege;
31 SepExports.SeLockMemoryPrivilege = SeLockMemoryPrivilege;
32 SepExports.SeIncreaseQuotaPrivilege = SeIncreaseQuotaPrivilege;
33 SepExports.SeUnsolicitedInputPrivilege = SeUnsolicitedInputPrivilege;
34 SepExports.SeTcbPrivilege = SeTcbPrivilege;
35 SepExports.SeSecurityPrivilege = SeSecurityPrivilege;
36 SepExports.SeTakeOwnershipPrivilege = SeTakeOwnershipPrivilege;
37 SepExports.SeLoadDriverPrivilege = SeLoadDriverPrivilege;
38 SepExports.SeCreatePagefilePrivilege = SeCreatePagefilePrivilege;
39 SepExports.SeIncreaseBasePriorityPrivilege = SeIncreaseBasePriorityPrivilege;
40 SepExports.SeSystemProfilePrivilege = SeSystemProfilePrivilege;
41 SepExports.SeSystemtimePrivilege = SeSystemtimePrivilege;
42 SepExports.SeProfileSingleProcessPrivilege = SeProfileSingleProcessPrivilege;
43 SepExports.SeCreatePermanentPrivilege = SeCreatePermanentPrivilege;
44 SepExports.SeBackupPrivilege = SeBackupPrivilege;
45 SepExports.SeRestorePrivilege = SeRestorePrivilege;
46 SepExports.SeShutdownPrivilege = SeShutdownPrivilege;
47 SepExports.SeDebugPrivilege = SeDebugPrivilege;
48 SepExports.SeAuditPrivilege = SeAuditPrivilege;
49 SepExports.SeSystemEnvironmentPrivilege = SeSystemEnvironmentPrivilege;
50 SepExports.SeChangeNotifyPrivilege = SeChangeNotifyPrivilege;
51 SepExports.SeRemoteShutdownPrivilege = SeRemoteShutdownPrivilege;
52
53 SepExports.SeNullSid = SeNullSid;
54 SepExports.SeWorldSid = SeWorldSid;
55 SepExports.SeLocalSid = SeLocalSid;
56 SepExports.SeCreatorOwnerSid = SeCreatorOwnerSid;
57 SepExports.SeCreatorGroupSid = SeCreatorGroupSid;
58 SepExports.SeNtAuthoritySid = SeNtAuthoritySid;
59 SepExports.SeDialupSid = SeDialupSid;
60 SepExports.SeNetworkSid = SeNetworkSid;
61 SepExports.SeBatchSid = SeBatchSid;
62 SepExports.SeInteractiveSid = SeInteractiveSid;
63 SepExports.SeLocalSystemSid = SeLocalSystemSid;
64 SepExports.SeAliasAdminsSid = SeAliasAdminsSid;
65 SepExports.SeAliasUsersSid = SeAliasUsersSid;
66 SepExports.SeAliasGuestsSid = SeAliasGuestsSid;
67 SepExports.SeAliasPowerUsersSid = SeAliasPowerUsersSid;
68 SepExports.SeAliasAccountOpsSid = SeAliasAccountOpsSid;
69 SepExports.SeAliasSystemOpsSid = SeAliasSystemOpsSid;
70 SepExports.SeAliasPrintOpsSid = SeAliasPrintOpsSid;
71 SepExports.SeAliasBackupOpsSid = SeAliasBackupOpsSid;
72 SepExports.SeAuthenticatedUsersSid = SeAuthenticatedUsersSid;
73 SepExports.SeRestrictedSid = SeRestrictedSid;
74 SepExports.SeAnonymousLogonSid = SeAnonymousLogonSid;
75
76 SepExports.SeUndockPrivilege = SeUndockPrivilege;
77 SepExports.SeSyncAgentPrivilege = SeSyncAgentPrivilege;
78 SepExports.SeEnableDelegationPrivilege = SeEnableDelegationPrivilege;
79
80 SeExports = &SepExports;
81 return TRUE;
82 }
83
84
85 BOOLEAN
86 NTAPI
87 SepInitializationPhase0(VOID)
88 {
89 PAGED_CODE();
90
91 ExpInitLuid();
92 if (!SepInitSecurityIDs()) return FALSE;
93 if (!SepInitDACLs()) return FALSE;
94 if (!SepInitSDs()) return FALSE;
95 SepInitPrivileges();
96 if (!SepInitExports()) return FALSE;
97
98 /* Initialize the subject context lock */
99 ExInitializeResource(&SepSubjectContextLock);
100
101 /* Initialize token objects */
102 SepInitializeTokenImplementation();
103
104 /* Clear impersonation info for the idle thread */
105 PsGetCurrentThread()->ImpersonationInfo = NULL;
106 PspClearCrossThreadFlag(PsGetCurrentThread(),
107 CT_ACTIVE_IMPERSONATION_INFO_BIT);
108
109 /* Initialize the boot token */
110 ObInitializeFastReference(&PsGetCurrentProcess()->Token, NULL);
111 ObInitializeFastReference(&PsGetCurrentProcess()->Token,
112 SepCreateSystemProcessToken());
113 return TRUE;
114 }
115
116 BOOLEAN
117 NTAPI
118 SepInitializationPhase1(VOID)
119 {
120 NTSTATUS Status;
121 PAGED_CODE();
122
123 /* Insert the system token into the tree */
124 Status = ObInsertObject((PVOID)(PsGetCurrentProcess()->Token.Value &
125 ~MAX_FAST_REFS),
126 NULL,
127 0,
128 0,
129 NULL,
130 NULL);
131 ASSERT(NT_SUCCESS(Status));
132
133 /* FIXME: TODO \\ Security directory */
134 return TRUE;
135 }
136
137 BOOLEAN
138 NTAPI
139 SeInitSystem(VOID)
140 {
141 /* Check the initialization phase */
142 switch (ExpInitializationPhase)
143 {
144 case 0:
145
146 /* Do Phase 0 */
147 return SepInitializationPhase0();
148
149 case 1:
150
151 /* Do Phase 1 */
152 return SepInitializationPhase1();
153
154 default:
155
156 /* Don't know any other phase! Bugcheck! */
157 KeBugCheckEx(UNEXPECTED_INITIALIZATION_CALL,
158 0,
159 ExpInitializationPhase,
160 0,
161 0);
162 return FALSE;
163 }
164 }
165
166 BOOLEAN
167 NTAPI
168 SeInitSRM(VOID)
169 {
170 OBJECT_ATTRIBUTES ObjectAttributes;
171 UNICODE_STRING Name;
172 HANDLE DirectoryHandle;
173 HANDLE EventHandle;
174 NTSTATUS Status;
175
176 /* Create '\Security' directory */
177 RtlInitUnicodeString(&Name,
178 L"\\Security");
179 InitializeObjectAttributes(&ObjectAttributes,
180 &Name,
181 OBJ_PERMANENT,
182 0,
183 NULL);
184 Status = ZwCreateDirectoryObject(&DirectoryHandle,
185 DIRECTORY_ALL_ACCESS,
186 &ObjectAttributes);
187 if (!NT_SUCCESS(Status))
188 {
189 DPRINT1("Failed to create 'Security' directory!\n");
190 return FALSE;
191 }
192
193 /* Create 'LSA_AUTHENTICATION_INITALIZED' event */
194 RtlInitUnicodeString(&Name,
195 L"\\LSA_AUTHENTICATION_INITALIZED");
196 InitializeObjectAttributes(&ObjectAttributes,
197 &Name,
198 OBJ_PERMANENT,
199 DirectoryHandle,
200 SePublicDefaultSd);
201 Status = ZwCreateEvent(&EventHandle,
202 EVENT_ALL_ACCESS,
203 &ObjectAttributes,
204 SynchronizationEvent,
205 FALSE);
206 if (!NT_SUCCESS(Status))
207 {
208 DPRINT1("Failed to create 'LSA_AUTHENTICATION_INITALIZED' event!\n");
209 NtClose(DirectoryHandle);
210 return FALSE;
211 }
212
213 ZwClose(EventHandle);
214 ZwClose(DirectoryHandle);
215
216 /* FIXME: Create SRM port and listener thread */
217
218 return TRUE;
219 }
220
221 NTSTATUS
222 NTAPI
223 SeDefaultObjectMethod(IN PVOID Object,
224 IN SECURITY_OPERATION_CODE OperationType,
225 IN PSECURITY_INFORMATION SecurityInformation,
226 IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
227 IN OUT PULONG ReturnLength OPTIONAL,
228 IN OUT PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
229 IN POOL_TYPE PoolType,
230 IN PGENERIC_MAPPING GenericMapping)
231 {
232 PAGED_CODE();
233
234 /* Select the operation type */
235 switch (OperationType)
236 {
237 /* Setting a new descriptor */
238 case SetSecurityDescriptor:
239
240 /* Sanity check */
241 ASSERT((PoolType == PagedPool) || (PoolType == NonPagedPool));
242
243 /* Set the information */
244 return ObSetSecurityDescriptorInfo(Object,
245 SecurityInformation,
246 SecurityDescriptor,
247 OldSecurityDescriptor,
248 PoolType,
249 GenericMapping);
250
251 case QuerySecurityDescriptor:
252
253 /* Query the information */
254 return ObQuerySecurityDescriptorInfo(Object,
255 SecurityInformation,
256 SecurityDescriptor,
257 ReturnLength,
258 OldSecurityDescriptor);
259
260 case DeleteSecurityDescriptor:
261
262 /* De-assign it */
263 return ObDeassignSecurity(OldSecurityDescriptor);
264
265 case AssignSecurityDescriptor:
266
267 /* Assign it */
268 ObAssignObjectSecurityDescriptor(Object, SecurityDescriptor, PoolType);
269 return STATUS_SUCCESS;
270
271 default:
272
273 /* Bug check */
274 KeBugCheckEx(SECURITY_SYSTEM, 0, STATUS_INVALID_PARAMETER, 0, 0);
275 }
276
277 /* Should never reach here */
278 ASSERT(FALSE);
279 return STATUS_SUCCESS;
280 }
281
282
283 static BOOLEAN
284 SepSidInToken(PACCESS_TOKEN _Token,
285 PSID Sid)
286 {
287 ULONG i;
288 PTOKEN Token = (PTOKEN)_Token;
289
290 PAGED_CODE();
291
292 if (Token->UserAndGroupCount == 0)
293 {
294 return FALSE;
295 }
296
297 for (i=0; i<Token->UserAndGroupCount; i++)
298 {
299 if (RtlEqualSid(Sid, Token->UserAndGroups[i].Sid))
300 {
301 if (Token->UserAndGroups[i].Attributes & SE_GROUP_ENABLED)
302 {
303 return TRUE;
304 }
305
306 return FALSE;
307 }
308 }
309
310 return FALSE;
311 }
312
313
314 VOID NTAPI
315 SeQuerySecurityAccessMask(IN SECURITY_INFORMATION SecurityInformation,
316 OUT PACCESS_MASK DesiredAccess)
317 {
318 *DesiredAccess = 0;
319
320 if (SecurityInformation & (OWNER_SECURITY_INFORMATION |
321 GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION))
322 {
323 *DesiredAccess |= READ_CONTROL;
324 }
325 if (SecurityInformation & SACL_SECURITY_INFORMATION)
326 {
327 *DesiredAccess |= ACCESS_SYSTEM_SECURITY;
328 }
329 }
330
331 VOID NTAPI
332 SeSetSecurityAccessMask(IN SECURITY_INFORMATION SecurityInformation,
333 OUT PACCESS_MASK DesiredAccess)
334 {
335 *DesiredAccess = 0;
336
337 if (SecurityInformation & (OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION))
338 {
339 *DesiredAccess |= WRITE_OWNER;
340 }
341 if (SecurityInformation & DACL_SECURITY_INFORMATION)
342 {
343 *DesiredAccess |= WRITE_DAC;
344 }
345 if (SecurityInformation & SACL_SECURITY_INFORMATION)
346 {
347 *DesiredAccess |= ACCESS_SYSTEM_SECURITY;
348 }
349 }
350
351 /* PUBLIC FUNCTIONS ***********************************************************/
352
353 /*
354 * @implemented
355 */
356 BOOLEAN NTAPI
357 SeAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
358 IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext,
359 IN BOOLEAN SubjectContextLocked,
360 IN ACCESS_MASK DesiredAccess,
361 IN ACCESS_MASK PreviouslyGrantedAccess,
362 OUT PPRIVILEGE_SET* Privileges,
363 IN PGENERIC_MAPPING GenericMapping,
364 IN KPROCESSOR_MODE AccessMode,
365 OUT PACCESS_MASK GrantedAccess,
366 OUT PNTSTATUS AccessStatus)
367 {
368 LUID_AND_ATTRIBUTES Privilege;
369 ACCESS_MASK CurrentAccess, AccessMask;
370 PACCESS_TOKEN Token;
371 ULONG i;
372 PACL Dacl;
373 BOOLEAN Present;
374 BOOLEAN Defaulted;
375 PACE CurrentAce;
376 PSID Sid;
377 NTSTATUS Status;
378 PAGED_CODE();
379
380 /* Check if this is kernel mode */
381 if (AccessMode == KernelMode)
382 {
383 /* Check if kernel wants everything */
384 if (DesiredAccess & MAXIMUM_ALLOWED)
385 {
386 /* Give it */
387 *GrantedAccess = GenericMapping->GenericAll;
388 *GrantedAccess |= (DesiredAccess &~ MAXIMUM_ALLOWED);
389 *GrantedAccess |= PreviouslyGrantedAccess;
390 }
391 else
392 {
393 /* Give the desired and previous access */
394 *GrantedAccess = DesiredAccess | PreviouslyGrantedAccess;
395 }
396
397 /* Success */
398 *AccessStatus = STATUS_SUCCESS;
399 return TRUE;
400 }
401
402 /* Check if we didn't get an SD */
403 if (!SecurityDescriptor)
404 {
405 /* Automatic failure */
406 *AccessStatus = STATUS_ACCESS_DENIED;
407 return FALSE;
408 }
409
410 /* Check for invalid impersonation */
411 if ((SubjectSecurityContext->ClientToken) &&
412 (SubjectSecurityContext->ImpersonationLevel < SecurityImpersonation))
413 {
414 *AccessStatus = STATUS_BAD_IMPERSONATION_LEVEL;
415 return FALSE;
416 }
417
418 /* Check for no access desired */
419 if (!DesiredAccess)
420 {
421 /* Check if we had no previous access */
422 if (!PreviouslyGrantedAccess)
423 {
424 /* Then there's nothing to give */
425 *AccessStatus = STATUS_ACCESS_DENIED;
426 return FALSE;
427 }
428
429 /* Return the previous access only */
430 *GrantedAccess = PreviouslyGrantedAccess;
431 *AccessStatus = STATUS_SUCCESS;
432 *Privileges = NULL;
433 return TRUE;
434 }
435
436 /* Acquire the lock if needed */
437 if (!SubjectContextLocked) SeLockSubjectContext(SubjectSecurityContext);
438
439 /* Map given accesses */
440 RtlMapGenericMask(&DesiredAccess, GenericMapping);
441 if (PreviouslyGrantedAccess)
442 RtlMapGenericMask(&PreviouslyGrantedAccess, GenericMapping);
443
444
445
446 CurrentAccess = PreviouslyGrantedAccess;
447
448
449
450 Token = SubjectSecurityContext->ClientToken ?
451 SubjectSecurityContext->ClientToken : SubjectSecurityContext->PrimaryToken;
452
453 /* Get the DACL */
454 Status = RtlGetDaclSecurityDescriptor(SecurityDescriptor,
455 &Present,
456 &Dacl,
457 &Defaulted);
458 if (!NT_SUCCESS(Status))
459 {
460 if (SubjectContextLocked == FALSE)
461 {
462 SeUnlockSubjectContext(SubjectSecurityContext);
463 }
464
465 *AccessStatus = Status;
466 return FALSE;
467 }
468
469 /* RULE 1: Grant desired access if the object is unprotected */
470 if (Present == TRUE && Dacl == NULL)
471 {
472 if (SubjectContextLocked == FALSE)
473 {
474 SeUnlockSubjectContext(SubjectSecurityContext);
475 }
476
477 *GrantedAccess = DesiredAccess;
478 *AccessStatus = STATUS_SUCCESS;
479 return TRUE;
480 }
481
482 CurrentAccess = PreviouslyGrantedAccess;
483
484 /* RULE 2: Check token for 'take ownership' privilege */
485 Privilege.Luid = SeTakeOwnershipPrivilege;
486 Privilege.Attributes = SE_PRIVILEGE_ENABLED;
487
488 if (SepPrivilegeCheck(Token,
489 &Privilege,
490 1,
491 PRIVILEGE_SET_ALL_NECESSARY,
492 AccessMode))
493 {
494 CurrentAccess |= WRITE_OWNER;
495 if ((DesiredAccess & ~VALID_INHERIT_FLAGS) ==
496 (CurrentAccess & ~VALID_INHERIT_FLAGS))
497 {
498 if (SubjectContextLocked == FALSE)
499 {
500 SeUnlockSubjectContext(SubjectSecurityContext);
501 }
502
503 *GrantedAccess = CurrentAccess;
504 *AccessStatus = STATUS_SUCCESS;
505 return TRUE;
506 }
507 }
508
509 /* RULE 3: Check whether the token is the owner */
510 Status = RtlGetOwnerSecurityDescriptor(SecurityDescriptor,
511 &Sid,
512 &Defaulted);
513 if (!NT_SUCCESS(Status))
514 {
515 DPRINT1("RtlGetOwnerSecurityDescriptor() failed (Status %lx)\n", Status);
516 if (SubjectContextLocked == FALSE)
517 {
518 SeUnlockSubjectContext(SubjectSecurityContext);
519 }
520
521 *AccessStatus = Status;
522 return FALSE;
523 }
524
525 if (Sid && SepSidInToken(Token, Sid))
526 {
527 CurrentAccess |= (READ_CONTROL | WRITE_DAC);
528 if ((DesiredAccess & ~VALID_INHERIT_FLAGS) ==
529 (CurrentAccess & ~VALID_INHERIT_FLAGS))
530 {
531 if (SubjectContextLocked == FALSE)
532 {
533 SeUnlockSubjectContext(SubjectSecurityContext);
534 }
535
536 *GrantedAccess = CurrentAccess;
537 *AccessStatus = STATUS_SUCCESS;
538 return TRUE;
539 }
540 }
541
542 /* Fail if DACL is absent */
543 if (Present == FALSE)
544 {
545 if (SubjectContextLocked == FALSE)
546 {
547 SeUnlockSubjectContext(SubjectSecurityContext);
548 }
549
550 *GrantedAccess = 0;
551 *AccessStatus = STATUS_ACCESS_DENIED;
552 return FALSE;
553 }
554
555 /* RULE 4: Grant rights according to the DACL */
556 CurrentAce = (PACE)(Dacl + 1);
557 for (i = 0; i < Dacl->AceCount; i++)
558 {
559 Sid = (PSID)(CurrentAce + 1);
560 if (CurrentAce->Header.AceType == ACCESS_DENIED_ACE_TYPE)
561 {
562 if (SepSidInToken(Token, Sid))
563 {
564 if (SubjectContextLocked == FALSE)
565 {
566 SeUnlockSubjectContext(SubjectSecurityContext);
567 }
568
569 *GrantedAccess = 0;
570 *AccessStatus = STATUS_ACCESS_DENIED;
571 return FALSE;
572 }
573 }
574
575 else if (CurrentAce->Header.AceType == ACCESS_ALLOWED_ACE_TYPE)
576 {
577 if (SepSidInToken(Token, Sid))
578 {
579 AccessMask = CurrentAce->AccessMask;
580 RtlMapGenericMask(&AccessMask, GenericMapping);
581 CurrentAccess |= AccessMask;
582 }
583 }
584 else
585 {
586 DPRINT1("Unknown Ace type 0x%lx\n", CurrentAce->Header.AceType);
587 }
588 CurrentAce = (PACE)((ULONG_PTR)CurrentAce + CurrentAce->Header.AceSize);
589 }
590
591 if (SubjectContextLocked == FALSE)
592 {
593 SeUnlockSubjectContext(SubjectSecurityContext);
594 }
595
596 DPRINT("CurrentAccess %08lx\n DesiredAccess %08lx\n",
597 CurrentAccess, DesiredAccess);
598
599 *GrantedAccess = CurrentAccess & DesiredAccess;
600
601 if (DesiredAccess & MAXIMUM_ALLOWED)
602 {
603 *GrantedAccess = CurrentAccess;
604 *AccessStatus = STATUS_SUCCESS;
605 return TRUE;
606 }
607 else if ((*GrantedAccess & ~VALID_INHERIT_FLAGS) ==
608 (DesiredAccess & ~VALID_INHERIT_FLAGS))
609 {
610 *AccessStatus = STATUS_SUCCESS;
611 return TRUE;
612 }
613 else
614 {
615 DPRINT1("Denying access for caller: granted 0x%lx, desired 0x%lx (generic mapping %p)\n",
616 *GrantedAccess, DesiredAccess, GenericMapping);
617 *AccessStatus = STATUS_ACCESS_DENIED;
618 return FALSE;
619 }
620 }
621
622 /* SYSTEM CALLS ***************************************************************/
623
624 /*
625 * @implemented
626 */
627 NTSTATUS
628 NTAPI
629 NtAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
630 IN HANDLE TokenHandle,
631 IN ACCESS_MASK DesiredAccess,
632 IN PGENERIC_MAPPING GenericMapping,
633 OUT PPRIVILEGE_SET PrivilegeSet OPTIONAL,
634 IN OUT PULONG PrivilegeSetLength,
635 OUT PACCESS_MASK GrantedAccess,
636 OUT PNTSTATUS AccessStatus)
637 {
638 SECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
639 KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
640 PTOKEN Token;
641 NTSTATUS Status;
642 PAGED_CODE();
643
644 /* Check if this is kernel mode */
645 if (PreviousMode == KernelMode)
646 {
647 /* Check if kernel wants everything */
648 if (DesiredAccess & MAXIMUM_ALLOWED)
649 {
650 /* Give it */
651 *GrantedAccess = GenericMapping->GenericAll;
652 *GrantedAccess |= (DesiredAccess &~ MAXIMUM_ALLOWED);
653 }
654 else
655 {
656 /* Just give the desired access */
657 *GrantedAccess = DesiredAccess;
658 }
659
660 /* Success */
661 *AccessStatus = STATUS_SUCCESS;
662 return STATUS_SUCCESS;
663 }
664
665 /* Reference the token */
666 Status = ObReferenceObjectByHandle(TokenHandle,
667 TOKEN_QUERY,
668 SepTokenObjectType,
669 PreviousMode,
670 (PVOID*)&Token,
671 NULL);
672 if (!NT_SUCCESS(Status))
673 {
674 DPRINT1("Failed to reference token (Status %lx)\n", Status);
675 return Status;
676 }
677
678 /* Check token type */
679 if (Token->TokenType != TokenImpersonation)
680 {
681 DPRINT1("No impersonation token\n");
682 ObDereferenceObject(Token);
683 return STATUS_ACCESS_DENIED;
684 }
685
686 /* Set up the subject context, and lock it */
687 SubjectSecurityContext.ClientToken = Token;
688 SubjectSecurityContext.ImpersonationLevel = Token->ImpersonationLevel;
689 SubjectSecurityContext.PrimaryToken = NULL;
690 SubjectSecurityContext.ProcessAuditId = NULL;
691 SeLockSubjectContext(&SubjectSecurityContext);
692
693 /* Now perform the access check */
694 SeAccessCheck(SecurityDescriptor,
695 &SubjectSecurityContext,
696 TRUE,
697 DesiredAccess,
698 0,
699 &PrivilegeSet, //FIXME
700 GenericMapping,
701 PreviousMode,
702 GrantedAccess,
703 AccessStatus);
704
705 /* Unlock subject context and dereference the token */
706 SeUnlockSubjectContext(&SubjectSecurityContext);
707 ObDereferenceObject(Token);
708
709 /* Check succeeded */
710 return STATUS_SUCCESS;
711 }
712
713
714 NTSTATUS
715 NTAPI
716 NtAccessCheckByType(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
717 IN PSID PrincipalSelfSid,
718 IN HANDLE ClientToken,
719 IN ACCESS_MASK DesiredAccess,
720 IN POBJECT_TYPE_LIST ObjectTypeList,
721 IN ULONG ObjectTypeLength,
722 IN PGENERIC_MAPPING GenericMapping,
723 IN PPRIVILEGE_SET PrivilegeSet,
724 IN ULONG PrivilegeSetLength,
725 OUT PACCESS_MASK GrantedAccess,
726 OUT PNTSTATUS AccessStatus)
727 {
728 UNIMPLEMENTED;
729 return STATUS_NOT_IMPLEMENTED;
730 }
731
732 NTSTATUS
733 NTAPI
734 NtAccessCheckByTypeAndAuditAlarm(IN PUNICODE_STRING SubsystemName,
735 IN HANDLE HandleId,
736 IN PUNICODE_STRING ObjectTypeName,
737 IN PUNICODE_STRING ObjectName,
738 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
739 IN PSID PrincipalSelfSid,
740 IN ACCESS_MASK DesiredAccess,
741 IN AUDIT_EVENT_TYPE AuditType,
742 IN ULONG Flags,
743 IN POBJECT_TYPE_LIST ObjectTypeList,
744 IN ULONG ObjectTypeLength,
745 IN PGENERIC_MAPPING GenericMapping,
746 IN BOOLEAN ObjectCreation,
747 OUT PACCESS_MASK GrantedAccess,
748 OUT PNTSTATUS AccessStatus,
749 OUT PBOOLEAN GenerateOnClose)
750 {
751 UNIMPLEMENTED;
752 return STATUS_NOT_IMPLEMENTED;
753 }
754
755 NTSTATUS
756 NTAPI
757 NtAccessCheckByTypeResultList(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
758 IN PSID PrincipalSelfSid,
759 IN HANDLE ClientToken,
760 IN ACCESS_MASK DesiredAccess,
761 IN POBJECT_TYPE_LIST ObjectTypeList,
762 IN ULONG ObjectTypeLength,
763 IN PGENERIC_MAPPING GenericMapping,
764 IN PPRIVILEGE_SET PrivilegeSet,
765 IN ULONG PrivilegeSetLength,
766 OUT PACCESS_MASK GrantedAccess,
767 OUT PNTSTATUS AccessStatus)
768 {
769 UNIMPLEMENTED;
770 return STATUS_NOT_IMPLEMENTED;
771 }
772
773 NTSTATUS
774 NTAPI
775 NtAccessCheckByTypeResultListAndAuditAlarm(IN PUNICODE_STRING SubsystemName,
776 IN HANDLE HandleId,
777 IN PUNICODE_STRING ObjectTypeName,
778 IN PUNICODE_STRING ObjectName,
779 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
780 IN PSID PrincipalSelfSid,
781 IN ACCESS_MASK DesiredAccess,
782 IN AUDIT_EVENT_TYPE AuditType,
783 IN ULONG Flags,
784 IN POBJECT_TYPE_LIST ObjectTypeList,
785 IN ULONG ObjectTypeLength,
786 IN PGENERIC_MAPPING GenericMapping,
787 IN BOOLEAN ObjectCreation,
788 OUT PACCESS_MASK GrantedAccess,
789 OUT PNTSTATUS AccessStatus,
790 OUT PBOOLEAN GenerateOnClose)
791 {
792 UNIMPLEMENTED;
793 return STATUS_NOT_IMPLEMENTED;
794 }
795
796 NTSTATUS
797 NTAPI
798 NtAccessCheckByTypeResultListAndAuditAlarmByHandle(IN PUNICODE_STRING SubsystemName,
799 IN HANDLE HandleId,
800 IN HANDLE ClientToken,
801 IN PUNICODE_STRING ObjectTypeName,
802 IN PUNICODE_STRING ObjectName,
803 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
804 IN PSID PrincipalSelfSid,
805 IN ACCESS_MASK DesiredAccess,
806 IN AUDIT_EVENT_TYPE AuditType,
807 IN ULONG Flags,
808 IN POBJECT_TYPE_LIST ObjectTypeList,
809 IN ULONG ObjectTypeLength,
810 IN PGENERIC_MAPPING GenericMapping,
811 IN BOOLEAN ObjectCreation,
812 OUT PACCESS_MASK GrantedAccess,
813 OUT PNTSTATUS AccessStatus,
814 OUT PBOOLEAN GenerateOnClose)
815 {
816 UNIMPLEMENTED;
817 return STATUS_NOT_IMPLEMENTED;
818 }
819
820 /* EOF */