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 )
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 GetSecurityDescriptorOwner (
113 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
115 LPBOOL lpbOwnerDefaulted
118 BOOLEAN OwnerDefaulted
;
121 Status
= RtlGetOwnerSecurityDescriptor (pSecurityDescriptor
,
124 *lpbOwnerDefaulted
= (BOOL
)OwnerDefaulted
;
126 if (!NT_SUCCESS(Status
))
128 SetLastError (RtlNtStatusToDosError (Status
));
141 GetSecurityDescriptorRMControl (
142 PSECURITY_DESCRIPTOR SecurityDescriptor
,
145 if (!RtlGetSecurityDescriptorRMControl(SecurityDescriptor
,
147 return ERROR_INVALID_DATA
;
149 return ERROR_SUCCESS
;
158 GetSecurityDescriptorSacl (
159 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
160 LPBOOL lpbSaclPresent
,
162 LPBOOL lpbSaclDefaulted
166 BOOLEAN SaclDefaulted
;
169 Status
= RtlGetSaclSecurityDescriptor (pSecurityDescriptor
,
173 *lpbSaclPresent
= (BOOL
)SaclPresent
;
174 *lpbSaclDefaulted
= (BOOL
)SaclDefaulted
;
176 if (!NT_SUCCESS(Status
))
178 SetLastError (RtlNtStatusToDosError (Status
));
191 InitializeSecurityDescriptor (
192 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
198 Status
= RtlCreateSecurityDescriptor (pSecurityDescriptor
,
200 if (!NT_SUCCESS(Status
))
202 SetLastError (RtlNtStatusToDosError (Status
));
215 IsValidSecurityDescriptor (
216 PSECURITY_DESCRIPTOR pSecurityDescriptor
221 Result
= RtlValidSecurityDescriptor (pSecurityDescriptor
);
223 SetLastError (RtlNtStatusToDosError (STATUS_INVALID_SECURITY_DESCR
));
235 PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor
,
236 PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor
,
237 LPDWORD lpdwAbsoluteSecurityDescriptorSize
,
239 LPDWORD lpdwDaclSize
,
241 LPDWORD lpdwSaclSize
,
243 LPDWORD lpdwOwnerSize
,
245 LPDWORD lpdwPrimaryGroupSize
250 Status
= RtlSelfRelativeToAbsoluteSD (pSelfRelativeSecurityDescriptor
,
251 pAbsoluteSecurityDescriptor
,
252 lpdwAbsoluteSecurityDescriptorSize
,
260 lpdwPrimaryGroupSize
);
261 if (!NT_SUCCESS(Status
))
263 SetLastError (RtlNtStatusToDosError (Status
));
276 MakeAbsoluteSD2(IN OUT PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor
,
277 OUT LPDWORD lpdwBufferSize
)
281 Status
= RtlSelfRelativeToAbsoluteSD2(pSelfRelativeSecurityDescriptor
,
283 if (!NT_SUCCESS(Status
))
285 SetLastError (RtlNtStatusToDosError (Status
));
299 PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor
,
300 PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor
,
301 LPDWORD lpdwBufferLength
306 Status
= RtlAbsoluteToSelfRelativeSD (pAbsoluteSecurityDescriptor
,
307 pSelfRelativeSecurityDescriptor
,
308 (PULONG
)lpdwBufferLength
);
309 if (!NT_SUCCESS(Status
))
311 SetLastError (RtlNtStatusToDosError (Status
));
324 SetSecurityDescriptorControl (
325 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
326 SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest
,
327 SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet
)
331 Status
= RtlSetControlSecurityDescriptor(pSecurityDescriptor
,
332 ControlBitsOfInterest
,
334 if (!NT_SUCCESS(Status
))
336 SetLastError (RtlNtStatusToDosError (Status
));
349 SetSecurityDescriptorDacl (
350 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
358 Status
= RtlSetDaclSecurityDescriptor (pSecurityDescriptor
,
362 if (!NT_SUCCESS(Status
))
364 SetLastError (RtlNtStatusToDosError (Status
));
377 SetSecurityDescriptorGroup (
378 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
385 Status
= RtlSetGroupSecurityDescriptor (pSecurityDescriptor
,
388 if (!NT_SUCCESS(Status
))
390 SetLastError (RtlNtStatusToDosError (Status
));
403 SetSecurityDescriptorOwner (
404 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
411 Status
= RtlSetOwnerSecurityDescriptor (pSecurityDescriptor
,
414 if (!NT_SUCCESS(Status
))
416 SetLastError (RtlNtStatusToDosError (Status
));
429 SetSecurityDescriptorRMControl (
430 PSECURITY_DESCRIPTOR SecurityDescriptor
,
433 RtlSetSecurityDescriptorRMControl(SecurityDescriptor
,
436 return ERROR_SUCCESS
;
445 SetSecurityDescriptorSacl (
446 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
454 Status
= RtlSetSaclSecurityDescriptor (pSecurityDescriptor
,
458 if (!NT_SUCCESS(Status
))
460 SetLastError (RtlNtStatusToDosError (Status
));
473 ConvertToAutoInheritPrivateObjectSecurity(IN PSECURITY_DESCRIPTOR ParentDescriptor
,
474 IN PSECURITY_DESCRIPTOR CurrentSecurityDescriptor
,
475 OUT PSECURITY_DESCRIPTOR
* NewSecurityDescriptor
,
477 IN BOOLEAN IsDirectoryObject
,
478 IN PGENERIC_MAPPING GenericMapping
)
490 BuildSecurityDescriptorW(IN PTRUSTEE_W pOwner OPTIONAL
,
491 IN PTRUSTEE_W pGroup OPTIONAL
,
492 IN ULONG cCountOfAccessEntries
,
493 IN PEXPLICIT_ACCESS pListOfAccessEntries OPTIONAL
,
494 IN ULONG cCountOfAuditEntries
,
495 IN PEXPLICIT_ACCESS pListOfAuditEntries OPTIONAL
,
496 IN PSECURITY_DESCRIPTOR pOldSD OPTIONAL
,
497 OUT PULONG pSizeNewSD
,
498 OUT PSECURITY_DESCRIPTOR
* pNewSD
)
510 BuildSecurityDescriptorA(IN PTRUSTEE_A pOwner OPTIONAL
,
511 IN PTRUSTEE_A pGroup OPTIONAL
,
512 IN ULONG cCountOfAccessEntries
,
513 IN PEXPLICIT_ACCESS pListOfAccessEntries OPTIONAL
,
514 IN ULONG cCountOfAuditEntries
,
515 IN PEXPLICIT_ACCESS pListOfAuditEntries OPTIONAL
,
516 IN PSECURITY_DESCRIPTOR pOldSD OPTIONAL
,
517 OUT PULONG pSizeNewSD
,
518 OUT PSECURITY_DESCRIPTOR
* pNewSD
)
528 BOOL WINAPI
DecryptFileW(LPCWSTR lpFileName
, DWORD dwReserved
)
530 DPRINT1("%s() not implemented!\n", __FUNCTION__
);
531 return ERROR_CALL_NOT_IMPLEMENTED
;
537 BOOL WINAPI
DecryptFileA(LPCSTR lpFileName
, DWORD dwReserved
)
539 DPRINT1("%s() not implemented!\n", __FUNCTION__
);
540 return ERROR_CALL_NOT_IMPLEMENTED
;
546 BOOL WINAPI
EncryptFileW(LPCWSTR lpFileName
)
548 DPRINT1("%s() not implemented!\n", __FUNCTION__
);
549 return ERROR_CALL_NOT_IMPLEMENTED
;
555 BOOL WINAPI
EncryptFileA(LPCSTR lpFileName
)
557 DPRINT1("%s() not implemented!\n", __FUNCTION__
);
558 return ERROR_CALL_NOT_IMPLEMENTED
;
561 BOOL WINAPI
ConvertSecurityDescriptorToStringSecurityDescriptorW(
562 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
564 SECURITY_INFORMATION SecurityInformation
,
568 DPRINT1("%s() not implemented!\n", __FUNCTION__
);
569 return ERROR_CALL_NOT_IMPLEMENTED
;
572 BOOL WINAPI
ConvertSecurityDescriptorToStringSecurityDescriptorA(
573 PSECURITY_DESCRIPTOR pSecurityDescriptor
,
575 SECURITY_INFORMATION SecurityInformation
,
579 DPRINT1("%s() not implemented!\n", __FUNCTION__
);
580 return ERROR_CALL_NOT_IMPLEMENTED
;