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 GetSecurityDescriptorOwner (
111 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
113 LPBOOL lpbOwnerDefaulted
116 BOOLEAN OwnerDefaulted
;
119 Status
= RtlGetOwnerSecurityDescriptor (pSecurityDescriptor
,
122 *lpbOwnerDefaulted
= (BOOL
)OwnerDefaulted
;
124 if (!NT_SUCCESS(Status
))
126 SetLastError (RtlNtStatusToDosError (Status
));
139 GetSecurityDescriptorRMControl (
140 PSECURITY_DESCRIPTOR SecurityDescriptor
,
143 if (!RtlGetSecurityDescriptorRMControl(SecurityDescriptor
,
145 return ERROR_INVALID_DATA
;
147 return ERROR_SUCCESS
;
156 GetSecurityDescriptorSacl (
157 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
158 LPBOOL lpbSaclPresent
,
160 LPBOOL lpbSaclDefaulted
164 BOOLEAN SaclDefaulted
;
167 Status
= RtlGetSaclSecurityDescriptor (pSecurityDescriptor
,
171 *lpbSaclPresent
= (BOOL
)SaclPresent
;
172 *lpbSaclDefaulted
= (BOOL
)SaclDefaulted
;
174 if (!NT_SUCCESS(Status
))
176 SetLastError (RtlNtStatusToDosError (Status
));
189 InitializeSecurityDescriptor (
190 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
196 Status
= RtlCreateSecurityDescriptor (pSecurityDescriptor
,
198 if (!NT_SUCCESS(Status
))
200 SetLastError (RtlNtStatusToDosError (Status
));
213 IsValidSecurityDescriptor (
214 PSECURITY_DESCRIPTOR pSecurityDescriptor
219 Result
= RtlValidSecurityDescriptor (pSecurityDescriptor
);
221 SetLastError (RtlNtStatusToDosError (STATUS_INVALID_SECURITY_DESCR
));
233 PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor
,
234 PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor
,
235 LPDWORD lpdwAbsoluteSecurityDescriptorSize
,
237 LPDWORD lpdwDaclSize
,
239 LPDWORD lpdwSaclSize
,
241 LPDWORD lpdwOwnerSize
,
243 LPDWORD lpdwPrimaryGroupSize
248 Status
= RtlSelfRelativeToAbsoluteSD (pSelfRelativeSecurityDescriptor
,
249 pAbsoluteSecurityDescriptor
,
250 lpdwAbsoluteSecurityDescriptorSize
,
258 lpdwPrimaryGroupSize
);
259 if (!NT_SUCCESS(Status
))
261 SetLastError (RtlNtStatusToDosError (Status
));
275 PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor
,
276 PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor
,
277 LPDWORD lpdwBufferLength
282 Status
= RtlAbsoluteToSelfRelativeSD (pAbsoluteSecurityDescriptor
,
283 pSelfRelativeSecurityDescriptor
,
284 (PULONG
)lpdwBufferLength
);
285 if (!NT_SUCCESS(Status
))
287 SetLastError (RtlNtStatusToDosError (Status
));
300 SetSecurityDescriptorControl (
301 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
302 SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest
,
303 SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet
)
307 Status
= RtlSetControlSecurityDescriptor(pSecurityDescriptor
,
308 ControlBitsOfInterest
,
310 if (!NT_SUCCESS(Status
))
312 SetLastError (RtlNtStatusToDosError (Status
));
325 SetSecurityDescriptorDacl (
326 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
334 Status
= RtlSetDaclSecurityDescriptor (pSecurityDescriptor
,
338 if (!NT_SUCCESS(Status
))
340 SetLastError (RtlNtStatusToDosError (Status
));
353 SetSecurityDescriptorGroup (
354 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
361 Status
= RtlSetGroupSecurityDescriptor (pSecurityDescriptor
,
364 if (!NT_SUCCESS(Status
))
366 SetLastError (RtlNtStatusToDosError (Status
));
379 SetSecurityDescriptorOwner (
380 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
387 Status
= RtlSetOwnerSecurityDescriptor (pSecurityDescriptor
,
390 if (!NT_SUCCESS(Status
))
392 SetLastError (RtlNtStatusToDosError (Status
));
405 SetSecurityDescriptorRMControl (
406 PSECURITY_DESCRIPTOR SecurityDescriptor
,
409 RtlSetSecurityDescriptorRMControl(SecurityDescriptor
,
412 return ERROR_SUCCESS
;
421 SetSecurityDescriptorSacl (
422 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
430 Status
= RtlSetSaclSecurityDescriptor (pSecurityDescriptor
,
434 if (!NT_SUCCESS(Status
))
436 SetLastError (RtlNtStatusToDosError (Status
));
449 ConvertToAutoInheritPrivateObjectSecurity(IN PSECURITY_DESCRIPTOR ParentDescriptor
,
450 IN PSECURITY_DESCRIPTOR CurrentSecurityDescriptor
,
451 OUT PSECURITY_DESCRIPTOR
* NewSecurityDescriptor
,
453 IN BOOLEAN IsDirectoryObject
,
454 IN PGENERIC_MAPPING GenericMapping
)
466 BuildSecurityDescriptorW(IN PTRUSTEE_W pOwner OPTIONAL
,
467 IN PTRUSTEE_W pGroup OPTIONAL
,
468 IN ULONG cCountOfAccessEntries
,
469 IN PEXPLICIT_ACCESS pListOfAccessEntries OPTIONAL
,
470 IN ULONG cCountOfAuditEntries
,
471 IN PEXPLICIT_ACCESS pListOfAuditEntries OPTIONAL
,
472 IN PSECURITY_DESCRIPTOR pOldSD OPTIONAL
,
473 OUT PULONG pSizeNewSD
,
474 OUT PSECURITY_DESCRIPTOR
* pNewSD
)
486 BuildSecurityDescriptorA(IN PTRUSTEE_A pOwner OPTIONAL
,
487 IN PTRUSTEE_A pGroup OPTIONAL
,
488 IN ULONG cCountOfAccessEntries
,
489 IN PEXPLICIT_ACCESS pListOfAccessEntries OPTIONAL
,
490 IN ULONG cCountOfAuditEntries
,
491 IN PEXPLICIT_ACCESS pListOfAuditEntries OPTIONAL
,
492 IN PSECURITY_DESCRIPTOR pOldSD OPTIONAL
,
493 OUT PULONG pSizeNewSD
,
494 OUT PSECURITY_DESCRIPTOR
* pNewSD
)