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 )
22 GetSecurityDescriptorControl (
23 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
24 PSECURITY_DESCRIPTOR_CONTROL pControl
,
30 Status
= RtlGetControlSecurityDescriptor (pSecurityDescriptor
,
32 (PULONG
)lpdwRevision
);
33 if (!NT_SUCCESS(Status
))
35 SetLastError (RtlNtStatusToDosError (Status
));
48 GetSecurityDescriptorDacl (
49 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
50 LPBOOL lpbDaclPresent
,
52 LPBOOL lpbDaclDefaulted
56 BOOLEAN DaclDefaulted
;
59 Status
= RtlGetDaclSecurityDescriptor (pSecurityDescriptor
,
63 *lpbDaclPresent
= (BOOL
)DaclPresent
;
64 *lpbDaclDefaulted
= (BOOL
)DaclDefaulted
;
66 if (!NT_SUCCESS(Status
))
68 SetLastError (RtlNtStatusToDosError (Status
));
81 GetSecurityDescriptorGroup (
82 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
84 LPBOOL lpbGroupDefaulted
87 BOOLEAN GroupDefaulted
;
90 Status
= RtlGetGroupSecurityDescriptor (pSecurityDescriptor
,
93 *lpbGroupDefaulted
= (BOOL
)GroupDefaulted
;
95 if (!NT_SUCCESS(Status
))
97 SetLastError (RtlNtStatusToDosError (Status
));
110 GetSecurityDescriptorLength (
111 PSECURITY_DESCRIPTOR pSecurityDescriptor
114 return RtlLengthSecurityDescriptor(pSecurityDescriptor
);
123 GetSecurityDescriptorOwner (
124 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
126 LPBOOL lpbOwnerDefaulted
129 BOOLEAN OwnerDefaulted
;
132 Status
= RtlGetOwnerSecurityDescriptor (pSecurityDescriptor
,
135 *lpbOwnerDefaulted
= (BOOL
)OwnerDefaulted
;
137 if (!NT_SUCCESS(Status
))
139 SetLastError (RtlNtStatusToDosError (Status
));
152 GetSecurityDescriptorRMControl (
153 PSECURITY_DESCRIPTOR SecurityDescriptor
,
156 if (!RtlGetSecurityDescriptorRMControl(SecurityDescriptor
,
158 return ERROR_INVALID_DATA
;
160 return ERROR_SUCCESS
;
169 GetSecurityDescriptorSacl (
170 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
171 LPBOOL lpbSaclPresent
,
173 LPBOOL lpbSaclDefaulted
177 BOOLEAN SaclDefaulted
;
180 Status
= RtlGetSaclSecurityDescriptor (pSecurityDescriptor
,
184 *lpbSaclPresent
= (BOOL
)SaclPresent
;
185 *lpbSaclDefaulted
= (BOOL
)SaclDefaulted
;
187 if (!NT_SUCCESS(Status
))
189 SetLastError (RtlNtStatusToDosError (Status
));
202 InitializeSecurityDescriptor (
203 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
209 Status
= RtlCreateSecurityDescriptor (pSecurityDescriptor
,
211 if (!NT_SUCCESS(Status
))
213 SetLastError (RtlNtStatusToDosError (Status
));
226 IsValidSecurityDescriptor (
227 PSECURITY_DESCRIPTOR pSecurityDescriptor
232 Result
= RtlValidSecurityDescriptor (pSecurityDescriptor
);
234 SetLastError (RtlNtStatusToDosError (STATUS_INVALID_SECURITY_DESCR
));
246 PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor
,
247 PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor
,
248 LPDWORD lpdwAbsoluteSecurityDescriptorSize
,
250 LPDWORD lpdwDaclSize
,
252 LPDWORD lpdwSaclSize
,
254 LPDWORD lpdwOwnerSize
,
256 LPDWORD lpdwPrimaryGroupSize
261 Status
= RtlSelfRelativeToAbsoluteSD ((PSECURITY_DESCRIPTOR_RELATIVE
)pSelfRelativeSecurityDescriptor
,
262 pAbsoluteSecurityDescriptor
,
263 lpdwAbsoluteSecurityDescriptorSize
,
271 lpdwPrimaryGroupSize
);
272 if (!NT_SUCCESS(Status
))
274 SetLastError (RtlNtStatusToDosError (Status
));
288 PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor
,
289 PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor
,
290 LPDWORD lpdwBufferLength
295 Status
= RtlAbsoluteToSelfRelativeSD (pAbsoluteSecurityDescriptor
,
296 (PSECURITY_DESCRIPTOR_RELATIVE
)pSelfRelativeSecurityDescriptor
,
297 (PULONG
)lpdwBufferLength
);
298 if (!NT_SUCCESS(Status
))
300 SetLastError (RtlNtStatusToDosError (Status
));
313 SetSecurityDescriptorControl (
314 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
315 SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest
,
316 SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet
)
320 Status
= RtlSetControlSecurityDescriptor(pSecurityDescriptor
,
321 ControlBitsOfInterest
,
323 if (!NT_SUCCESS(Status
))
325 SetLastError (RtlNtStatusToDosError (Status
));
338 SetSecurityDescriptorDacl (
339 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
347 Status
= RtlSetDaclSecurityDescriptor (pSecurityDescriptor
,
351 if (!NT_SUCCESS(Status
))
353 SetLastError (RtlNtStatusToDosError (Status
));
366 SetSecurityDescriptorGroup (
367 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
374 Status
= RtlSetGroupSecurityDescriptor (pSecurityDescriptor
,
377 if (!NT_SUCCESS(Status
))
379 SetLastError (RtlNtStatusToDosError (Status
));
392 SetSecurityDescriptorOwner (
393 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
400 Status
= RtlSetOwnerSecurityDescriptor (pSecurityDescriptor
,
403 if (!NT_SUCCESS(Status
))
405 SetLastError (RtlNtStatusToDosError (Status
));
418 SetSecurityDescriptorRMControl (
419 PSECURITY_DESCRIPTOR SecurityDescriptor
,
422 RtlSetSecurityDescriptorRMControl(SecurityDescriptor
,
425 return ERROR_SUCCESS
;
434 SetSecurityDescriptorSacl (
435 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
443 Status
= RtlSetSaclSecurityDescriptor (pSecurityDescriptor
,
447 if (!NT_SUCCESS(Status
))
449 SetLastError (RtlNtStatusToDosError (Status
));