/src/libewf/libewf/libewf_access_control_entry.c
Line | Count | Source |
1 | | /* |
2 | | * Access control entry functions |
3 | | * |
4 | | * Copyright (C) 2006-2026, 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 <memory.h> |
24 | | #include <types.h> |
25 | | |
26 | | #include "libewf_access_control_entry.h" |
27 | | #include "libewf_lef_permission.h" |
28 | | #include "libewf_libcerror.h" |
29 | | #include "libewf_libcthreads.h" |
30 | | #include "libewf_types.h" |
31 | | |
32 | | /* Creates a access control entry |
33 | | * Make sure the value access_control_entry is referencing, is set to NULL |
34 | | * Returns 1 if successful or -1 on error |
35 | | */ |
36 | | int libewf_access_control_entry_initialize( |
37 | | libewf_access_control_entry_t **access_control_entry, |
38 | | libewf_lef_permission_t *lef_permission, |
39 | | libcerror_error_t **error ) |
40 | 0 | { |
41 | 0 | libewf_internal_access_control_entry_t *internal_access_control_entry = NULL; |
42 | 0 | static char *function = "libewf_access_control_entry_initialize"; |
43 | |
|
44 | 0 | if( access_control_entry == NULL ) |
45 | 0 | { |
46 | 0 | libcerror_error_set( |
47 | 0 | error, |
48 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
49 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
50 | 0 | "%s: invalid access control entry.", |
51 | 0 | function ); |
52 | |
|
53 | 0 | return( -1 ); |
54 | 0 | } |
55 | 0 | if( *access_control_entry != NULL ) |
56 | 0 | { |
57 | 0 | libcerror_error_set( |
58 | 0 | error, |
59 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
60 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
61 | 0 | "%s: invalid access control entry value already set.", |
62 | 0 | function ); |
63 | |
|
64 | 0 | return( -1 ); |
65 | 0 | } |
66 | 0 | if( lef_permission == NULL ) |
67 | 0 | { |
68 | 0 | libcerror_error_set( |
69 | 0 | error, |
70 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
71 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
72 | 0 | "%s: invalid permission.", |
73 | 0 | function ); |
74 | |
|
75 | 0 | return( -1 ); |
76 | 0 | } |
77 | 0 | internal_access_control_entry = memory_allocate_structure( |
78 | 0 | libewf_internal_access_control_entry_t ); |
79 | |
|
80 | 0 | if( internal_access_control_entry == NULL ) |
81 | 0 | { |
82 | 0 | libcerror_error_set( |
83 | 0 | error, |
84 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
85 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
86 | 0 | "%s: unable to create access control entry.", |
87 | 0 | function ); |
88 | |
|
89 | 0 | goto on_error; |
90 | 0 | } |
91 | 0 | if( memory_set( |
92 | 0 | internal_access_control_entry, |
93 | 0 | 0, |
94 | 0 | sizeof( libewf_internal_access_control_entry_t ) ) == NULL ) |
95 | 0 | { |
96 | 0 | libcerror_error_set( |
97 | 0 | error, |
98 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
99 | 0 | LIBCERROR_MEMORY_ERROR_SET_FAILED, |
100 | 0 | "%s: unable to clear access control entry.", |
101 | 0 | function ); |
102 | |
|
103 | 0 | memory_free( |
104 | 0 | internal_access_control_entry ); |
105 | |
|
106 | 0 | return( -1 ); |
107 | 0 | } |
108 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
109 | 0 | if( libcthreads_read_write_lock_initialize( |
110 | 0 | &( internal_access_control_entry->read_write_lock ), |
111 | 0 | error ) != 1 ) |
112 | 0 | { |
113 | 0 | libcerror_error_set( |
114 | 0 | error, |
115 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
116 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
117 | 0 | "%s: unable to initialize read/write lock.", |
118 | 0 | function ); |
119 | |
|
120 | 0 | goto on_error; |
121 | 0 | } |
122 | 0 | #endif |
123 | 0 | internal_access_control_entry->lef_permission = lef_permission; |
124 | |
|
125 | 0 | *access_control_entry = (libewf_access_control_entry_t *) internal_access_control_entry; |
126 | |
|
127 | 0 | return( 1 ); |
128 | | |
129 | 0 | on_error: |
130 | 0 | if( internal_access_control_entry != NULL ) |
131 | 0 | { |
132 | 0 | memory_free( |
133 | 0 | internal_access_control_entry ); |
134 | 0 | } |
135 | 0 | return( -1 ); |
136 | 0 | } |
137 | | |
138 | | /* Frees a access control entry |
139 | | * Returns 1 if successful or -1 on error |
140 | | */ |
141 | | int libewf_access_control_entry_free( |
142 | | libewf_access_control_entry_t **access_control_entry, |
143 | | libcerror_error_t **error ) |
144 | 0 | { |
145 | 0 | libewf_internal_access_control_entry_t *internal_access_control_entry = NULL; |
146 | 0 | static char *function = "libewf_access_control_entry_free"; |
147 | 0 | int result = 1; |
148 | |
|
149 | 0 | if( 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 | 0 | if( *access_control_entry != NULL ) |
161 | 0 | { |
162 | 0 | internal_access_control_entry = (libewf_internal_access_control_entry_t *) *access_control_entry; |
163 | 0 | *access_control_entry = NULL; |
164 | |
|
165 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
166 | 0 | if( libcthreads_read_write_lock_free( |
167 | 0 | &( internal_access_control_entry->read_write_lock ), |
168 | 0 | error ) != 1 ) |
169 | 0 | { |
170 | 0 | libcerror_error_set( |
171 | 0 | error, |
172 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
173 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
174 | 0 | "%s: unable to free read/write lock.", |
175 | 0 | function ); |
176 | |
|
177 | 0 | result = -1; |
178 | 0 | } |
179 | 0 | #endif |
180 | | /* The lef_permission reference is freed elsewhere |
181 | | */ |
182 | 0 | memory_free( |
183 | 0 | internal_access_control_entry ); |
184 | 0 | } |
185 | 0 | return( result ); |
186 | 0 | } |
187 | | |
188 | | /* Retrieves the (property) type |
189 | | * Returns 1 if successful or -1 on error |
190 | | */ |
191 | | int libewf_access_control_entry_get_type( |
192 | | libewf_access_control_entry_t *access_control_entry, |
193 | | uint32_t *type, |
194 | | libcerror_error_t **error ) |
195 | 0 | { |
196 | 0 | libewf_internal_access_control_entry_t *internal_access_control_entry = NULL; |
197 | 0 | static char *function = "libewf_access_control_entry_get_type"; |
198 | 0 | int result = 1; |
199 | |
|
200 | 0 | if( access_control_entry == NULL ) |
201 | 0 | { |
202 | 0 | libcerror_error_set( |
203 | 0 | error, |
204 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
205 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
206 | 0 | "%s: invalid access control entry.", |
207 | 0 | function ); |
208 | |
|
209 | 0 | return( -1 ); |
210 | 0 | } |
211 | 0 | internal_access_control_entry = (libewf_internal_access_control_entry_t *) access_control_entry; |
212 | |
|
213 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
214 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
215 | 0 | internal_access_control_entry->read_write_lock, |
216 | 0 | error ) != 1 ) |
217 | 0 | { |
218 | 0 | libcerror_error_set( |
219 | 0 | error, |
220 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
221 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
222 | 0 | "%s: unable to grab read/write lock for reading.", |
223 | 0 | function ); |
224 | |
|
225 | 0 | return( -1 ); |
226 | 0 | } |
227 | 0 | #endif |
228 | 0 | if( libewf_lef_permission_get_property_type( |
229 | 0 | internal_access_control_entry->lef_permission, |
230 | 0 | type, |
231 | 0 | error ) != 1 ) |
232 | 0 | { |
233 | 0 | libcerror_error_set( |
234 | 0 | error, |
235 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
236 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
237 | 0 | "%s: unable to retrieve property type.", |
238 | 0 | function ); |
239 | |
|
240 | 0 | result = -1; |
241 | 0 | } |
242 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
243 | 0 | if( libcthreads_read_write_lock_release_for_read( |
244 | 0 | internal_access_control_entry->read_write_lock, |
245 | 0 | error ) != 1 ) |
246 | 0 | { |
247 | 0 | libcerror_error_set( |
248 | 0 | error, |
249 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
250 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
251 | 0 | "%s: unable to release read/write lock for reading.", |
252 | 0 | function ); |
253 | |
|
254 | 0 | return( -1 ); |
255 | 0 | } |
256 | 0 | #endif |
257 | 0 | return( result ); |
258 | 0 | } |
259 | | |
260 | | /* Retrieves the size of the UTF-8 encoded identifier |
261 | | * The returned size includes the end of string character |
262 | | * Returns 1 if successful, 0 if not set or -1 on error |
263 | | */ |
264 | | int libewf_access_control_entry_get_utf8_identifier_size( |
265 | | libewf_access_control_entry_t *access_control_entry, |
266 | | size_t *utf8_string_size, |
267 | | libcerror_error_t **error ) |
268 | 0 | { |
269 | 0 | libewf_internal_access_control_entry_t *internal_access_control_entry = NULL; |
270 | 0 | static char *function = "libewf_access_control_entry_get_utf8_identifier_size"; |
271 | 0 | int result = 0; |
272 | |
|
273 | 0 | if( access_control_entry == NULL ) |
274 | 0 | { |
275 | 0 | libcerror_error_set( |
276 | 0 | error, |
277 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
278 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
279 | 0 | "%s: invalid access control entry.", |
280 | 0 | function ); |
281 | |
|
282 | 0 | return( -1 ); |
283 | 0 | } |
284 | 0 | internal_access_control_entry = (libewf_internal_access_control_entry_t *) access_control_entry; |
285 | |
|
286 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
287 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
288 | 0 | internal_access_control_entry->read_write_lock, |
289 | 0 | error ) != 1 ) |
290 | 0 | { |
291 | 0 | libcerror_error_set( |
292 | 0 | error, |
293 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
294 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
295 | 0 | "%s: unable to grab read/write lock for reading.", |
296 | 0 | function ); |
297 | |
|
298 | 0 | return( -1 ); |
299 | 0 | } |
300 | 0 | #endif |
301 | 0 | result = libewf_lef_permission_get_utf8_identifier_size( |
302 | 0 | internal_access_control_entry->lef_permission, |
303 | 0 | utf8_string_size, |
304 | 0 | error ); |
305 | |
|
306 | 0 | if( result == -1 ) |
307 | 0 | { |
308 | 0 | libcerror_error_set( |
309 | 0 | error, |
310 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
311 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
312 | 0 | "%s: unable to retrieve UTF-8 identifier size.", |
313 | 0 | function ); |
314 | |
|
315 | 0 | result = -1; |
316 | 0 | } |
317 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
318 | 0 | if( libcthreads_read_write_lock_release_for_read( |
319 | 0 | internal_access_control_entry->read_write_lock, |
320 | 0 | error ) != 1 ) |
321 | 0 | { |
322 | 0 | libcerror_error_set( |
323 | 0 | error, |
324 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
325 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
326 | 0 | "%s: unable to release read/write lock for reading.", |
327 | 0 | function ); |
328 | |
|
329 | 0 | return( -1 ); |
330 | 0 | } |
331 | 0 | #endif |
332 | 0 | return( result ); |
333 | 0 | } |
334 | | |
335 | | /* Retrieves the UTF-8 encoded identifier |
336 | | * The size should include the end of string character |
337 | | * Returns 1 if successful, 0 if not set or -1 on error |
338 | | */ |
339 | | int libewf_access_control_entry_get_utf8_identifier( |
340 | | libewf_access_control_entry_t *access_control_entry, |
341 | | uint8_t *utf8_string, |
342 | | size_t utf8_string_size, |
343 | | libcerror_error_t **error ) |
344 | 0 | { |
345 | 0 | libewf_internal_access_control_entry_t *internal_access_control_entry = NULL; |
346 | 0 | static char *function = "libewf_access_control_entry_get_utf8_identifier"; |
347 | 0 | int result = 0; |
348 | |
|
349 | 0 | if( access_control_entry == NULL ) |
350 | 0 | { |
351 | 0 | libcerror_error_set( |
352 | 0 | error, |
353 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
354 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
355 | 0 | "%s: invalid access control entry.", |
356 | 0 | function ); |
357 | |
|
358 | 0 | return( -1 ); |
359 | 0 | } |
360 | 0 | internal_access_control_entry = (libewf_internal_access_control_entry_t *) access_control_entry; |
361 | |
|
362 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
363 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
364 | 0 | internal_access_control_entry->read_write_lock, |
365 | 0 | error ) != 1 ) |
366 | 0 | { |
367 | 0 | libcerror_error_set( |
368 | 0 | error, |
369 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
370 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
371 | 0 | "%s: unable to grab read/write lock for reading.", |
372 | 0 | function ); |
373 | |
|
374 | 0 | return( -1 ); |
375 | 0 | } |
376 | 0 | #endif |
377 | 0 | result = libewf_lef_permission_get_utf8_identifier( |
378 | 0 | internal_access_control_entry->lef_permission, |
379 | 0 | utf8_string, |
380 | 0 | utf8_string_size, |
381 | 0 | error ); |
382 | |
|
383 | 0 | if( result == -1 ) |
384 | 0 | { |
385 | 0 | libcerror_error_set( |
386 | 0 | error, |
387 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
388 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
389 | 0 | "%s: unable to retrieve UTF-8 identifier size.", |
390 | 0 | function ); |
391 | |
|
392 | 0 | result = -1; |
393 | 0 | } |
394 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
395 | 0 | if( libcthreads_read_write_lock_release_for_read( |
396 | 0 | internal_access_control_entry->read_write_lock, |
397 | 0 | error ) != 1 ) |
398 | 0 | { |
399 | 0 | libcerror_error_set( |
400 | 0 | error, |
401 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
402 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
403 | 0 | "%s: unable to release read/write lock for reading.", |
404 | 0 | function ); |
405 | |
|
406 | 0 | return( -1 ); |
407 | 0 | } |
408 | 0 | #endif |
409 | 0 | return( result ); |
410 | 0 | } |
411 | | |
412 | | /* Retrieves the size of the UTF-16 encoded identifier |
413 | | * The returned size includes the end of string character |
414 | | * Returns 1 if successful, 0 if not set or -1 on error |
415 | | */ |
416 | | int libewf_access_control_entry_get_utf16_identifier_size( |
417 | | libewf_access_control_entry_t *access_control_entry, |
418 | | size_t *utf16_string_size, |
419 | | libcerror_error_t **error ) |
420 | 0 | { |
421 | 0 | libewf_internal_access_control_entry_t *internal_access_control_entry = NULL; |
422 | 0 | static char *function = "libewf_access_control_entry_get_utf16_identifier_size"; |
423 | 0 | int result = 0; |
424 | |
|
425 | 0 | if( access_control_entry == NULL ) |
426 | 0 | { |
427 | 0 | libcerror_error_set( |
428 | 0 | error, |
429 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
430 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
431 | 0 | "%s: invalid access control entry.", |
432 | 0 | function ); |
433 | |
|
434 | 0 | return( -1 ); |
435 | 0 | } |
436 | 0 | internal_access_control_entry = (libewf_internal_access_control_entry_t *) access_control_entry; |
437 | |
|
438 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
439 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
440 | 0 | internal_access_control_entry->read_write_lock, |
441 | 0 | error ) != 1 ) |
442 | 0 | { |
443 | 0 | libcerror_error_set( |
444 | 0 | error, |
445 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
446 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
447 | 0 | "%s: unable to grab read/write lock for reading.", |
448 | 0 | function ); |
449 | |
|
450 | 0 | return( -1 ); |
451 | 0 | } |
452 | 0 | #endif |
453 | 0 | result = libewf_lef_permission_get_utf16_identifier_size( |
454 | 0 | internal_access_control_entry->lef_permission, |
455 | 0 | utf16_string_size, |
456 | 0 | error ); |
457 | |
|
458 | 0 | if( result == -1 ) |
459 | 0 | { |
460 | 0 | libcerror_error_set( |
461 | 0 | error, |
462 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
463 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
464 | 0 | "%s: unable to retrieve UTF-16 identifier size.", |
465 | 0 | function ); |
466 | |
|
467 | 0 | result = -1; |
468 | 0 | } |
469 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
470 | 0 | if( libcthreads_read_write_lock_release_for_read( |
471 | 0 | internal_access_control_entry->read_write_lock, |
472 | 0 | error ) != 1 ) |
473 | 0 | { |
474 | 0 | libcerror_error_set( |
475 | 0 | error, |
476 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
477 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
478 | 0 | "%s: unable to release read/write lock for reading.", |
479 | 0 | function ); |
480 | |
|
481 | 0 | return( -1 ); |
482 | 0 | } |
483 | 0 | #endif |
484 | 0 | return( result ); |
485 | 0 | } |
486 | | |
487 | | /* Retrieves the UTF-16 encoded identifier |
488 | | * The size should include the end of string character |
489 | | * Returns 1 if successful, 0 if not set or -1 on error |
490 | | */ |
491 | | int libewf_access_control_entry_get_utf16_identifier( |
492 | | libewf_access_control_entry_t *access_control_entry, |
493 | | uint16_t *utf16_string, |
494 | | size_t utf16_string_size, |
495 | | libcerror_error_t **error ) |
496 | 0 | { |
497 | 0 | libewf_internal_access_control_entry_t *internal_access_control_entry = NULL; |
498 | 0 | static char *function = "libewf_access_control_entry_get_utf16_identifier"; |
499 | 0 | int result = 0; |
500 | |
|
501 | 0 | if( access_control_entry == NULL ) |
502 | 0 | { |
503 | 0 | libcerror_error_set( |
504 | 0 | error, |
505 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
506 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
507 | 0 | "%s: invalid access control entry.", |
508 | 0 | function ); |
509 | |
|
510 | 0 | return( -1 ); |
511 | 0 | } |
512 | 0 | internal_access_control_entry = (libewf_internal_access_control_entry_t *) access_control_entry; |
513 | |
|
514 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
515 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
516 | 0 | internal_access_control_entry->read_write_lock, |
517 | 0 | error ) != 1 ) |
518 | 0 | { |
519 | 0 | libcerror_error_set( |
520 | 0 | error, |
521 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
522 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
523 | 0 | "%s: unable to grab read/write lock for reading.", |
524 | 0 | function ); |
525 | |
|
526 | 0 | return( -1 ); |
527 | 0 | } |
528 | 0 | #endif |
529 | 0 | result = libewf_lef_permission_get_utf16_identifier( |
530 | 0 | internal_access_control_entry->lef_permission, |
531 | 0 | utf16_string, |
532 | 0 | utf16_string_size, |
533 | 0 | error ); |
534 | |
|
535 | 0 | if( result == -1 ) |
536 | 0 | { |
537 | 0 | libcerror_error_set( |
538 | 0 | error, |
539 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
540 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
541 | 0 | "%s: unable to retrieve UTF-16 identifier size.", |
542 | 0 | function ); |
543 | |
|
544 | 0 | result = -1; |
545 | 0 | } |
546 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
547 | 0 | if( libcthreads_read_write_lock_release_for_read( |
548 | 0 | internal_access_control_entry->read_write_lock, |
549 | 0 | error ) != 1 ) |
550 | 0 | { |
551 | 0 | libcerror_error_set( |
552 | 0 | error, |
553 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
554 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
555 | 0 | "%s: unable to release read/write lock for reading.", |
556 | 0 | function ); |
557 | |
|
558 | 0 | return( -1 ); |
559 | 0 | } |
560 | 0 | #endif |
561 | 0 | return( result ); |
562 | 0 | } |
563 | | |
564 | | /* Retrieves the size of the UTF-8 encoded name |
565 | | * The returned size includes the end of string character |
566 | | * Returns 1 if successful, 0 if not set or -1 on error |
567 | | */ |
568 | | int libewf_access_control_entry_get_utf8_name_size( |
569 | | libewf_access_control_entry_t *access_control_entry, |
570 | | size_t *utf8_string_size, |
571 | | libcerror_error_t **error ) |
572 | 0 | { |
573 | 0 | libewf_internal_access_control_entry_t *internal_access_control_entry = NULL; |
574 | 0 | static char *function = "libewf_access_control_entry_get_utf8_name_size"; |
575 | 0 | int result = 0; |
576 | |
|
577 | 0 | if( access_control_entry == NULL ) |
578 | 0 | { |
579 | 0 | libcerror_error_set( |
580 | 0 | error, |
581 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
582 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
583 | 0 | "%s: invalid access control entry.", |
584 | 0 | function ); |
585 | |
|
586 | 0 | return( -1 ); |
587 | 0 | } |
588 | 0 | internal_access_control_entry = (libewf_internal_access_control_entry_t *) access_control_entry; |
589 | |
|
590 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
591 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
592 | 0 | internal_access_control_entry->read_write_lock, |
593 | 0 | error ) != 1 ) |
594 | 0 | { |
595 | 0 | libcerror_error_set( |
596 | 0 | error, |
597 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
598 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
599 | 0 | "%s: unable to grab read/write lock for reading.", |
600 | 0 | function ); |
601 | |
|
602 | 0 | return( -1 ); |
603 | 0 | } |
604 | 0 | #endif |
605 | 0 | result = libewf_lef_permission_get_utf8_name_size( |
606 | 0 | internal_access_control_entry->lef_permission, |
607 | 0 | utf8_string_size, |
608 | 0 | error ); |
609 | |
|
610 | 0 | if( result == -1 ) |
611 | 0 | { |
612 | 0 | libcerror_error_set( |
613 | 0 | error, |
614 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
615 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
616 | 0 | "%s: unable to retrieve UTF-8 name size.", |
617 | 0 | function ); |
618 | |
|
619 | 0 | result = -1; |
620 | 0 | } |
621 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
622 | 0 | if( libcthreads_read_write_lock_release_for_read( |
623 | 0 | internal_access_control_entry->read_write_lock, |
624 | 0 | error ) != 1 ) |
625 | 0 | { |
626 | 0 | libcerror_error_set( |
627 | 0 | error, |
628 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
629 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
630 | 0 | "%s: unable to release read/write lock for reading.", |
631 | 0 | function ); |
632 | |
|
633 | 0 | return( -1 ); |
634 | 0 | } |
635 | 0 | #endif |
636 | 0 | return( result ); |
637 | 0 | } |
638 | | |
639 | | /* Retrieves the UTF-8 encoded name |
640 | | * The size should include the end of string character |
641 | | * Returns 1 if successful, 0 if not set or -1 on error |
642 | | */ |
643 | | int libewf_access_control_entry_get_utf8_name( |
644 | | libewf_access_control_entry_t *access_control_entry, |
645 | | uint8_t *utf8_string, |
646 | | size_t utf8_string_size, |
647 | | libcerror_error_t **error ) |
648 | 0 | { |
649 | 0 | libewf_internal_access_control_entry_t *internal_access_control_entry = NULL; |
650 | 0 | static char *function = "libewf_access_control_entry_get_utf8_name"; |
651 | 0 | int result = 0; |
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 = (libewf_internal_access_control_entry_t *) access_control_entry; |
665 | |
|
666 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
667 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
668 | 0 | internal_access_control_entry->read_write_lock, |
669 | 0 | error ) != 1 ) |
670 | 0 | { |
671 | 0 | libcerror_error_set( |
672 | 0 | error, |
673 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
674 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
675 | 0 | "%s: unable to grab read/write lock for reading.", |
676 | 0 | function ); |
677 | |
|
678 | 0 | return( -1 ); |
679 | 0 | } |
680 | 0 | #endif |
681 | 0 | result = libewf_lef_permission_get_utf8_name( |
682 | 0 | internal_access_control_entry->lef_permission, |
683 | 0 | utf8_string, |
684 | 0 | utf8_string_size, |
685 | 0 | error ); |
686 | |
|
687 | 0 | if( result == -1 ) |
688 | 0 | { |
689 | 0 | libcerror_error_set( |
690 | 0 | error, |
691 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
692 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
693 | 0 | "%s: unable to retrieve UTF-8 name size.", |
694 | 0 | function ); |
695 | |
|
696 | 0 | result = -1; |
697 | 0 | } |
698 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
699 | 0 | if( libcthreads_read_write_lock_release_for_read( |
700 | 0 | internal_access_control_entry->read_write_lock, |
701 | 0 | error ) != 1 ) |
702 | 0 | { |
703 | 0 | libcerror_error_set( |
704 | 0 | error, |
705 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
706 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
707 | 0 | "%s: unable to release read/write lock for reading.", |
708 | 0 | function ); |
709 | |
|
710 | 0 | return( -1 ); |
711 | 0 | } |
712 | 0 | #endif |
713 | 0 | return( result ); |
714 | 0 | } |
715 | | |
716 | | /* Retrieves the size of the UTF-16 encoded name |
717 | | * The returned size includes the end of string character |
718 | | * Returns 1 if successful, 0 if not set or -1 on error |
719 | | */ |
720 | | int libewf_access_control_entry_get_utf16_name_size( |
721 | | libewf_access_control_entry_t *access_control_entry, |
722 | | size_t *utf16_string_size, |
723 | | libcerror_error_t **error ) |
724 | 0 | { |
725 | 0 | libewf_internal_access_control_entry_t *internal_access_control_entry = NULL; |
726 | 0 | static char *function = "libewf_access_control_entry_get_utf16_name_size"; |
727 | 0 | int result = 0; |
728 | |
|
729 | 0 | if( access_control_entry == NULL ) |
730 | 0 | { |
731 | 0 | libcerror_error_set( |
732 | 0 | error, |
733 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
734 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
735 | 0 | "%s: invalid access control entry.", |
736 | 0 | function ); |
737 | |
|
738 | 0 | return( -1 ); |
739 | 0 | } |
740 | 0 | internal_access_control_entry = (libewf_internal_access_control_entry_t *) access_control_entry; |
741 | |
|
742 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
743 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
744 | 0 | internal_access_control_entry->read_write_lock, |
745 | 0 | error ) != 1 ) |
746 | 0 | { |
747 | 0 | libcerror_error_set( |
748 | 0 | error, |
749 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
750 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
751 | 0 | "%s: unable to grab read/write lock for reading.", |
752 | 0 | function ); |
753 | |
|
754 | 0 | return( -1 ); |
755 | 0 | } |
756 | 0 | #endif |
757 | 0 | result = libewf_lef_permission_get_utf16_name_size( |
758 | 0 | internal_access_control_entry->lef_permission, |
759 | 0 | utf16_string_size, |
760 | 0 | error ); |
761 | |
|
762 | 0 | if( result == -1 ) |
763 | 0 | { |
764 | 0 | libcerror_error_set( |
765 | 0 | error, |
766 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
767 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
768 | 0 | "%s: unable to retrieve UTF-16 name size.", |
769 | 0 | function ); |
770 | |
|
771 | 0 | result = -1; |
772 | 0 | } |
773 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
774 | 0 | if( libcthreads_read_write_lock_release_for_read( |
775 | 0 | internal_access_control_entry->read_write_lock, |
776 | 0 | error ) != 1 ) |
777 | 0 | { |
778 | 0 | libcerror_error_set( |
779 | 0 | error, |
780 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
781 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
782 | 0 | "%s: unable to release read/write lock for reading.", |
783 | 0 | function ); |
784 | |
|
785 | 0 | return( -1 ); |
786 | 0 | } |
787 | 0 | #endif |
788 | 0 | return( result ); |
789 | 0 | } |
790 | | |
791 | | /* Retrieves the UTF-16 encoded name |
792 | | * The size should include the end of string character |
793 | | * Returns 1 if successful, 0 if not set or -1 on error |
794 | | */ |
795 | | int libewf_access_control_entry_get_utf16_name( |
796 | | libewf_access_control_entry_t *access_control_entry, |
797 | | uint16_t *utf16_string, |
798 | | size_t utf16_string_size, |
799 | | libcerror_error_t **error ) |
800 | 0 | { |
801 | 0 | libewf_internal_access_control_entry_t *internal_access_control_entry = NULL; |
802 | 0 | static char *function = "libewf_access_control_entry_get_utf16_name"; |
803 | 0 | int result = 0; |
804 | |
|
805 | 0 | if( access_control_entry == NULL ) |
806 | 0 | { |
807 | 0 | libcerror_error_set( |
808 | 0 | error, |
809 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
810 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
811 | 0 | "%s: invalid access control entry.", |
812 | 0 | function ); |
813 | |
|
814 | 0 | return( -1 ); |
815 | 0 | } |
816 | 0 | internal_access_control_entry = (libewf_internal_access_control_entry_t *) access_control_entry; |
817 | |
|
818 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
819 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
820 | 0 | internal_access_control_entry->read_write_lock, |
821 | 0 | error ) != 1 ) |
822 | 0 | { |
823 | 0 | libcerror_error_set( |
824 | 0 | error, |
825 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
826 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
827 | 0 | "%s: unable to grab read/write lock for reading.", |
828 | 0 | function ); |
829 | |
|
830 | 0 | return( -1 ); |
831 | 0 | } |
832 | 0 | #endif |
833 | 0 | result = libewf_lef_permission_get_utf16_name( |
834 | 0 | internal_access_control_entry->lef_permission, |
835 | 0 | utf16_string, |
836 | 0 | utf16_string_size, |
837 | 0 | error ); |
838 | |
|
839 | 0 | if( result == -1 ) |
840 | 0 | { |
841 | 0 | libcerror_error_set( |
842 | 0 | error, |
843 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
844 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
845 | 0 | "%s: unable to retrieve UTF-16 name size.", |
846 | 0 | function ); |
847 | |
|
848 | 0 | result = -1; |
849 | 0 | } |
850 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
851 | 0 | if( libcthreads_read_write_lock_release_for_read( |
852 | 0 | internal_access_control_entry->read_write_lock, |
853 | 0 | error ) != 1 ) |
854 | 0 | { |
855 | 0 | libcerror_error_set( |
856 | 0 | error, |
857 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
858 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
859 | 0 | "%s: unable to release read/write lock for reading.", |
860 | 0 | function ); |
861 | |
|
862 | 0 | return( -1 ); |
863 | 0 | } |
864 | 0 | #endif |
865 | 0 | return( result ); |
866 | 0 | } |
867 | | |
868 | | /* Retrieves the access mask |
869 | | * Returns 1 if successful or -1 on error |
870 | | */ |
871 | | int libewf_access_control_entry_get_access_mask( |
872 | | libewf_access_control_entry_t *access_control_entry, |
873 | | uint32_t *access_mask, |
874 | | libcerror_error_t **error ) |
875 | 0 | { |
876 | 0 | libewf_internal_access_control_entry_t *internal_access_control_entry = NULL; |
877 | 0 | static char *function = "libewf_access_control_entry_get_access_mask"; |
878 | 0 | int result = 1; |
879 | |
|
880 | 0 | if( access_control_entry == NULL ) |
881 | 0 | { |
882 | 0 | libcerror_error_set( |
883 | 0 | error, |
884 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
885 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
886 | 0 | "%s: invalid access control entry.", |
887 | 0 | function ); |
888 | |
|
889 | 0 | return( -1 ); |
890 | 0 | } |
891 | 0 | internal_access_control_entry = (libewf_internal_access_control_entry_t *) access_control_entry; |
892 | |
|
893 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
894 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
895 | 0 | internal_access_control_entry->read_write_lock, |
896 | 0 | error ) != 1 ) |
897 | 0 | { |
898 | 0 | libcerror_error_set( |
899 | 0 | error, |
900 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
901 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
902 | 0 | "%s: unable to grab read/write lock for reading.", |
903 | 0 | function ); |
904 | |
|
905 | 0 | return( -1 ); |
906 | 0 | } |
907 | 0 | #endif |
908 | 0 | result = libewf_lef_permission_get_access_mask( |
909 | 0 | internal_access_control_entry->lef_permission, |
910 | 0 | access_mask, |
911 | 0 | error ); |
912 | |
|
913 | 0 | if( result == -1 ) |
914 | 0 | { |
915 | 0 | libcerror_error_set( |
916 | 0 | error, |
917 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
918 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
919 | 0 | "%s: unable to retrieve access mask.", |
920 | 0 | function ); |
921 | |
|
922 | 0 | result = -1; |
923 | 0 | } |
924 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
925 | 0 | if( libcthreads_read_write_lock_release_for_read( |
926 | 0 | internal_access_control_entry->read_write_lock, |
927 | 0 | error ) != 1 ) |
928 | 0 | { |
929 | 0 | libcerror_error_set( |
930 | 0 | error, |
931 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
932 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
933 | 0 | "%s: unable to release read/write lock for reading.", |
934 | 0 | function ); |
935 | |
|
936 | 0 | return( -1 ); |
937 | 0 | } |
938 | 0 | #endif |
939 | 0 | return( result ); |
940 | 0 | } |
941 | | |
942 | | /* Retrieves the flags |
943 | | * Contains Windows NT access control entry (ACE) flags |
944 | | * Returns 1 if successful or -1 on error |
945 | | */ |
946 | | int libewf_access_control_entry_get_flags( |
947 | | libewf_access_control_entry_t *access_control_entry, |
948 | | uint32_t *flags, |
949 | | libcerror_error_t **error ) |
950 | 0 | { |
951 | 0 | libewf_internal_access_control_entry_t *internal_access_control_entry = NULL; |
952 | 0 | static char *function = "libewf_access_control_entry_get_flags"; |
953 | 0 | int result = 1; |
954 | |
|
955 | 0 | if( access_control_entry == NULL ) |
956 | 0 | { |
957 | 0 | libcerror_error_set( |
958 | 0 | error, |
959 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
960 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
961 | 0 | "%s: invalid access control entry.", |
962 | 0 | function ); |
963 | |
|
964 | 0 | return( -1 ); |
965 | 0 | } |
966 | 0 | internal_access_control_entry = (libewf_internal_access_control_entry_t *) access_control_entry; |
967 | |
|
968 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
969 | 0 | if( libcthreads_read_write_lock_grab_for_read( |
970 | 0 | internal_access_control_entry->read_write_lock, |
971 | 0 | error ) != 1 ) |
972 | 0 | { |
973 | 0 | libcerror_error_set( |
974 | 0 | error, |
975 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
976 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
977 | 0 | "%s: unable to grab read/write lock for reading.", |
978 | 0 | function ); |
979 | |
|
980 | 0 | return( -1 ); |
981 | 0 | } |
982 | 0 | #endif |
983 | 0 | result = libewf_lef_permission_get_ace_flags( |
984 | 0 | internal_access_control_entry->lef_permission, |
985 | 0 | flags, |
986 | 0 | error ); |
987 | |
|
988 | 0 | if( result == -1 ) |
989 | 0 | { |
990 | 0 | libcerror_error_set( |
991 | 0 | error, |
992 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
993 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
994 | 0 | "%s: unable to retrieve ACE flags.", |
995 | 0 | function ); |
996 | |
|
997 | 0 | result = -1; |
998 | 0 | } |
999 | 0 | #if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) |
1000 | 0 | if( libcthreads_read_write_lock_release_for_read( |
1001 | 0 | internal_access_control_entry->read_write_lock, |
1002 | 0 | error ) != 1 ) |
1003 | 0 | { |
1004 | 0 | libcerror_error_set( |
1005 | 0 | error, |
1006 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1007 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1008 | 0 | "%s: unable to release read/write lock for reading.", |
1009 | 0 | function ); |
1010 | |
|
1011 | 0 | return( -1 ); |
1012 | 0 | } |
1013 | 0 | #endif |
1014 | 0 | return( result ); |
1015 | 0 | } |
1016 | | |