/src/libfwnt/libfwnt/libfwnt_access_control_entry.c
Line | Count | Source |
1 | | /* |
2 | | * Windows NT Access Control Entry (ACE) functions |
3 | | * |
4 | | * Copyright (C) 2009-2025, Joachim Metz <joachim.metz@gmail.com> |
5 | | * |
6 | | * Refer to AUTHORS for acknowledgements. |
7 | | * |
8 | | * This program is free software: you can redistribute it and/or modify |
9 | | * it under the terms of the GNU Lesser General Public License as published by |
10 | | * the Free Software Foundation, either version 3 of the License, or |
11 | | * (at your option) any later version. |
12 | | * |
13 | | * This program is distributed in the hope that it will be useful, |
14 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | | * GNU General Public License for more details. |
17 | | * |
18 | | * You should have received a copy of the GNU Lesser General Public License |
19 | | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
20 | | */ |
21 | | |
22 | | #include <common.h> |
23 | | #include <byte_stream.h> |
24 | | #include <memory.h> |
25 | | #include <narrow_string.h> |
26 | | #include <system_string.h> |
27 | | #include <types.h> |
28 | | #include <wide_string.h> |
29 | | |
30 | | #include "libfwnt_access_control_entry.h" |
31 | | #include "libfwnt_debug.h" |
32 | | #include "libfwnt_definitions.h" |
33 | | #include "libfwnt_libcerror.h" |
34 | | #include "libfwnt_libcnotify.h" |
35 | | #include "libfwnt_security_identifier.h" |
36 | | #include "libfwnt_types.h" |
37 | | |
38 | | /* Creates an access control entry |
39 | | * Make sure the value access_control_entry is referencing, is set to NULL |
40 | | * Returns 1 if successful or -1 on error |
41 | | */ |
42 | | int libfwnt_access_control_entry_initialize( |
43 | | libfwnt_access_control_entry_t **access_control_entry, |
44 | | libcerror_error_t **error ) |
45 | 90.1k | { |
46 | 90.1k | libfwnt_internal_access_control_entry_t *internal_access_control_entry = NULL; |
47 | 90.1k | static char *function = "libfwnt_access_control_entry_initialize"; |
48 | | |
49 | 90.1k | if( access_control_entry == NULL ) |
50 | 0 | { |
51 | 0 | libcerror_error_set( |
52 | 0 | error, |
53 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
54 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
55 | 0 | "%s: invalid access control entry.", |
56 | 0 | function ); |
57 | |
|
58 | 0 | return( -1 ); |
59 | 0 | } |
60 | 90.1k | if( *access_control_entry != NULL ) |
61 | 0 | { |
62 | 0 | libcerror_error_set( |
63 | 0 | error, |
64 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
65 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
66 | 0 | "%s: invalid access control entry value already set.", |
67 | 0 | function ); |
68 | |
|
69 | 0 | return( -1 ); |
70 | 0 | } |
71 | 90.1k | internal_access_control_entry = memory_allocate_structure( |
72 | 90.1k | libfwnt_internal_access_control_entry_t ); |
73 | | |
74 | 90.1k | if( internal_access_control_entry == NULL ) |
75 | 0 | { |
76 | 0 | libcerror_error_set( |
77 | 0 | error, |
78 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
79 | 0 | LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
80 | 0 | "%s: unable to create access control entry.", |
81 | 0 | function ); |
82 | |
|
83 | 0 | goto on_error; |
84 | 0 | } |
85 | 90.1k | if( memory_set( |
86 | 90.1k | internal_access_control_entry, |
87 | 90.1k | 0, |
88 | 90.1k | sizeof( libfwnt_internal_access_control_entry_t ) ) == NULL ) |
89 | 0 | { |
90 | 0 | libcerror_error_set( |
91 | 0 | error, |
92 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
93 | 0 | LIBCERROR_MEMORY_ERROR_SET_FAILED, |
94 | 0 | "%s: unable to clear access control entry.", |
95 | 0 | function ); |
96 | |
|
97 | 0 | goto on_error; |
98 | 0 | } |
99 | 90.1k | *access_control_entry = (libfwnt_access_control_entry_t *) internal_access_control_entry; |
100 | | |
101 | 90.1k | return( 1 ); |
102 | | |
103 | 0 | on_error: |
104 | 0 | if( internal_access_control_entry != NULL ) |
105 | 0 | { |
106 | 0 | memory_free( |
107 | 0 | internal_access_control_entry ); |
108 | 0 | } |
109 | 0 | return( -1 ); |
110 | 90.1k | } |
111 | | |
112 | | /* Frees an access control entry |
113 | | * Returns 1 if successful or -1 on error |
114 | | */ |
115 | | int libfwnt_access_control_entry_free( |
116 | | libfwnt_access_control_entry_t **access_control_entry, |
117 | | libcerror_error_t **error ) |
118 | 0 | { |
119 | 0 | static char *function = "libfwnt_access_control_entry_free"; |
120 | |
|
121 | 0 | if( access_control_entry == NULL ) |
122 | 0 | { |
123 | 0 | libcerror_error_set( |
124 | 0 | error, |
125 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
126 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
127 | 0 | "%s: invalid access control entry.", |
128 | 0 | function ); |
129 | |
|
130 | 0 | return( -1 ); |
131 | 0 | } |
132 | 0 | if( *access_control_entry != NULL ) |
133 | 0 | { |
134 | 0 | *access_control_entry = NULL; |
135 | 0 | } |
136 | 0 | return( 1 ); |
137 | 0 | } |
138 | | |
139 | | /* Frees an access control entry |
140 | | * Returns 1 if successful or -1 on error |
141 | | */ |
142 | | int libfwnt_internal_access_control_entry_free( |
143 | | libfwnt_internal_access_control_entry_t **internal_access_control_entry, |
144 | | libcerror_error_t **error ) |
145 | 90.1k | { |
146 | 90.1k | static char *function = "libfwnt_internal_access_control_entry_free"; |
147 | 90.1k | int result = 1; |
148 | | |
149 | 90.1k | if( internal_access_control_entry == NULL ) |
150 | 0 | { |
151 | 0 | libcerror_error_set( |
152 | 0 | error, |
153 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
154 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
155 | 0 | "%s: invalid access control entry.", |
156 | 0 | function ); |
157 | |
|
158 | 0 | return( -1 ); |
159 | 0 | } |
160 | 90.1k | if( *internal_access_control_entry != NULL ) |
161 | 90.1k | { |
162 | 90.1k | if( ( *internal_access_control_entry )->security_identifier != NULL ) |
163 | 4.72k | { |
164 | 4.72k | if( libfwnt_internal_security_identifier_free( |
165 | 4.72k | (libfwnt_internal_security_identifier_t **) &( ( *internal_access_control_entry )->security_identifier ), |
166 | 4.72k | error ) != 1 ) |
167 | 0 | { |
168 | 0 | libcerror_error_set( |
169 | 0 | error, |
170 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
171 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
172 | 0 | "%s: unable to free security identifier.", |
173 | 0 | function ); |
174 | |
|
175 | 0 | result = -1; |
176 | 0 | } |
177 | 4.72k | } |
178 | 90.1k | memory_free( |
179 | 90.1k | *internal_access_control_entry ); |
180 | | |
181 | 90.1k | *internal_access_control_entry = NULL; |
182 | 90.1k | } |
183 | 90.1k | return( result ); |
184 | 90.1k | } |
185 | | |
186 | | /* Converts an access control entry stored in a byte stream into a runtime version |
187 | | * Returns 1 if successful or -1 on error |
188 | | */ |
189 | | int libfwnt_access_control_entry_copy_from_byte_stream( |
190 | | libfwnt_access_control_entry_t *access_control_entry, |
191 | | const uint8_t *byte_stream, |
192 | | size_t byte_stream_size, |
193 | | int byte_order, |
194 | | libcerror_error_t **error ) |
195 | 90.1k | { |
196 | 90.1k | libfwnt_internal_access_control_entry_t *internal_access_control_entry = NULL; |
197 | 90.1k | static char *function = "libfwnt_access_control_entry_copy_from_byte_stream"; |
198 | 90.1k | size_t access_mask_offset = 0; |
199 | 90.1k | size_t sid_offset = 0; |
200 | | |
201 | | #if defined( HAVE_DEBUG_OUTPUT ) |
202 | | system_character_t *sid_string = NULL; |
203 | | size_t sid_string_size = 0; |
204 | | int result = 0; |
205 | | #endif |
206 | | |
207 | 90.1k | if( access_control_entry == NULL ) |
208 | 0 | { |
209 | 0 | libcerror_error_set( |
210 | 0 | error, |
211 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
212 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
213 | 0 | "%s: invalid access control entry.", |
214 | 0 | function ); |
215 | |
|
216 | 0 | return( -1 ); |
217 | 0 | } |
218 | 90.1k | internal_access_control_entry = (libfwnt_internal_access_control_entry_t *) access_control_entry; |
219 | | |
220 | 90.1k | if( byte_stream == NULL ) |
221 | 0 | { |
222 | 0 | libcerror_error_set( |
223 | 0 | error, |
224 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
225 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
226 | 0 | "%s: invalid byte stream.", |
227 | 0 | function ); |
228 | |
|
229 | 0 | return( -1 ); |
230 | 0 | } |
231 | 90.1k | if( byte_stream_size < 4 ) |
232 | 84 | { |
233 | 84 | libcerror_error_set( |
234 | 84 | error, |
235 | 84 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
236 | 84 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
237 | 84 | "%s: byte stream too small.", |
238 | 84 | function ); |
239 | | |
240 | 84 | return( -1 ); |
241 | 84 | } |
242 | 90.0k | if( byte_stream_size > (size_t) SSIZE_MAX ) |
243 | 0 | { |
244 | 0 | libcerror_error_set( |
245 | 0 | error, |
246 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
247 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
248 | 0 | "%s: byte stream size exceeds maximum.", |
249 | 0 | function ); |
250 | |
|
251 | 0 | return( -1 ); |
252 | 0 | } |
253 | 90.0k | if( byte_order != LIBFWNT_ENDIAN_LITTLE ) |
254 | 0 | { |
255 | 0 | libcerror_error_set( |
256 | 0 | error, |
257 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
258 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
259 | 0 | "%s: unsupported byte order.", |
260 | 0 | function ); |
261 | |
|
262 | 0 | return( -1 ); |
263 | 0 | } |
264 | | #if defined( HAVE_DEBUG_OUTPUT ) |
265 | | if( libcnotify_verbose != 0 ) |
266 | | { |
267 | | libcnotify_printf( |
268 | | "%s: header data:\n", |
269 | | function ); |
270 | | libcnotify_print_data( |
271 | | byte_stream, |
272 | | 4, |
273 | | 0 ); |
274 | | } |
275 | | #endif |
276 | 90.0k | internal_access_control_entry->type = byte_stream[ 0 ]; |
277 | 90.0k | internal_access_control_entry->flags = byte_stream[ 1 ]; |
278 | | |
279 | 90.0k | byte_stream_copy_to_uint16_little_endian( |
280 | 90.0k | &( byte_stream[ 2 ] ), |
281 | 90.0k | internal_access_control_entry->size ); |
282 | | |
283 | | #if defined( HAVE_DEBUG_OUTPUT ) |
284 | | if( libcnotify_verbose != 0 ) |
285 | | { |
286 | | libcnotify_printf( |
287 | | "%s: type\t\t: %" PRIu8 " (%s)\n", |
288 | | function, |
289 | | internal_access_control_entry->type, |
290 | | libfwnt_debug_print_access_control_entry_type( |
291 | | internal_access_control_entry->type ) ); |
292 | | |
293 | | libcnotify_printf( |
294 | | "%s: flags\t\t: 0x%02" PRIx8 "\n", |
295 | | function, |
296 | | internal_access_control_entry->flags ); |
297 | | libfwnt_debug_print_access_control_entry_flags( |
298 | | internal_access_control_entry->flags ); |
299 | | libcnotify_printf( |
300 | | "\n" ); |
301 | | |
302 | | libcnotify_printf( |
303 | | "%s: size\t\t: %" PRIu16 "\n", |
304 | | function, |
305 | | internal_access_control_entry->size ); |
306 | | |
307 | | libcnotify_printf( |
308 | | "\n" ); |
309 | | } |
310 | | #endif /* defined( HAVE_DEBUG_OUTPUT ) */ |
311 | | |
312 | 90.0k | if( ( internal_access_control_entry->size < 4 ) |
313 | 89.9k | || ( (size_t) internal_access_control_entry->size > byte_stream_size ) ) |
314 | | |
315 | 137 | { |
316 | 137 | libcerror_error_set( |
317 | 137 | error, |
318 | 137 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
319 | 137 | LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
320 | 137 | "%s: access control entry size value out of bounds.", |
321 | 137 | function ); |
322 | | |
323 | 137 | goto on_error; |
324 | 137 | } |
325 | | #if defined( HAVE_DEBUG_OUTPUT ) |
326 | | if( libcnotify_verbose != 0 ) |
327 | | { |
328 | | libcnotify_printf( |
329 | | "%s: access control entry data:\n", |
330 | | function ); |
331 | | libcnotify_print_data( |
332 | | &( byte_stream[ 4 ] ), |
333 | | internal_access_control_entry->size - 4, |
334 | | 0 ); |
335 | | } |
336 | | #endif |
337 | 89.8k | switch( internal_access_control_entry->type ) |
338 | 89.8k | { |
339 | | /* Basic types */ |
340 | 327 | case LIBFWNT_ACCESS_ALLOWED: |
341 | 601 | case LIBFWNT_ACCESS_DENIED: |
342 | 821 | case LIBFWNT_SYSTEM_AUDIT: |
343 | 1.29k | case LIBFWNT_SYSTEM_ALARM: |
344 | 1.54k | case LIBFWNT_ACCESS_ALLOWED_CALLBACK: |
345 | 2.07k | case LIBFWNT_ACCESS_DENIED_CALLBACK: |
346 | 2.38k | case LIBFWNT_SYSTEM_AUDIT_CALLBACK: |
347 | 2.65k | case LIBFWNT_SYSTEM_ALARM_CALLBACK: |
348 | 2.93k | case LIBFWNT_SYSTEM_MANDATORY_LABEL: |
349 | 2.93k | access_mask_offset = 4; |
350 | 2.93k | sid_offset = 8; |
351 | 2.93k | break; |
352 | | |
353 | | /* Object types */ |
354 | 212 | case LIBFWNT_ACCESS_ALLOWED_OBJECT: |
355 | 410 | case LIBFWNT_ACCESS_DENIED_OBJECT: |
356 | 645 | case LIBFWNT_SYSTEM_AUDIT_OBJECT: |
357 | 842 | case LIBFWNT_SYSTEM_ALARM_OBJECT: |
358 | 1.12k | case LIBFWNT_ACCESS_ALLOWED_CALLBACK_OBJECT: |
359 | 1.36k | case LIBFWNT_ACCESS_DENIED_CALLBACK_OBJECT: |
360 | 1.68k | case LIBFWNT_SYSTEM_AUDIT_CALLBACK_OBJECT: |
361 | 1.89k | case LIBFWNT_SYSTEM_ALARM_CALLBACK_OBJECT: |
362 | 1.89k | access_mask_offset = 4; |
363 | 1.89k | sid_offset = 40; |
364 | 1.89k | break; |
365 | | |
366 | | /* Unknown types */ |
367 | 24.0k | case LIBFWNT_ACCESS_ALLOWED_COMPOUND: |
368 | 85.0k | default: |
369 | 85.0k | break; |
370 | 89.8k | } |
371 | 89.8k | if( access_mask_offset > 0 ) |
372 | 4.82k | { |
373 | 4.82k | if( access_mask_offset > (size_t) ( internal_access_control_entry->size - 4 ) ) |
374 | | |
375 | 33 | { |
376 | 33 | libcerror_error_set( |
377 | 33 | error, |
378 | 33 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
379 | 33 | LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
380 | 33 | "%s: access control mask offset value out of bounds.", |
381 | 33 | function ); |
382 | | |
383 | 33 | goto on_error; |
384 | 33 | } |
385 | 4.79k | byte_stream_copy_to_uint32_little_endian( |
386 | 4.79k | &( byte_stream[ access_mask_offset ] ), |
387 | 4.79k | internal_access_control_entry->access_mask ); |
388 | | |
389 | | #if defined( HAVE_DEBUG_OUTPUT ) |
390 | | if( libcnotify_verbose != 0 ) |
391 | | { |
392 | | libcnotify_printf( |
393 | | "%s: access mask\t\t: 0x%08" PRIx32 "\n", |
394 | | function, |
395 | | internal_access_control_entry->access_mask ); |
396 | | libfwnt_debug_print_access_control_entry_access_mask( |
397 | | internal_access_control_entry->access_mask ); |
398 | | libcnotify_printf( |
399 | | "\n" ); |
400 | | } |
401 | | #endif |
402 | 4.79k | } |
403 | 89.8k | if( sid_offset > 0 ) |
404 | 4.79k | { |
405 | 4.79k | if( sid_offset > internal_access_control_entry->size ) |
406 | 17 | { |
407 | 17 | libcerror_error_set( |
408 | 17 | error, |
409 | 17 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
410 | 17 | LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
411 | 17 | "%s: security identifier offset value out of bounds.", |
412 | 17 | function ); |
413 | | |
414 | 17 | goto on_error; |
415 | 17 | } |
416 | 4.77k | if( libfwnt_security_identifier_initialize( |
417 | 4.77k | &( internal_access_control_entry->security_identifier ), |
418 | 4.77k | error ) != 1 ) |
419 | 0 | { |
420 | 0 | libcerror_error_set( |
421 | 0 | error, |
422 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
423 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
424 | 0 | "%s: unable to create security identifier.", |
425 | 0 | function ); |
426 | |
|
427 | 0 | goto on_error; |
428 | 0 | } |
429 | 4.77k | if( internal_access_control_entry->security_identifier == NULL ) |
430 | 0 | { |
431 | 0 | libcerror_error_set( |
432 | 0 | error, |
433 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
434 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, |
435 | 0 | "%s: invalid access control entry - missing owner security identifier.", |
436 | 0 | function ); |
437 | |
|
438 | 0 | goto on_error; |
439 | 0 | } |
440 | 4.77k | ( (libfwnt_internal_security_identifier_t *) internal_access_control_entry->security_identifier )->is_managed = 1; |
441 | | |
442 | 4.77k | if( libfwnt_security_identifier_copy_from_byte_stream( |
443 | 4.77k | internal_access_control_entry->security_identifier, |
444 | 4.77k | &( byte_stream[ sid_offset ] ), |
445 | 4.77k | byte_stream_size - sid_offset, |
446 | 4.77k | byte_order, |
447 | 4.77k | error ) != 1 ) |
448 | 51 | { |
449 | 51 | libcerror_error_set( |
450 | 51 | error, |
451 | 51 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
452 | 51 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
453 | 51 | "%s: unable to copy security identifier from byte stream.", |
454 | 51 | function ); |
455 | | |
456 | 51 | goto on_error; |
457 | 51 | } |
458 | | #if defined( HAVE_DEBUG_OUTPUT ) |
459 | | if( libcnotify_verbose != 0 ) |
460 | | { |
461 | | if( libfwnt_security_identifier_get_string_size( |
462 | | internal_access_control_entry->security_identifier, |
463 | | &sid_string_size, |
464 | | 0, |
465 | | error ) != 1 ) |
466 | | { |
467 | | libcerror_error_set( |
468 | | error, |
469 | | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
470 | | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
471 | | "%s: unable to retrieve security identifier string size.", |
472 | | function ); |
473 | | |
474 | | goto on_error; |
475 | | } |
476 | | libcnotify_printf( |
477 | | "%s: SID\t\t\t: ", |
478 | | function ); |
479 | | |
480 | | if( sid_string_size > 0 ) |
481 | | { |
482 | | sid_string = system_string_allocate( |
483 | | sid_string_size ); |
484 | | |
485 | | if( sid_string == NULL ) |
486 | | { |
487 | | libcerror_error_set( |
488 | | error, |
489 | | LIBCERROR_ERROR_DOMAIN_MEMORY, |
490 | | LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
491 | | "%s: unable to create security identifier string.", |
492 | | function ); |
493 | | |
494 | | goto on_error; |
495 | | } |
496 | | #if defined( HAVE_WIDE_SYSTEM_CHARACTER ) |
497 | | result = libfwnt_security_identifier_copy_to_utf16_string( |
498 | | internal_access_control_entry->security_identifier, |
499 | | (uint16_t *) sid_string, |
500 | | sid_string_size, |
501 | | 0, |
502 | | error ); |
503 | | #else |
504 | | result = libfwnt_security_identifier_copy_to_utf8_string( |
505 | | internal_access_control_entry->security_identifier, |
506 | | (uint8_t *) sid_string, |
507 | | sid_string_size, |
508 | | 0, |
509 | | error ); |
510 | | #endif |
511 | | if( result != 1 ) |
512 | | { |
513 | | libcerror_error_set( |
514 | | error, |
515 | | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
516 | | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
517 | | "%s: unable to copy security identifier to string.", |
518 | | function ); |
519 | | |
520 | | goto on_error; |
521 | | } |
522 | | libcnotify_printf( |
523 | | "%" PRIs_SYSTEM "", |
524 | | sid_string ); |
525 | | |
526 | | memory_free( |
527 | | sid_string ); |
528 | | |
529 | | sid_string = NULL; |
530 | | } |
531 | | libcnotify_printf( |
532 | | "\n" ); |
533 | | } |
534 | | #endif /* defined( HAVE_DEBUG_OUTPUT ) */ |
535 | 4.77k | } |
536 | | #if defined( HAVE_DEBUG_OUTPUT ) |
537 | | if( libcnotify_verbose != 0 ) |
538 | | { |
539 | | libcnotify_printf( |
540 | | "\n" ); |
541 | | } |
542 | | #endif |
543 | 89.7k | return( 1 ); |
544 | | |
545 | 238 | on_error: |
546 | | #if defined( HAVE_DEBUG_OUTPUT ) |
547 | | if( sid_string != NULL ) |
548 | | { |
549 | | memory_free( |
550 | | sid_string ); |
551 | | } |
552 | | #endif |
553 | 238 | if( internal_access_control_entry->security_identifier != NULL ) |
554 | 51 | { |
555 | 51 | libfwnt_internal_security_identifier_free( |
556 | 51 | (libfwnt_internal_security_identifier_t **) &( internal_access_control_entry->security_identifier ), |
557 | 51 | NULL ); |
558 | 51 | } |
559 | 238 | return( -1 ); |
560 | 89.8k | } |
561 | | |
562 | | /* Retrieves the type |
563 | | * Returns 1 if successful or -1 on error |
564 | | */ |
565 | | int libfwnt_access_control_entry_get_type( |
566 | | libfwnt_access_control_entry_t *access_control_entry, |
567 | | uint8_t *type, |
568 | | libcerror_error_t **error ) |
569 | 0 | { |
570 | 0 | libfwnt_internal_access_control_entry_t *internal_access_control_entry = NULL; |
571 | 0 | static char *function = "libfwnt_access_control_entry_get_type"; |
572 | |
|
573 | 0 | if( access_control_entry == NULL ) |
574 | 0 | { |
575 | 0 | libcerror_error_set( |
576 | 0 | error, |
577 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
578 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
579 | 0 | "%s: invalid access control entry.", |
580 | 0 | function ); |
581 | |
|
582 | 0 | return( -1 ); |
583 | 0 | } |
584 | 0 | internal_access_control_entry = (libfwnt_internal_access_control_entry_t *) access_control_entry; |
585 | |
|
586 | 0 | if( type == NULL ) |
587 | 0 | { |
588 | 0 | libcerror_error_set( |
589 | 0 | error, |
590 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
591 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
592 | 0 | "%s: invalid type.", |
593 | 0 | function ); |
594 | |
|
595 | 0 | return( -1 ); |
596 | 0 | } |
597 | 0 | *type = internal_access_control_entry->type; |
598 | |
|
599 | 0 | return( 1 ); |
600 | 0 | } |
601 | | |
602 | | /* Retrieves the flags |
603 | | * Returns 1 if successful or -1 on error |
604 | | */ |
605 | | int libfwnt_access_control_entry_get_flags( |
606 | | libfwnt_access_control_entry_t *access_control_entry, |
607 | | uint8_t *flags, |
608 | | libcerror_error_t **error ) |
609 | 0 | { |
610 | 0 | libfwnt_internal_access_control_entry_t *internal_access_control_entry = NULL; |
611 | 0 | static char *function = "libfwnt_access_control_entry_get_flags"; |
612 | |
|
613 | 0 | if( access_control_entry == NULL ) |
614 | 0 | { |
615 | 0 | libcerror_error_set( |
616 | 0 | error, |
617 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
618 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
619 | 0 | "%s: invalid access control entry.", |
620 | 0 | function ); |
621 | |
|
622 | 0 | return( -1 ); |
623 | 0 | } |
624 | 0 | internal_access_control_entry = (libfwnt_internal_access_control_entry_t *) access_control_entry; |
625 | |
|
626 | 0 | if( flags == NULL ) |
627 | 0 | { |
628 | 0 | libcerror_error_set( |
629 | 0 | error, |
630 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
631 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
632 | 0 | "%s: invalid flags.", |
633 | 0 | function ); |
634 | |
|
635 | 0 | return( -1 ); |
636 | 0 | } |
637 | 0 | *flags = internal_access_control_entry->flags; |
638 | |
|
639 | 0 | return( 1 ); |
640 | 0 | } |
641 | | |
642 | | /* Retrieves the access mask |
643 | | * Returns 1 if successful, 0 if not available or -1 on error |
644 | | */ |
645 | | int libfwnt_access_control_entry_get_access_mask( |
646 | | libfwnt_access_control_entry_t *access_control_entry, |
647 | | uint32_t *access_mask, |
648 | | libcerror_error_t **error ) |
649 | 0 | { |
650 | 0 | libfwnt_internal_access_control_entry_t *internal_access_control_entry = NULL; |
651 | 0 | static char *function = "libfwnt_access_control_entry_get_access_mask"; |
652 | |
|
653 | 0 | if( access_control_entry == NULL ) |
654 | 0 | { |
655 | 0 | libcerror_error_set( |
656 | 0 | error, |
657 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
658 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
659 | 0 | "%s: invalid access control entry.", |
660 | 0 | function ); |
661 | |
|
662 | 0 | return( -1 ); |
663 | 0 | } |
664 | 0 | internal_access_control_entry = (libfwnt_internal_access_control_entry_t *) access_control_entry; |
665 | |
|
666 | 0 | if( access_mask == NULL ) |
667 | 0 | { |
668 | 0 | libcerror_error_set( |
669 | 0 | error, |
670 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
671 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
672 | 0 | "%s: invalid access mask.", |
673 | 0 | function ); |
674 | |
|
675 | 0 | return( -1 ); |
676 | 0 | } |
677 | 0 | switch( internal_access_control_entry->type ) |
678 | 0 | { |
679 | | /* Basic types */ |
680 | 0 | case LIBFWNT_ACCESS_ALLOWED: |
681 | 0 | case LIBFWNT_ACCESS_DENIED: |
682 | 0 | case LIBFWNT_SYSTEM_AUDIT: |
683 | 0 | case LIBFWNT_SYSTEM_ALARM: |
684 | 0 | case LIBFWNT_ACCESS_ALLOWED_CALLBACK: |
685 | 0 | case LIBFWNT_ACCESS_DENIED_CALLBACK: |
686 | 0 | case LIBFWNT_SYSTEM_AUDIT_CALLBACK: |
687 | 0 | case LIBFWNT_SYSTEM_ALARM_CALLBACK: |
688 | 0 | case LIBFWNT_SYSTEM_MANDATORY_LABEL: |
689 | | /* Object types */ |
690 | 0 | case LIBFWNT_ACCESS_ALLOWED_OBJECT: |
691 | 0 | case LIBFWNT_ACCESS_DENIED_OBJECT: |
692 | 0 | case LIBFWNT_SYSTEM_AUDIT_OBJECT: |
693 | 0 | case LIBFWNT_SYSTEM_ALARM_OBJECT: |
694 | 0 | case LIBFWNT_ACCESS_ALLOWED_CALLBACK_OBJECT: |
695 | 0 | case LIBFWNT_ACCESS_DENIED_CALLBACK_OBJECT: |
696 | 0 | case LIBFWNT_SYSTEM_AUDIT_CALLBACK_OBJECT: |
697 | 0 | case LIBFWNT_SYSTEM_ALARM_CALLBACK_OBJECT: |
698 | 0 | break; |
699 | | |
700 | | /* Unknown types */ |
701 | 0 | case LIBFWNT_ACCESS_ALLOWED_COMPOUND: |
702 | 0 | default: |
703 | 0 | return( 0 ); |
704 | 0 | } |
705 | 0 | *access_mask = internal_access_control_entry->access_mask; |
706 | |
|
707 | 0 | return( 1 ); |
708 | 0 | } |
709 | | |
710 | | /* Retrieves the security identifier |
711 | | * Returns 1 if successful, 0 if not available or -1 on error |
712 | | */ |
713 | | int libfwnt_access_control_entry_get_security_identifier( |
714 | | libfwnt_access_control_entry_t *access_control_entry, |
715 | | libfwnt_security_identifier_t **security_identifier, |
716 | | libcerror_error_t **error ) |
717 | 0 | { |
718 | 0 | libfwnt_internal_access_control_entry_t *internal_access_control_entry = NULL; |
719 | 0 | static char *function = "libfwnt_access_control_entry_get_security_identifier"; |
720 | |
|
721 | 0 | if( access_control_entry == NULL ) |
722 | 0 | { |
723 | 0 | libcerror_error_set( |
724 | 0 | error, |
725 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
726 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
727 | 0 | "%s: invalid access control entry.", |
728 | 0 | function ); |
729 | |
|
730 | 0 | return( -1 ); |
731 | 0 | } |
732 | 0 | internal_access_control_entry = (libfwnt_internal_access_control_entry_t *) access_control_entry; |
733 | |
|
734 | 0 | if( security_identifier == NULL ) |
735 | 0 | { |
736 | 0 | libcerror_error_set( |
737 | 0 | error, |
738 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
739 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
740 | 0 | "%s: invalid security identifier.", |
741 | 0 | function ); |
742 | |
|
743 | 0 | return( -1 ); |
744 | 0 | } |
745 | 0 | if( *security_identifier != NULL ) |
746 | 0 | { |
747 | 0 | libcerror_error_set( |
748 | 0 | error, |
749 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
750 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
751 | 0 | "%s: invalid security identifier value already set.", |
752 | 0 | function ); |
753 | |
|
754 | 0 | return( -1 ); |
755 | 0 | } |
756 | 0 | if( internal_access_control_entry->security_identifier == NULL ) |
757 | 0 | { |
758 | 0 | return( 0 ); |
759 | 0 | } |
760 | 0 | *security_identifier = internal_access_control_entry->security_identifier; |
761 | |
|
762 | 0 | return( 1 ); |
763 | 0 | } |
764 | | |