update for HEAD-2003050101
[reactos.git] / ntoskrnl / ob / security.c
1 /*
2  * COPYRIGHT:         See COPYING in the top level directory
3  * PROJECT:           ReactOS kernel
4  * PURPOSE:           Security manager
5  * FILE:              ntoskrnl/ob/security.c
6  * PROGRAMER:         ?
7  * REVISION HISTORY:
8  *                 26/07/98: Added stubs for security functions
9  */
10
11 /* INCLUDES *****************************************************************/
12
13 #include <ddk/ntddk.h>
14 #include <internal/ob.h>
15
16 #include <internal/debug.h>
17
18 /* FUNCTIONS ***************************************************************/
19
20 NTSTATUS STDCALL
21 ObAssignSecurity(IN PACCESS_STATE AccessState,
22                  IN PSECURITY_DESCRIPTOR SecurityDescriptor,
23                  IN PVOID Object,
24                  IN POBJECT_TYPE Type)
25 {
26   UNIMPLEMENTED;
27 }
28
29
30 NTSTATUS STDCALL
31 ObGetObjectSecurity(IN PVOID Object,
32                     OUT PSECURITY_DESCRIPTOR *SecurityDescriptor,
33                     OUT PBOOLEAN MemoryAllocated)
34 {
35   UNIMPLEMENTED;
36 }
37
38
39 VOID STDCALL
40 ObReleaseObjectSecurity(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
41                         IN BOOLEAN MemoryAllocated)
42 {
43   UNIMPLEMENTED;
44 }
45
46
47 NTSTATUS STDCALL
48 NtQuerySecurityObject(IN HANDLE Handle,
49                       IN SECURITY_INFORMATION SecurityInformation,
50                       OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
51                       IN ULONG Length,
52                       OUT PULONG ResultLength)
53 {
54   POBJECT_HEADER Header;
55   PVOID Object;
56   NTSTATUS Status;
57
58   Status = ObReferenceObjectByHandle(Handle,
59                                      0,
60                                      NULL,
61                                      KeGetPreviousMode(),
62                                      &Object,
63                                      NULL);
64   if (!NT_SUCCESS(Status))
65     {
66       return(Status);
67     }
68
69   Header = BODY_TO_HEADER(Object);
70   if (Header->ObjectType != NULL &&
71       Header->ObjectType->Security != NULL)
72     {
73       Status = Header->ObjectType->Security(Object,
74                                             QuerySecurityDescriptor,
75                                             SecurityInformation,
76                                             SecurityDescriptor,
77                                             &Length);
78       *ResultLength = Length;
79     }
80   else
81     {
82       Status = STATUS_NOT_IMPLEMENTED;
83     }
84
85   ObDereferenceObject(Object);
86
87   return(Status);
88 }
89
90
91 NTSTATUS STDCALL
92 NtSetSecurityObject(IN HANDLE Handle,
93                     IN SECURITY_INFORMATION SecurityInformation,
94                     IN PSECURITY_DESCRIPTOR SecurityDescriptor)
95 {
96   POBJECT_HEADER Header;
97   PVOID Object;
98   NTSTATUS Status;
99
100   Status = ObReferenceObjectByHandle(Handle,
101                                      0,
102                                      NULL,
103                                      KeGetPreviousMode(),
104                                      &Object,
105                                      NULL);
106   if (!NT_SUCCESS(Status))
107     {
108       return(Status);
109     }
110
111   Header = BODY_TO_HEADER(Object);
112   if (Header->ObjectType != NULL &&
113       Header->ObjectType->Security != NULL)
114     {
115       Status = Header->ObjectType->Security(Object,
116                                             SetSecurityDescriptor,
117                                             SecurityInformation,
118                                             SecurityDescriptor,
119                                             NULL);
120     }
121   else
122     {
123       Status = STATUS_NOT_IMPLEMENTED;
124     }
125
126   ObDereferenceObject(Object);
127
128   return(Status);
129 }
130
131 /* EOF */