implemented some stubs needed by ClamWin
[reactos.git] / reactos / lib / advapi32 / sec / sec.c
1 /* $Id$
2 *
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 )
10 * UPDATE HISTORY:
11 * Created 01/11/98
12 */
13
14 #include <advapi32.h>
15
16 #define NDEBUG
17 #include <debug.h>
18
19 /*
20 * @implemented
21 */
22 BOOL
23 STDCALL
24 GetSecurityDescriptorControl (
25 PSECURITY_DESCRIPTOR pSecurityDescriptor,
26 PSECURITY_DESCRIPTOR_CONTROL pControl,
27 LPDWORD lpdwRevision
28 )
29 {
30 NTSTATUS Status;
31
32 Status = RtlGetControlSecurityDescriptor (pSecurityDescriptor,
33 pControl,
34 (PULONG)lpdwRevision);
35 if (!NT_SUCCESS(Status))
36 {
37 SetLastError (RtlNtStatusToDosError (Status));
38 return FALSE;
39 }
40
41 return TRUE;
42 }
43
44
45 /*
46 * @implemented
47 */
48 BOOL
49 STDCALL
50 GetSecurityDescriptorDacl (
51 PSECURITY_DESCRIPTOR pSecurityDescriptor,
52 LPBOOL lpbDaclPresent,
53 PACL *pDacl,
54 LPBOOL lpbDaclDefaulted
55 )
56 {
57 BOOLEAN DaclPresent;
58 BOOLEAN DaclDefaulted;
59 NTSTATUS Status;
60
61 Status = RtlGetDaclSecurityDescriptor (pSecurityDescriptor,
62 &DaclPresent,
63 pDacl,
64 &DaclDefaulted);
65 *lpbDaclPresent = (BOOL)DaclPresent;
66 *lpbDaclDefaulted = (BOOL)DaclDefaulted;
67
68 if (!NT_SUCCESS(Status))
69 {
70 SetLastError (RtlNtStatusToDosError (Status));
71 return FALSE;
72 }
73
74 return TRUE;
75 }
76
77
78 /*
79 * @implemented
80 */
81 BOOL
82 STDCALL
83 GetSecurityDescriptorGroup (
84 PSECURITY_DESCRIPTOR pSecurityDescriptor,
85 PSID *pGroup,
86 LPBOOL lpbGroupDefaulted
87 )
88 {
89 BOOLEAN GroupDefaulted;
90 NTSTATUS Status;
91
92 Status = RtlGetGroupSecurityDescriptor (pSecurityDescriptor,
93 pGroup,
94 &GroupDefaulted);
95 *lpbGroupDefaulted = (BOOL)GroupDefaulted;
96
97 if (!NT_SUCCESS(Status))
98 {
99 SetLastError (RtlNtStatusToDosError (Status));
100 return FALSE;
101 }
102
103 return TRUE;
104 }
105
106
107 /*
108 * @implemented
109 */
110 BOOL
111 STDCALL
112 GetSecurityDescriptorOwner (
113 PSECURITY_DESCRIPTOR pSecurityDescriptor,
114 PSID *pOwner,
115 LPBOOL lpbOwnerDefaulted
116 )
117 {
118 BOOLEAN OwnerDefaulted;
119 NTSTATUS Status;
120
121 Status = RtlGetOwnerSecurityDescriptor (pSecurityDescriptor,
122 pOwner,
123 &OwnerDefaulted);
124 *lpbOwnerDefaulted = (BOOL)OwnerDefaulted;
125
126 if (!NT_SUCCESS(Status))
127 {
128 SetLastError (RtlNtStatusToDosError (Status));
129 return FALSE;
130 }
131
132 return TRUE;
133 }
134
135
136 /*
137 * @implemented
138 */
139 DWORD
140 STDCALL
141 GetSecurityDescriptorRMControl (
142 PSECURITY_DESCRIPTOR SecurityDescriptor,
143 PUCHAR RMControl)
144 {
145 if (!RtlGetSecurityDescriptorRMControl(SecurityDescriptor,
146 RMControl))
147 return ERROR_INVALID_DATA;
148
149 return ERROR_SUCCESS;
150 }
151
152
153 /*
154 * @implemented
155 */
156 BOOL
157 STDCALL
158 GetSecurityDescriptorSacl (
159 PSECURITY_DESCRIPTOR pSecurityDescriptor,
160 LPBOOL lpbSaclPresent,
161 PACL *pSacl,
162 LPBOOL lpbSaclDefaulted
163 )
164 {
165 BOOLEAN SaclPresent;
166 BOOLEAN SaclDefaulted;
167 NTSTATUS Status;
168
169 Status = RtlGetSaclSecurityDescriptor (pSecurityDescriptor,
170 &SaclPresent,
171 pSacl,
172 &SaclDefaulted);
173 *lpbSaclPresent = (BOOL)SaclPresent;
174 *lpbSaclDefaulted = (BOOL)SaclDefaulted;
175
176 if (!NT_SUCCESS(Status))
177 {
178 SetLastError (RtlNtStatusToDosError (Status));
179 return FALSE;
180 }
181
182 return TRUE;
183 }
184
185
186 /*
187 * @implemented
188 */
189 BOOL
190 STDCALL
191 InitializeSecurityDescriptor (
192 PSECURITY_DESCRIPTOR pSecurityDescriptor,
193 DWORD dwRevision
194 )
195 {
196 NTSTATUS Status;
197
198 Status = RtlCreateSecurityDescriptor (pSecurityDescriptor,
199 dwRevision);
200 if (!NT_SUCCESS(Status))
201 {
202 SetLastError (RtlNtStatusToDosError (Status));
203 return FALSE;
204 }
205
206 return TRUE;
207 }
208
209
210 /*
211 * @implemented
212 */
213 BOOL
214 STDCALL
215 IsValidSecurityDescriptor (
216 PSECURITY_DESCRIPTOR pSecurityDescriptor
217 )
218 {
219 BOOLEAN Result;
220
221 Result = RtlValidSecurityDescriptor (pSecurityDescriptor);
222 if (Result == FALSE)
223 SetLastError (RtlNtStatusToDosError (STATUS_INVALID_SECURITY_DESCR));
224
225 return (BOOL)Result;
226 }
227
228
229 /*
230 * @implemented
231 */
232 BOOL
233 STDCALL
234 MakeAbsoluteSD (
235 PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
236 PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
237 LPDWORD lpdwAbsoluteSecurityDescriptorSize,
238 PACL pDacl,
239 LPDWORD lpdwDaclSize,
240 PACL pSacl,
241 LPDWORD lpdwSaclSize,
242 PSID pOwner,
243 LPDWORD lpdwOwnerSize,
244 PSID pPrimaryGroup,
245 LPDWORD lpdwPrimaryGroupSize
246 )
247 {
248 NTSTATUS Status;
249
250 Status = RtlSelfRelativeToAbsoluteSD (pSelfRelativeSecurityDescriptor,
251 pAbsoluteSecurityDescriptor,
252 lpdwAbsoluteSecurityDescriptorSize,
253 pDacl,
254 lpdwDaclSize,
255 pSacl,
256 lpdwSaclSize,
257 pOwner,
258 lpdwOwnerSize,
259 pPrimaryGroup,
260 lpdwPrimaryGroupSize);
261 if (!NT_SUCCESS(Status))
262 {
263 SetLastError (RtlNtStatusToDosError (Status));
264 return FALSE;
265 }
266
267 return TRUE;
268 }
269
270
271 /*
272 * @implemented
273 */
274 BOOL
275 STDCALL
276 MakeAbsoluteSD2(IN OUT PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
277 OUT LPDWORD lpdwBufferSize)
278 {
279 NTSTATUS Status;
280
281 Status = RtlSelfRelativeToAbsoluteSD2(pSelfRelativeSecurityDescriptor,
282 lpdwBufferSize);
283 if (!NT_SUCCESS(Status))
284 {
285 SetLastError (RtlNtStatusToDosError (Status));
286 return FALSE;
287 }
288
289 return TRUE;
290 }
291
292
293 /*
294 * @implemented
295 */
296 BOOL
297 STDCALL
298 MakeSelfRelativeSD (
299 PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
300 PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
301 LPDWORD lpdwBufferLength
302 )
303 {
304 NTSTATUS Status;
305
306 Status = RtlAbsoluteToSelfRelativeSD (pAbsoluteSecurityDescriptor,
307 pSelfRelativeSecurityDescriptor,
308 (PULONG)lpdwBufferLength);
309 if (!NT_SUCCESS(Status))
310 {
311 SetLastError (RtlNtStatusToDosError (Status));
312 return FALSE;
313 }
314
315 return TRUE;
316 }
317
318
319 /*
320 * @implemented
321 */
322 BOOL
323 STDCALL
324 SetSecurityDescriptorControl (
325 PSECURITY_DESCRIPTOR pSecurityDescriptor,
326 SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest,
327 SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet)
328 {
329 NTSTATUS Status;
330
331 Status = RtlSetControlSecurityDescriptor(pSecurityDescriptor,
332 ControlBitsOfInterest,
333 ControlBitsToSet);
334 if (!NT_SUCCESS(Status))
335 {
336 SetLastError (RtlNtStatusToDosError (Status));
337 return FALSE;
338 }
339
340 return TRUE;
341 }
342
343
344 /*
345 * @implemented
346 */
347 BOOL
348 STDCALL
349 SetSecurityDescriptorDacl (
350 PSECURITY_DESCRIPTOR pSecurityDescriptor,
351 BOOL bDaclPresent,
352 PACL pDacl,
353 BOOL bDaclDefaulted
354 )
355 {
356 NTSTATUS Status;
357
358 Status = RtlSetDaclSecurityDescriptor (pSecurityDescriptor,
359 bDaclPresent,
360 pDacl,
361 bDaclDefaulted);
362 if (!NT_SUCCESS(Status))
363 {
364 SetLastError (RtlNtStatusToDosError (Status));
365 return FALSE;
366 }
367
368 return TRUE;
369 }
370
371
372 /*
373 * @implemented
374 */
375 BOOL
376 STDCALL
377 SetSecurityDescriptorGroup (
378 PSECURITY_DESCRIPTOR pSecurityDescriptor,
379 PSID pGroup,
380 BOOL bGroupDefaulted
381 )
382 {
383 NTSTATUS Status;
384
385 Status = RtlSetGroupSecurityDescriptor (pSecurityDescriptor,
386 pGroup,
387 bGroupDefaulted);
388 if (!NT_SUCCESS(Status))
389 {
390 SetLastError (RtlNtStatusToDosError (Status));
391 return FALSE;
392 }
393
394 return TRUE;
395 }
396
397
398 /*
399 * @implemented
400 */
401 BOOL
402 STDCALL
403 SetSecurityDescriptorOwner (
404 PSECURITY_DESCRIPTOR pSecurityDescriptor,
405 PSID pOwner,
406 BOOL bOwnerDefaulted
407 )
408 {
409 NTSTATUS Status;
410
411 Status = RtlSetOwnerSecurityDescriptor (pSecurityDescriptor,
412 pOwner,
413 bOwnerDefaulted);
414 if (!NT_SUCCESS(Status))
415 {
416 SetLastError (RtlNtStatusToDosError (Status));
417 return FALSE;
418 }
419
420 return TRUE;
421 }
422
423
424 /*
425 * @implemented
426 */
427 DWORD
428 STDCALL
429 SetSecurityDescriptorRMControl (
430 PSECURITY_DESCRIPTOR SecurityDescriptor,
431 PUCHAR RMControl)
432 {
433 RtlSetSecurityDescriptorRMControl(SecurityDescriptor,
434 RMControl);
435
436 return ERROR_SUCCESS;
437 }
438
439
440 /*
441 * @implemented
442 */
443 BOOL
444 STDCALL
445 SetSecurityDescriptorSacl (
446 PSECURITY_DESCRIPTOR pSecurityDescriptor,
447 BOOL bSaclPresent,
448 PACL pSacl,
449 BOOL bSaclDefaulted
450 )
451 {
452 NTSTATUS Status;
453
454 Status = RtlSetSaclSecurityDescriptor (pSecurityDescriptor,
455 bSaclPresent,
456 pSacl,
457 bSaclDefaulted);
458 if (!NT_SUCCESS(Status))
459 {
460 SetLastError (RtlNtStatusToDosError (Status));
461 return FALSE;
462 }
463
464 return TRUE;
465 }
466
467
468 /*
469 * @unimplemented
470 */
471 BOOL
472 STDCALL
473 ConvertToAutoInheritPrivateObjectSecurity(IN PSECURITY_DESCRIPTOR ParentDescriptor,
474 IN PSECURITY_DESCRIPTOR CurrentSecurityDescriptor,
475 OUT PSECURITY_DESCRIPTOR* NewSecurityDescriptor,
476 IN GUID* ObjectType,
477 IN BOOLEAN IsDirectoryObject,
478 IN PGENERIC_MAPPING GenericMapping)
479 {
480 UNIMPLEMENTED;
481 return FALSE;
482 }
483
484
485 /*
486 * @unimplemented
487 */
488 DWORD
489 STDCALL
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)
499 {
500 UNIMPLEMENTED;
501 return FALSE;
502 }
503
504
505 /*
506 * @unimplemented
507 */
508 DWORD
509 STDCALL
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)
519 {
520 UNIMPLEMENTED;
521 return FALSE;
522 }
523
524
525 /*
526 * @unimplemented
527 */
528 BOOL WINAPI DecryptFileW(LPCWSTR lpFileName, DWORD dwReserved)
529 {
530 DPRINT1("%s() not implemented!\n", __FUNCTION__);
531 return ERROR_CALL_NOT_IMPLEMENTED;
532 }
533
534 /*
535 * @unimplemented
536 */
537 BOOL WINAPI DecryptFileA(LPCSTR lpFileName, DWORD dwReserved)
538 {
539 DPRINT1("%s() not implemented!\n", __FUNCTION__);
540 return ERROR_CALL_NOT_IMPLEMENTED;
541 }
542
543 /*
544 * @unimplemented
545 */
546 BOOL WINAPI EncryptFileW(LPCWSTR lpFileName)
547 {
548 DPRINT1("%s() not implemented!\n", __FUNCTION__);
549 return ERROR_CALL_NOT_IMPLEMENTED;
550 }
551
552 /*
553 * @unimplemented
554 */
555 BOOL WINAPI EncryptFileA(LPCSTR lpFileName)
556 {
557 DPRINT1("%s() not implemented!\n", __FUNCTION__);
558 return ERROR_CALL_NOT_IMPLEMENTED;
559 }
560
561 BOOL WINAPI ConvertSecurityDescriptorToStringSecurityDescriptorW(
562 PSECURITY_DESCRIPTOR pSecurityDescriptor,
563 DWORD dword,
564 SECURITY_INFORMATION SecurityInformation,
565 LPWSTR* lpwstr,
566 PULONG pulong)
567 {
568 DPRINT1("%s() not implemented!\n", __FUNCTION__);
569 return ERROR_CALL_NOT_IMPLEMENTED;
570 }
571
572 BOOL WINAPI ConvertSecurityDescriptorToStringSecurityDescriptorA(
573 PSECURITY_DESCRIPTOR pSecurityDescriptor,
574 DWORD dword,
575 SECURITY_INFORMATION SecurityInformation,
576 LPSTR* lpstr,
577 PULONG pulong)
578 {
579 DPRINT1("%s() not implemented!\n", __FUNCTION__);
580 return ERROR_CALL_NOT_IMPLEMENTED;
581 }
582
583 /* EOF */