2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: Security manager
5 * FILE: ntoskrnl/ob/security.c
8 * 26/07/98: Added stubs for security functions
11 /* INCLUDES *****************************************************************/
13 #include <ddk/ntddk.h>
14 #include <internal/ob.h>
16 #include <internal/debug.h>
18 /* FUNCTIONS ***************************************************************/
24 ObAssignSecurity(IN PACCESS_STATE AccessState
,
25 IN PSECURITY_DESCRIPTOR SecurityDescriptor
,
29 PSECURITY_DESCRIPTOR NewDescriptor
;
32 /* Build the new security descriptor */
33 Status
= SeAssignSecurity(SecurityDescriptor
,
34 AccessState
->SecurityDescriptor
,
36 (Type
== ObDirectoryType
),
37 &AccessState
->SubjectSecurityContext
,
40 if (!NT_SUCCESS(Status
))
43 if (Type
->Security
!= NULL
)
45 /* Call the security method */
46 Status
= Type
->Security(Object
,
47 AssignSecurityDescriptor
,
54 /* Assign the security descriptor to the object header */
55 Status
= ObpAddSecurityDescriptor(NewDescriptor
,
56 &(BODY_TO_HEADER(Object
)->SecurityDescriptor
));
59 /* Release the new security descriptor */
60 SeDeassignSecurity(&NewDescriptor
);
70 ObGetObjectSecurity(IN PVOID Object
,
71 OUT PSECURITY_DESCRIPTOR
*SecurityDescriptor
,
72 OUT PBOOLEAN MemoryAllocated
)
75 return(STATUS_NOT_IMPLEMENTED
);
83 ObReleaseObjectSecurity(IN PSECURITY_DESCRIPTOR SecurityDescriptor
,
84 IN BOOLEAN MemoryAllocated
)
94 NtQuerySecurityObject(IN HANDLE Handle
,
95 IN SECURITY_INFORMATION SecurityInformation
,
96 OUT PSECURITY_DESCRIPTOR SecurityDescriptor
,
98 OUT PULONG ResultLength
)
100 POBJECT_HEADER Header
;
104 Status
= ObReferenceObjectByHandle(Handle
,
110 if (!NT_SUCCESS(Status
))
115 Header
= BODY_TO_HEADER(Object
);
116 if (Header
->ObjectType
== NULL
&&
117 Header
->ObjectType
->Security
!= NULL
)
119 Status
= Header
->ObjectType
->Security(Object
,
120 QuerySecurityDescriptor
,
124 *ResultLength
= Length
;
128 if (Header
->SecurityDescriptor
!= NULL
)
130 /* FIXME: Use SecurityInformation */
131 *ResultLength
= RtlLengthSecurityDescriptor(Header
->SecurityDescriptor
);
132 if (Length
>= *ResultLength
)
134 RtlCopyMemory(SecurityDescriptor
,
135 Header
->SecurityDescriptor
,
138 Status
= STATUS_SUCCESS
;
142 Status
= STATUS_BUFFER_TOO_SMALL
;
148 Status
= STATUS_UNSUCCESSFUL
;
152 ObDereferenceObject(Object
);
162 NtSetSecurityObject(IN HANDLE Handle
,
163 IN SECURITY_INFORMATION SecurityInformation
,
164 IN PSECURITY_DESCRIPTOR SecurityDescriptor
)
166 POBJECT_HEADER Header
;
170 Status
= ObReferenceObjectByHandle(Handle
,
176 if (!NT_SUCCESS(Status
))
181 Header
= BODY_TO_HEADER(Object
);
182 if (Header
->ObjectType
!= NULL
&&
183 Header
->ObjectType
->Security
!= NULL
)
185 Status
= Header
->ObjectType
->Security(Object
,
186 SetSecurityDescriptor
,
193 Status
= STATUS_NOT_IMPLEMENTED
;
196 ObDereferenceObject(Object
);