1 /* $Id: sec.c,v 1.18 2004/02/25 14:25:11 ekohl Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/advapi32/sec/sec.c
6 * PURPOSE: Security descriptor functions
7 * PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
8 * Steven Edwards ( Steven_Ed4153@yahoo.com )
9 * Andrew Greenwood ( silverblade_uk@hotmail.com )
14 #define NTOS_MODE_USER
24 GetSecurityDescriptorControl (
25 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
26 PSECURITY_DESCRIPTOR_CONTROL pControl
,
32 Status
= RtlGetControlSecurityDescriptor (pSecurityDescriptor
,
34 (PULONG
)lpdwRevision
);
35 if (!NT_SUCCESS(Status
))
37 SetLastError (RtlNtStatusToDosError (Status
));
50 GetSecurityDescriptorDacl (
51 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
52 LPBOOL lpbDaclPresent
,
54 LPBOOL lpbDaclDefaulted
58 BOOLEAN DaclDefaulted
;
61 Status
= RtlGetDaclSecurityDescriptor (pSecurityDescriptor
,
65 *lpbDaclPresent
= (BOOL
)DaclPresent
;
66 *lpbDaclDefaulted
= (BOOL
)DaclDefaulted
;
68 if (!NT_SUCCESS(Status
))
70 SetLastError (RtlNtStatusToDosError (Status
));
83 GetSecurityDescriptorGroup (
84 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
86 LPBOOL lpbGroupDefaulted
89 BOOLEAN GroupDefaulted
;
92 Status
= RtlGetGroupSecurityDescriptor (pSecurityDescriptor
,
95 *lpbGroupDefaulted
= (BOOL
)GroupDefaulted
;
97 if (!NT_SUCCESS(Status
))
99 SetLastError (RtlNtStatusToDosError (Status
));
112 GetSecurityDescriptorLength (
113 PSECURITY_DESCRIPTOR pSecurityDescriptor
116 return RtlLengthSecurityDescriptor(pSecurityDescriptor
);
125 GetSecurityDescriptorOwner (
126 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
128 LPBOOL lpbOwnerDefaulted
131 BOOLEAN OwnerDefaulted
;
134 Status
= RtlGetOwnerSecurityDescriptor (pSecurityDescriptor
,
137 *lpbOwnerDefaulted
= (BOOL
)OwnerDefaulted
;
139 if (!NT_SUCCESS(Status
))
141 SetLastError (RtlNtStatusToDosError (Status
));
154 GetSecurityDescriptorSacl (
155 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
156 LPBOOL lpbSaclPresent
,
158 LPBOOL lpbSaclDefaulted
162 BOOLEAN SaclDefaulted
;
165 Status
= RtlGetSaclSecurityDescriptor (pSecurityDescriptor
,
169 *lpbSaclPresent
= (BOOL
)SaclPresent
;
170 *lpbSaclDefaulted
= (BOOL
)SaclDefaulted
;
172 if (!NT_SUCCESS(Status
))
174 SetLastError (RtlNtStatusToDosError (Status
));
187 InitializeSecurityDescriptor (
188 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
194 Status
= RtlCreateSecurityDescriptor (pSecurityDescriptor
,
196 if (!NT_SUCCESS(Status
))
198 SetLastError (RtlNtStatusToDosError (Status
));
211 IsValidSecurityDescriptor (
212 PSECURITY_DESCRIPTOR pSecurityDescriptor
217 Result
= RtlValidSecurityDescriptor (pSecurityDescriptor
);
219 SetLastError (RtlNtStatusToDosError (STATUS_INVALID_SECURITY_DESCR
));
231 PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor
,
232 PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor
,
233 LPDWORD lpdwAbsoluteSecurityDescriptorSize
,
235 LPDWORD lpdwDaclSize
,
237 LPDWORD lpdwSaclSize
,
239 LPDWORD lpdwOwnerSize
,
241 LPDWORD lpdwPrimaryGroupSize
246 Status
= RtlSelfRelativeToAbsoluteSD (pSelfRelativeSecurityDescriptor
,
247 pAbsoluteSecurityDescriptor
,
248 lpdwAbsoluteSecurityDescriptorSize
,
256 lpdwPrimaryGroupSize
);
257 if (!NT_SUCCESS(Status
))
259 SetLastError (RtlNtStatusToDosError (Status
));
273 PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor
,
274 PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor
,
275 LPDWORD lpdwBufferLength
280 Status
= RtlAbsoluteToSelfRelativeSD (pAbsoluteSecurityDescriptor
,
281 pSelfRelativeSecurityDescriptor
,
282 (PULONG
)lpdwBufferLength
);
283 if (!NT_SUCCESS(Status
))
285 SetLastError (RtlNtStatusToDosError (Status
));
298 SetSecurityDescriptorDacl (
299 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
307 Status
= RtlSetDaclSecurityDescriptor (pSecurityDescriptor
,
311 if (!NT_SUCCESS(Status
))
313 SetLastError (RtlNtStatusToDosError (Status
));
326 SetSecurityDescriptorGroup (
327 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
334 Status
= RtlSetGroupSecurityDescriptor (pSecurityDescriptor
,
337 if (!NT_SUCCESS(Status
))
339 SetLastError (RtlNtStatusToDosError (Status
));
352 SetSecurityDescriptorOwner (
353 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
360 Status
= RtlSetGroupSecurityDescriptor (pSecurityDescriptor
,
363 if (!NT_SUCCESS(Status
))
365 SetLastError (RtlNtStatusToDosError (Status
));
378 SetSecurityDescriptorSacl (
379 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
387 Status
= RtlSetSaclSecurityDescriptor (pSecurityDescriptor
,
391 if (!NT_SUCCESS(Status
))
393 SetLastError (RtlNtStatusToDosError (Status
));