Remove ALL stubs which might be of questionable origin.
[reactos.git] / reactos / lib / advapi32 / sec / sec.c
1 /* $Id: sec.c,v 1.18 2004/02/25 14:25:11 ekohl Exp $
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 #define NTOS_MODE_USER
15 #include <windows.h>
16 #include <ntos.h>
17
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 DWORD
111 STDCALL
112 GetSecurityDescriptorLength (
113 PSECURITY_DESCRIPTOR pSecurityDescriptor
114 )
115 {
116 return RtlLengthSecurityDescriptor(pSecurityDescriptor);
117 }
118
119
120 /*
121 * @implemented
122 */
123 BOOL
124 STDCALL
125 GetSecurityDescriptorOwner (
126 PSECURITY_DESCRIPTOR pSecurityDescriptor,
127 PSID *pOwner,
128 LPBOOL lpbOwnerDefaulted
129 )
130 {
131 BOOLEAN OwnerDefaulted;
132 NTSTATUS Status;
133
134 Status = RtlGetOwnerSecurityDescriptor (pSecurityDescriptor,
135 pOwner,
136 &OwnerDefaulted);
137 *lpbOwnerDefaulted = (BOOL)OwnerDefaulted;
138
139 if (!NT_SUCCESS(Status))
140 {
141 SetLastError (RtlNtStatusToDosError (Status));
142 return FALSE;
143 }
144
145 return TRUE;
146 }
147
148
149 /*
150 * @implemented
151 */
152 BOOL
153 STDCALL
154 GetSecurityDescriptorSacl (
155 PSECURITY_DESCRIPTOR pSecurityDescriptor,
156 LPBOOL lpbSaclPresent,
157 PACL *pSacl,
158 LPBOOL lpbSaclDefaulted
159 )
160 {
161 BOOLEAN SaclPresent;
162 BOOLEAN SaclDefaulted;
163 NTSTATUS Status;
164
165 Status = RtlGetSaclSecurityDescriptor (pSecurityDescriptor,
166 &SaclPresent,
167 pSacl,
168 &SaclDefaulted);
169 *lpbSaclPresent = (BOOL)SaclPresent;
170 *lpbSaclDefaulted = (BOOL)SaclDefaulted;
171
172 if (!NT_SUCCESS(Status))
173 {
174 SetLastError (RtlNtStatusToDosError (Status));
175 return FALSE;
176 }
177
178 return TRUE;
179 }
180
181
182 /*
183 * @implemented
184 */
185 BOOL
186 STDCALL
187 InitializeSecurityDescriptor (
188 PSECURITY_DESCRIPTOR pSecurityDescriptor,
189 DWORD dwRevision
190 )
191 {
192 NTSTATUS Status;
193
194 Status = RtlCreateSecurityDescriptor (pSecurityDescriptor,
195 dwRevision);
196 if (!NT_SUCCESS(Status))
197 {
198 SetLastError (RtlNtStatusToDosError (Status));
199 return FALSE;
200 }
201
202 return TRUE;
203 }
204
205
206 /*
207 * @implemented
208 */
209 BOOL
210 STDCALL
211 IsValidSecurityDescriptor (
212 PSECURITY_DESCRIPTOR pSecurityDescriptor
213 )
214 {
215 BOOLEAN Result;
216
217 Result = RtlValidSecurityDescriptor (pSecurityDescriptor);
218 if (Result == FALSE)
219 SetLastError (RtlNtStatusToDosError (STATUS_INVALID_SECURITY_DESCR));
220
221 return (BOOL)Result;
222 }
223
224
225 /*
226 * @implemented
227 */
228 BOOL
229 STDCALL
230 MakeAbsoluteSD (
231 PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
232 PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
233 LPDWORD lpdwAbsoluteSecurityDescriptorSize,
234 PACL pDacl,
235 LPDWORD lpdwDaclSize,
236 PACL pSacl,
237 LPDWORD lpdwSaclSize,
238 PSID pOwner,
239 LPDWORD lpdwOwnerSize,
240 PSID pPrimaryGroup,
241 LPDWORD lpdwPrimaryGroupSize
242 )
243 {
244 NTSTATUS Status;
245
246 Status = RtlSelfRelativeToAbsoluteSD (pSelfRelativeSecurityDescriptor,
247 pAbsoluteSecurityDescriptor,
248 lpdwAbsoluteSecurityDescriptorSize,
249 pDacl,
250 lpdwDaclSize,
251 pSacl,
252 lpdwSaclSize,
253 pOwner,
254 lpdwOwnerSize,
255 pPrimaryGroup,
256 lpdwPrimaryGroupSize);
257 if (!NT_SUCCESS(Status))
258 {
259 SetLastError (RtlNtStatusToDosError (Status));
260 return FALSE;
261 }
262
263 return TRUE;
264 }
265
266
267 /*
268 * @implemented
269 */
270 BOOL
271 STDCALL
272 MakeSelfRelativeSD (
273 PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor,
274 PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor,
275 LPDWORD lpdwBufferLength
276 )
277 {
278 NTSTATUS Status;
279
280 Status = RtlAbsoluteToSelfRelativeSD (pAbsoluteSecurityDescriptor,
281 pSelfRelativeSecurityDescriptor,
282 (PULONG)lpdwBufferLength);
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 SetSecurityDescriptorDacl (
299 PSECURITY_DESCRIPTOR pSecurityDescriptor,
300 BOOL bDaclPresent,
301 PACL pDacl,
302 BOOL bDaclDefaulted
303 )
304 {
305 NTSTATUS Status;
306
307 Status = RtlSetDaclSecurityDescriptor (pSecurityDescriptor,
308 bDaclPresent,
309 pDacl,
310 bDaclDefaulted);
311 if (!NT_SUCCESS(Status))
312 {
313 SetLastError (RtlNtStatusToDosError (Status));
314 return FALSE;
315 }
316
317 return TRUE;
318 }
319
320
321 /*
322 * @implemented
323 */
324 BOOL
325 STDCALL
326 SetSecurityDescriptorGroup (
327 PSECURITY_DESCRIPTOR pSecurityDescriptor,
328 PSID pGroup,
329 BOOL bGroupDefaulted
330 )
331 {
332 NTSTATUS Status;
333
334 Status = RtlSetGroupSecurityDescriptor (pSecurityDescriptor,
335 pGroup,
336 bGroupDefaulted);
337 if (!NT_SUCCESS(Status))
338 {
339 SetLastError (RtlNtStatusToDosError (Status));
340 return FALSE;
341 }
342
343 return TRUE;
344 }
345
346
347 /*
348 * @implemented
349 */
350 BOOL
351 STDCALL
352 SetSecurityDescriptorOwner (
353 PSECURITY_DESCRIPTOR pSecurityDescriptor,
354 PSID pOwner,
355 BOOL bOwnerDefaulted
356 )
357 {
358 NTSTATUS Status;
359
360 Status = RtlSetGroupSecurityDescriptor (pSecurityDescriptor,
361 pOwner,
362 bOwnerDefaulted);
363 if (!NT_SUCCESS(Status))
364 {
365 SetLastError (RtlNtStatusToDosError (Status));
366 return FALSE;
367 }
368
369 return TRUE;
370 }
371
372
373 /*
374 * @implemented
375 */
376 BOOL
377 STDCALL
378 SetSecurityDescriptorSacl (
379 PSECURITY_DESCRIPTOR pSecurityDescriptor,
380 BOOL bSaclPresent,
381 PACL pSacl,
382 BOOL bSaclDefaulted
383 )
384 {
385 NTSTATUS Status;
386
387 Status = RtlSetSaclSecurityDescriptor (pSecurityDescriptor,
388 bSaclPresent,
389 pSacl,
390 bSaclDefaulted);
391 if (!NT_SUCCESS(Status))
392 {
393 SetLastError (RtlNtStatusToDosError (Status));
394 return FALSE;
395 }
396
397 return TRUE;
398 }
399
400 /* EOF */