b5c00dab36523c993f8e6e0b16922103dcefaa4f
[reactos.git] / reactos / 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 /*
21 * @unimplemented
22 */
23 NTSTATUS STDCALL
24 ObAssignSecurity(IN PACCESS_STATE AccessState,
25 IN PSECURITY_DESCRIPTOR SecurityDescriptor,
26 IN PVOID Object,
27 IN POBJECT_TYPE Type)
28 {
29 UNIMPLEMENTED;
30 return(STATUS_NOT_IMPLEMENTED);
31 }
32
33
34 /*
35 * @unimplemented
36 */
37 NTSTATUS STDCALL
38 ObGetObjectSecurity(IN PVOID Object,
39 OUT PSECURITY_DESCRIPTOR *SecurityDescriptor,
40 OUT PBOOLEAN MemoryAllocated)
41 {
42 UNIMPLEMENTED;
43 return(STATUS_NOT_IMPLEMENTED);
44 }
45
46
47 /*
48 * @unimplemented
49 */
50 VOID STDCALL
51 ObReleaseObjectSecurity(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
52 IN BOOLEAN MemoryAllocated)
53 {
54 UNIMPLEMENTED;
55 }
56
57
58 /*
59 * @implemented
60 */
61 NTSTATUS STDCALL
62 NtQuerySecurityObject(IN HANDLE Handle,
63 IN SECURITY_INFORMATION SecurityInformation,
64 OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
65 IN ULONG Length,
66 OUT PULONG ResultLength)
67 {
68 POBJECT_HEADER Header;
69 PVOID Object;
70 NTSTATUS Status;
71
72 Status = ObReferenceObjectByHandle(Handle,
73 0,
74 NULL,
75 KeGetPreviousMode(),
76 &Object,
77 NULL);
78 if (!NT_SUCCESS(Status))
79 {
80 return(Status);
81 }
82
83 Header = BODY_TO_HEADER(Object);
84 if (Header->ObjectType == NULL &&
85 Header->ObjectType->Security != NULL)
86 {
87 Status = Header->ObjectType->Security(Object,
88 QuerySecurityDescriptor,
89 SecurityInformation,
90 SecurityDescriptor,
91 &Length);
92 *ResultLength = Length;
93 }
94 else
95 {
96 if (Header->SecurityDescriptor != NULL)
97 {
98 /* FIXME: Use SecurityInformation */
99 *ResultLength = RtlLengthSecurityDescriptor(Header->SecurityDescriptor);
100 if (Length >= *ResultLength)
101 {
102 RtlCopyMemory(SecurityDescriptor,
103 Header->SecurityDescriptor,
104 *ResultLength);
105
106 Status = STATUS_SUCCESS;
107 }
108 else
109 {
110 Status = STATUS_BUFFER_TOO_SMALL;
111 }
112 }
113 else
114 {
115 *ResultLength = 0;
116 Status = STATUS_UNSUCCESSFUL;
117 }
118 }
119
120 ObDereferenceObject(Object);
121
122 return Status;
123 }
124
125
126 /*
127 * @unimplemented
128 */
129 NTSTATUS STDCALL
130 NtSetSecurityObject(IN HANDLE Handle,
131 IN SECURITY_INFORMATION SecurityInformation,
132 IN PSECURITY_DESCRIPTOR SecurityDescriptor)
133 {
134 POBJECT_HEADER Header;
135 PVOID Object;
136 NTSTATUS Status;
137
138 Status = ObReferenceObjectByHandle(Handle,
139 0,
140 NULL,
141 KeGetPreviousMode(),
142 &Object,
143 NULL);
144 if (!NT_SUCCESS(Status))
145 {
146 return(Status);
147 }
148
149 Header = BODY_TO_HEADER(Object);
150 if (Header->ObjectType != NULL &&
151 Header->ObjectType->Security != NULL)
152 {
153 Status = Header->ObjectType->Security(Object,
154 SetSecurityDescriptor,
155 SecurityInformation,
156 SecurityDescriptor,
157 NULL);
158 }
159 else
160 {
161 Status = STATUS_NOT_IMPLEMENTED;
162 }
163
164 ObDereferenceObject(Object);
165
166 return(Status);
167 }
168
169 /* EOF */