2003-07-10 Casper S. Hornstrup <chorns@users.sourceforge.net>
[reactos.git] / reactos / lib / advapi32 / sec / sec.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/advapi32/sec/sec.c
5 * PURPOSE: Registry functions
6 * PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
7 * Steven Edwards ( Steven_Ed4153@yahoo.com )
8 * UPDATE HISTORY:
9 * Created 01/11/98
10 * Added a few new stubs 6/27/03
11 */
12
13 #define NTOS_MODE_USER
14 #include <ntos.h>
15 #include <windows.h>
16
17
18 /*
19 * @implemented
20 */
21 BOOL
22 STDCALL
23 GetSecurityDescriptorControl (
24 PSECURITY_DESCRIPTOR pSecurityDescriptor,
25 PSECURITY_DESCRIPTOR_CONTROL pControl,
26 LPDWORD lpdwRevision
27 )
28 {
29 NTSTATUS Status;
30
31 Status = RtlGetControlSecurityDescriptor (pSecurityDescriptor,
32 pControl,
33 (PULONG)lpdwRevision);
34 if (!NT_SUCCESS(Status))
35 {
36 SetLastError (RtlNtStatusToDosError (Status));
37 return FALSE;
38 }
39
40 return TRUE;
41 }
42
43
44 /*
45 * @implemented
46 */
47 BOOL
48 STDCALL
49 GetSecurityDescriptorDacl (
50 PSECURITY_DESCRIPTOR pSecurityDescriptor,
51 LPBOOL lpbDaclPresent,
52 PACL *pDacl,
53 LPBOOL lpbDaclDefaulted
54 )
55 {
56 BOOLEAN DaclPresent;
57 BOOLEAN DaclDefaulted;
58 NTSTATUS Status;
59
60 Status = RtlGetDaclSecurityDescriptor (pSecurityDescriptor,
61 &DaclPresent,
62 pDacl,
63 &DaclDefaulted);
64 *lpbDaclPresent = (BOOL)DaclPresent;
65 *lpbDaclDefaulted = (BOOL)DaclDefaulted;
66
67 if (!NT_SUCCESS(Status))
68 {
69 SetLastError (RtlNtStatusToDosError (Status));
70 return FALSE;
71 }
72
73 return TRUE;
74 }
75
76
77 /*
78 * @implemented
79 */
80 BOOL
81 STDCALL
82 GetSecurityDescriptorGroup (
83 PSECURITY_DESCRIPTOR pSecurityDescriptor,
84 PSID *pGroup,
85 LPBOOL lpbGroupDefaulted
86 )
87 {
88 BOOLEAN GroupDefaulted;
89 NTSTATUS Status;
90
91 Status = RtlGetGroupSecurityDescriptor (pSecurityDescriptor,
92 pGroup,
93 &GroupDefaulted);
94 *lpbGroupDefaulted = (BOOL)GroupDefaulted;
95
96 if (!NT_SUCCESS(Status))
97 {
98 SetLastError (RtlNtStatusToDosError (Status));
99 return FALSE;
100 }
101
102 return TRUE;
103 }
104
105
106 /*
107 * @implemented
108 */
109 DWORD
110 STDCALL
111 GetSecurityDescriptorLength (
112 PSECURITY_DESCRIPTOR pSecurityDescriptor
113 )
114 {
115 return RtlLengthSecurityDescriptor(pSecurityDescriptor);
116 }
117
118
119 /*
120 * @implemented
121 */
122 BOOL
123 STDCALL
124 GetSecurityDescriptorOwner (
125 PSECURITY_DESCRIPTOR pSecurityDescriptor,
126 PSID *pOwner,
127 LPBOOL lpbOwnerDefaulted
128 )
129 {
130 BOOLEAN OwnerDefaulted;
131 NTSTATUS Status;
132
133 Status = RtlGetOwnerSecurityDescriptor (pSecurityDescriptor,
134 pOwner,
135 &OwnerDefaulted);
136 *lpbOwnerDefaulted = (BOOL)OwnerDefaulted;
137
138 if (!NT_SUCCESS(Status))
139 {
140 SetLastError (RtlNtStatusToDosError (Status));
141 return FALSE;
142 }
143
144 return TRUE;
145 }
146
147
148 /*
149 * @implemented
150 */
151 BOOL
152 STDCALL
153 GetSecurityDescriptorSacl (
154 PSECURITY_DESCRIPTOR pSecurityDescriptor,
155 LPBOOL lpbSaclPresent,
156 PACL *pSacl,
157 LPBOOL lpbSaclDefaulted
158 )
159 {
160 BOOLEAN SaclPresent;
161 BOOLEAN SaclDefaulted;
162 NTSTATUS Status;
163
164 Status = RtlGetSaclSecurityDescriptor (pSecurityDescriptor,
165 &SaclPresent,
166 pSacl,
167 &SaclDefaulted);
168 *lpbSaclPresent = (BOOL)SaclPresent;
169 *lpbSaclDefaulted = (BOOL)SaclDefaulted;
170
171 if (!NT_SUCCESS(Status))
172 {
173 SetLastError (RtlNtStatusToDosError (Status));
174 return FALSE;
175 }
176
177 return TRUE;
178 }
179
180
181 /*
182 * @implemented
183 */
184 BOOL
185 STDCALL
186 InitializeSecurityDescriptor (
187 PSECURITY_DESCRIPTOR pSecurityDescriptor,
188 DWORD dwRevision
189 )
190 {
191 NTSTATUS Status;
192
193 Status = RtlCreateSecurityDescriptor (pSecurityDescriptor,
194 dwRevision);
195 if (!NT_SUCCESS(Status))
196 {
197 SetLastError (RtlNtStatusToDosError (Status));
198 return FALSE;
199 }
200
201 return TRUE;
202 }
203
204
205 /*
206 * @implemented
207 */
208 BOOL
209 STDCALL
210 IsValidSecurityDescriptor (
211 PSECURITY_DESCRIPTOR pSecurityDescriptor
212 )
213 {
214 BOOLEAN Result;
215
216 Result = RtlValidSecurityDescriptor (pSecurityDescriptor);
217 if (Result == FALSE)
218 SetLastError (RtlNtStatusToDosError (STATUS_INVALID_SECURITY_DESCR));
219
220 return (BOOL)Result;
221 }
222
223
224 /*
225 * @implemented
226 */
227 WINBOOL
228 STDCALL
229 MakeAbsoluteSD (
230 PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
231 PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
232 LPDWORD lpdwAbsoluteSecurityDescriptorSize,
233 PACL pDacl,
234 LPDWORD lpdwDaclSize,
235 PACL pSacl,
236 LPDWORD lpdwSaclSize,
237 PSID pOwner,
238 LPDWORD lpdwOwnerSize,
239 PSID pPrimaryGroup,
240 LPDWORD lpdwPrimaryGroupSize
241 )
242 {
243 NTSTATUS Status;
244
245 Status = RtlSelfRelativeToAbsoluteSD (pSelfRelativeSecurityDescriptor,
246 pAbsoluteSecurityDescriptor,
247 lpdwAbsoluteSecurityDescriptorSize,
248 pDacl,
249 lpdwDaclSize,
250 pSacl,
251 lpdwSaclSize,
252 pOwner,
253 lpdwOwnerSize,
254 pPrimaryGroup,
255 lpdwPrimaryGroupSize);
256 if (!NT_SUCCESS(Status))
257 {
258 SetLastError (RtlNtStatusToDosError (Status));
259 return FALSE;
260 }
261
262 return TRUE;
263 }
264
265
266 /*
267 * @implemented
268 */
269 WINBOOL
270 STDCALL
271 MakeSelfRelativeSD (
272 PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
273 PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
274 LPDWORD lpdwBufferLength
275 )
276 {
277 NTSTATUS Status;
278
279 Status = RtlAbsoluteToSelfRelativeSD (pAbsoluteSecurityDescriptor,
280 pSelfRelativeSecurityDescriptor,
281 (PULONG)lpdwBufferLength);
282 if (!NT_SUCCESS(Status))
283 {
284 SetLastError (RtlNtStatusToDosError (Status));
285 return FALSE;
286 }
287
288 return TRUE;
289 }
290
291
292 /*
293 * @implemented
294 */
295 BOOL
296 STDCALL
297 SetSecurityDescriptorDacl (
298 PSECURITY_DESCRIPTOR pSecurityDescriptor,
299 BOOL bDaclPresent,
300 PACL pDacl,
301 BOOL bDaclDefaulted
302 )
303 {
304 NTSTATUS Status;
305
306 Status = RtlSetDaclSecurityDescriptor (pSecurityDescriptor,
307 bDaclPresent,
308 pDacl,
309 bDaclDefaulted);
310 if (!NT_SUCCESS(Status))
311 {
312 SetLastError (RtlNtStatusToDosError (Status));
313 return FALSE;
314 }
315
316 return TRUE;
317 }
318
319
320 /*
321 * @implemented
322 */
323 BOOL
324 STDCALL
325 SetSecurityDescriptorGroup (
326 PSECURITY_DESCRIPTOR pSecurityDescriptor,
327 PSID pGroup,
328 BOOL bGroupDefaulted
329 )
330 {
331 NTSTATUS Status;
332
333 Status = RtlSetGroupSecurityDescriptor (pSecurityDescriptor,
334 pGroup,
335 bGroupDefaulted);
336 if (!NT_SUCCESS(Status))
337 {
338 SetLastError (RtlNtStatusToDosError (Status));
339 return FALSE;
340 }
341
342 return TRUE;
343 }
344
345
346 /*
347 * @implemented
348 */
349 BOOL
350 STDCALL
351 SetSecurityDescriptorOwner (
352 PSECURITY_DESCRIPTOR pSecurityDescriptor,
353 PSID pOwner,
354 BOOL bOwnerDefaulted
355 )
356 {
357 NTSTATUS Status;
358
359 Status = RtlSetGroupSecurityDescriptor (pSecurityDescriptor,
360 pOwner,
361 bOwnerDefaulted);
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 SetSecurityDescriptorSacl (
378 PSECURITY_DESCRIPTOR pSecurityDescriptor,
379 BOOL bSaclPresent,
380 PACL pSacl,
381 BOOL bSaclDefaulted
382 )
383 {
384 NTSTATUS Status;
385
386 Status = RtlSetSaclSecurityDescriptor (pSecurityDescriptor,
387 bSaclPresent,
388 pSacl,
389 bSaclDefaulted);
390 if (!NT_SUCCESS(Status))
391 {
392 SetLastError (RtlNtStatusToDosError (Status));
393 return FALSE;
394 }
395
396 return TRUE;
397 }
398
399
400 /*
401 * @unimplemented
402 */
403 BOOL STDCALL
404 GetUserNameA(LPSTR lpBuffer, LPDWORD nSize)
405 {
406 return(FALSE);
407 }
408
409
410 /*
411 * @unimplemented
412 */
413 BOOL STDCALL
414 GetUserNameW(LPWSTR lpBuffer, LPDWORD nSize)
415 {
416 return(FALSE);
417 }
418
419
420 /*
421 * @unimplemented
422 */
423 WINBOOL
424 STDCALL
425 GetFileSecurityA (
426 LPCSTR lpFileName,
427 SECURITY_INFORMATION RequestedInformation,
428 PSECURITY_DESCRIPTOR pSecurityDescriptor,
429 DWORD nLength,
430 LPDWORD lpnLengthNeeded
431 )
432 {
433 return(FALSE);
434 }
435
436
437 /*
438 * @unimplemented
439 */
440 WINBOOL
441 STDCALL
442 GetFileSecurityW (
443 LPCWSTR lpFileName,
444 SECURITY_INFORMATION RequestedInformation,
445 PSECURITY_DESCRIPTOR pSecurityDescriptor,
446 DWORD nLength,
447 LPDWORD lpnLengthNeeded
448 )
449 {
450 return(FALSE);
451 }
452
453
454 /*
455 * @unimplemented
456 */
457 WINBOOL
458 STDCALL
459 SetFileSecurityA (
460 LPCSTR lpFileName,
461 SECURITY_INFORMATION SecurityInformation,
462 PSECURITY_DESCRIPTOR pSecurityDescriptor
463 )
464 {
465 return(FALSE);
466 }
467 /* EOF */