]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/dy_framework.c
configd-888.1.2.tar.gz
[apple/configd.git] / SystemConfiguration.fproj / dy_framework.c
1 /*
2 * Copyright (c) 2002-2008, 2010-2015 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 /*
25 * Modification History
26 *
27 * October 31, 2000 Allan Nathanson <ajn@apple.com>
28 * - initial revision
29 */
30
31
32 #include <sys/types.h>
33 #include <sys/param.h>
34 #include <sys/stat.h>
35 #include <dlfcn.h>
36 #include <mach-o/dyld_priv.h>
37
38 #include <CoreFoundation/CFRuntime.h>
39 #include "dy_framework.h"
40
41
42 void *
43 _SC_dlopen(const char *framework)
44 {
45 void *image;
46 static dispatch_once_t once;
47 static const char *suffix = NULL;
48
49 dispatch_once(&once, ^{
50 if (!dyld_process_is_restricted()) {
51 suffix = getenv("DYLD_IMAGE_SUFFIX");
52 if ((suffix != NULL) &&
53 ((strlen(suffix) < 2) || (suffix[0] != '_'))) {
54 // if too short or no leading "_"
55 suffix = NULL;
56 }
57 }
58 });
59
60 if (suffix != NULL) {
61 struct stat statbuf;
62 char path[MAXPATHLEN];
63
64 strlcpy(path, framework, sizeof(path));
65 strlcat(path, suffix, sizeof(path));
66 if (0 <= stat(path, &statbuf)) {
67 image = dlopen(path, RTLD_LAZY | RTLD_LOCAL);
68 return image;
69 }
70 }
71
72 image = dlopen(framework, RTLD_LAZY | RTLD_LOCAL);
73 return image;
74 }
75
76
77 #pragma mark -
78 #pragma mark IOKit.framework APIs
79
80 static void *
81 __loadIOKit(void) {
82 static void *image = NULL;
83 static dispatch_once_t once;
84
85 dispatch_once(&once, ^{
86 image = _SC_dlopen("/System/Library/Frameworks/IOKit.framework/IOKit");
87 });
88
89 return image;
90 }
91
92
93 __private_extern__ CFMutableDictionaryRef
94 _IOBSDNameMatching(mach_port_t masterPort, uint32_t options, const char *bsdName)
95 {
96 #undef IOBSDNameMatching
97 static typeof (IOBSDNameMatching) *dyfunc = NULL;
98 if (!dyfunc) {
99 void *image = __loadIOKit();
100 if (image) dyfunc = dlsym(image, "IOBSDNameMatching");
101 }
102 return dyfunc ? dyfunc(masterPort, options, bsdName) : NULL;
103 }
104
105
106 __private_extern__ io_object_t
107 _IOIteratorNext(io_iterator_t iterator)
108 {
109 #undef IOIteratorNext
110 static typeof (IOIteratorNext) *dyfunc = NULL;
111 if (!dyfunc) {
112 void *image = __loadIOKit();
113 if (image) dyfunc = dlsym(image, "IOIteratorNext");
114 }
115 return dyfunc ? dyfunc(iterator) : 0;
116 }
117
118
119 __private_extern__ kern_return_t
120 _IOMasterPort(mach_port_t bootstrapPort, mach_port_t *masterPort)
121 {
122 #undef IOMasterPort
123 static typeof (IOMasterPort) *dyfunc = NULL;
124 if (!dyfunc) {
125 void *image = __loadIOKit();
126 if (image) dyfunc = dlsym(image, "IOMasterPort");
127 }
128 return dyfunc ? dyfunc(bootstrapPort, masterPort) : KERN_FAILURE;
129 }
130
131
132 __private_extern__ boolean_t
133 _IOObjectConformsTo(io_object_t object, const io_name_t className)
134 {
135 #undef IOObjectConformsTo
136 static typeof (IOObjectConformsTo) *dyfunc = NULL;
137 if (!dyfunc) {
138 void *image = __loadIOKit();
139 if (image) dyfunc = dlsym(image, "IOObjectConformsTo");
140 }
141 return dyfunc ? dyfunc(object, className) : FALSE;
142 }
143
144
145 __private_extern__ boolean_t
146 _IOObjectGetClass(io_object_t object, io_name_t className)
147 {
148 #undef IOObjectGetClass
149 static typeof (IOObjectGetClass) *dyfunc = NULL;
150 if (!dyfunc) {
151 void *image = __loadIOKit();
152 if (image) dyfunc = dlsym(image, "IOObjectGetClass");
153 }
154 return dyfunc ? dyfunc(object, className) : FALSE;
155 }
156
157
158 __private_extern__ kern_return_t
159 _IOObjectRelease(io_object_t object)
160 {
161 #undef IOObjectRelease
162 static typeof (IOObjectRelease) *dyfunc = NULL;
163 if (!dyfunc) {
164 void *image = __loadIOKit();
165 if (image) dyfunc = dlsym(image, "IOObjectRelease");
166 }
167 return dyfunc ? dyfunc(object) : KERN_FAILURE;
168 }
169
170
171 #if !TARGET_OS_IPHONE
172
173 __private_extern__ IOReturn
174 _IOPMConnectionAcknowledgeEvent(IOPMConnection myConnection, IOPMConnectionMessageToken token)
175 {
176 #undef IOPMConnectionAcknowledgeEvent
177 static typeof (IOPMConnectionAcknowledgeEvent) *dyfunc = NULL;
178 if (!dyfunc) {
179 void *image = __loadIOKit();
180 if (image) dyfunc = dlsym(image, "IOPMConnectionAcknowledgeEvent");
181 }
182 return dyfunc ? dyfunc(myConnection, token) : kIOReturnError;
183 }
184
185
186 __private_extern__ IOReturn
187 _IOPMConnectionCreate(CFStringRef myName, IOPMCapabilityBits interests, IOPMConnection *newConnection)
188 {
189 #undef IOPMConnectionCreate
190 static typeof (IOPMConnectionCreate) *dyfunc = NULL;
191 if (!dyfunc) {
192 void *image = __loadIOKit();
193 if (image) dyfunc = dlsym(image, "IOPMConnectionCreate");
194 }
195 return dyfunc ? dyfunc(myName, interests, newConnection) : kIOReturnError;
196 }
197
198
199 __private_extern__ IOPMCapabilityBits
200 _IOPMConnectionGetSystemCapabilities(void)
201 {
202 #undef IOPMConnectionGetSystemCapabilities
203 static typeof (IOPMConnectionGetSystemCapabilities) *dyfunc = NULL;
204 if (!dyfunc) {
205 void *image = __loadIOKit();
206 if (image) dyfunc = dlsym(image, "IOPMConnectionGetSystemCapabilities");
207 }
208 return dyfunc ? dyfunc() : kIOPMSleepWakeInterest;
209 }
210
211
212 __private_extern__ IOReturn
213 _IOPMConnectionRelease(IOPMConnection myConnection)
214 {
215 #undef IOPMConnectionRelease
216 static typeof (IOPMConnectionRelease) *dyfunc = NULL;
217 if (!dyfunc) {
218 void *image = __loadIOKit();
219 if (image) dyfunc = dlsym(image, "IOPMConnectionRelease");
220 }
221 return dyfunc ? dyfunc(myConnection) : kIOReturnError;
222 }
223
224
225 __private_extern__ void
226 _IOPMConnectionSetDispatchQueue(IOPMConnection myConnection, dispatch_queue_t myQueue)
227 {
228 #undef IOPMConnectionSetDispatchQueue
229 static typeof (IOPMConnectionSetDispatchQueue) *dyfunc = NULL;
230 if (!dyfunc) {
231 void *image = __loadIOKit();
232 if (image) dyfunc = dlsym(image, "IOPMConnectionSetDispatchQueue");
233 }
234 if (dyfunc) {
235 dyfunc(myConnection, myQueue);
236 }
237 return;
238 }
239
240
241 __private_extern__ IOReturn
242 _IOPMConnectionSetNotification(IOPMConnection myConnection, void *param, IOPMEventHandlerType handler)
243 {
244 #undef IOPMConnectionSetNotification
245 static typeof (IOPMConnectionSetNotification) *dyfunc = NULL;
246 if (!dyfunc) {
247 void *image = __loadIOKit();
248 if (image) dyfunc = dlsym(image, "IOPMConnectionSetNotification");
249 }
250 return dyfunc ? dyfunc(myConnection, param, handler) : kIOReturnError;
251 }
252
253 #endif // !TARGET_OS_IPHONE
254
255
256 __private_extern__ CFTypeRef
257 _IORegistryEntryCreateCFProperty(io_registry_entry_t entry, CFStringRef key, CFAllocatorRef allocator, IOOptionBits options)
258 {
259 #undef IORegistryEntryCreateCFProperty
260 static typeof (IORegistryEntryCreateCFProperty) *dyfunc = NULL;
261 if (!dyfunc) {
262 void *image = __loadIOKit();
263 if (image) dyfunc = dlsym(image, "IORegistryEntryCreateCFProperty");
264 }
265 return dyfunc ? dyfunc(entry, key, allocator, options) : NULL;
266 }
267
268
269 __private_extern__ kern_return_t
270 _IORegistryEntryCreateCFProperties(io_registry_entry_t entry, CFMutableDictionaryRef *properties, CFAllocatorRef allocator, IOOptionBits options)
271 {
272 #undef IORegistryEntryCreateCFProperties
273 static typeof (IORegistryEntryCreateCFProperties) *dyfunc = NULL;
274 if (!dyfunc) {
275 void *image = __loadIOKit();
276 if (image) dyfunc = dlsym(image, "IORegistryEntryCreateCFProperties");
277 }
278 return dyfunc ? dyfunc(entry, properties, allocator, options) : KERN_FAILURE;
279 }
280
281
282 __private_extern__ kern_return_t
283 _IORegistryEntryCreateIterator(mach_port_t masterPort, const io_name_t plane, IOOptionBits options, io_iterator_t *iterator)
284 {
285 #undef IORegistryEntryCreateIterator
286 static typeof (IORegistryEntryCreateIterator) *dyfunc = NULL;
287 if (!dyfunc) {
288 void *image = __loadIOKit();
289 if (image) dyfunc = dlsym(image, "IORegistryEntryCreateIterator");
290 }
291 return dyfunc ? dyfunc(masterPort, plane, options, iterator) : KERN_FAILURE;
292 }
293
294
295 __private_extern__ kern_return_t
296 _IORegistryEntryGetLocationInPlane(io_registry_entry_t entry, const io_name_t plane, io_name_t location)
297 {
298 #undef IORegistryEntryGetLocationInPlane
299 static typeof (IORegistryEntryGetLocationInPlane) *dyfunc = NULL;
300 if (!dyfunc) {
301 void *image = __loadIOKit();
302 if (image) dyfunc = dlsym(image, "IORegistryEntryGetLocationInPlane");
303 }
304 return dyfunc ? dyfunc(entry, plane, location) : KERN_FAILURE;
305 }
306
307
308 __private_extern__ kern_return_t
309 _IORegistryEntryGetName(io_registry_entry_t entry, io_name_t name)
310 {
311 #undef IORegistryEntryGetName
312 static typeof (IORegistryEntryGetName) *dyfunc = NULL;
313 if (!dyfunc) {
314 void *image = __loadIOKit();
315 if (image) dyfunc = dlsym(image, "IORegistryEntryGetName");
316 }
317 return dyfunc ? dyfunc(entry, name) : KERN_FAILURE;
318 }
319
320
321 __private_extern__ kern_return_t
322 _IORegistryEntryGetNameInPlane(io_registry_entry_t entry, const io_name_t plane, io_name_t name)
323 {
324 #undef IORegistryEntryGetNameInPlane
325 static typeof (IORegistryEntryGetNameInPlane) *dyfunc = NULL;
326 if (!dyfunc) {
327 void *image = __loadIOKit();
328 if (image) dyfunc = dlsym(image, "IORegistryEntryGetNameInPlane");
329 }
330 return dyfunc ? dyfunc(entry, plane, name) : KERN_FAILURE;
331 }
332
333
334 __private_extern__ kern_return_t
335 _IORegistryEntryGetParentEntry(io_registry_entry_t entry, const io_name_t plane, io_registry_entry_t *parent)
336 {
337 #undef IORegistryEntryGetParentEntry
338 static typeof (IORegistryEntryGetParentEntry) *dyfunc = NULL;
339 if (!dyfunc) {
340 void *image = __loadIOKit();
341 if (image) dyfunc = dlsym(image, "IORegistryEntryGetParentEntry");
342 }
343 return dyfunc ? dyfunc(entry, plane, parent) : KERN_FAILURE;
344 }
345
346
347 __private_extern__ kern_return_t
348 _IORegistryEntryGetPath(io_registry_entry_t entry, const io_name_t plane, io_string_t path)
349 {
350 #undef IORegistryEntryGetPath
351 static typeof (IORegistryEntryGetPath) *dyfunc = NULL;
352 if (!dyfunc) {
353 void *image = __loadIOKit();
354 if (image) dyfunc = dlsym(image, "IORegistryEntryGetPath");
355 }
356 return dyfunc ? dyfunc(entry, plane, path) : KERN_FAILURE;
357 }
358
359
360 __private_extern__ kern_return_t
361 _IORegistryEntryGetRegistryEntryID(io_registry_entry_t entry, uint64_t *entryID)
362 {
363 #undef IORegistryEntryGetRegistryEntryID
364 static typeof (IORegistryEntryGetRegistryEntryID) *dyfunc = NULL;
365 if (!dyfunc) {
366 void *image = __loadIOKit();
367 if (image) dyfunc = dlsym(image, "IORegistryEntryGetRegistryEntryID");
368 }
369 return dyfunc ? dyfunc(entry, entryID) : KERN_FAILURE;
370 }
371
372
373 __private_extern__ CFTypeRef
374 _IORegistryEntrySearchCFProperty(io_registry_entry_t entry, const io_name_t plane, CFStringRef key, CFAllocatorRef allocator, IOOptionBits options)
375 {
376 #undef IORegistryEntrySearchCFProperty
377 static typeof (IORegistryEntrySearchCFProperty) *dyfunc = NULL;
378 if (!dyfunc) {
379 void *image = __loadIOKit();
380 if (image) dyfunc = dlsym(image, "IORegistryEntrySearchCFProperty");
381 }
382 return dyfunc ? dyfunc(entry, plane, key, allocator, options) : NULL;
383 }
384
385
386 __private_extern__ kern_return_t
387 _IOServiceGetMatchingServices(mach_port_t masterPort, CFDictionaryRef matching, io_iterator_t *existing)
388 {
389 #undef IOServiceGetMatchingServices
390 static typeof (IOServiceGetMatchingServices) *dyfunc = NULL;
391 if (!dyfunc) {
392 void *image = __loadIOKit();
393 if (image) dyfunc = dlsym(image, "IOServiceGetMatchingServices");
394 }
395 return dyfunc ? dyfunc(masterPort, matching, existing) : KERN_FAILURE;
396 }
397
398
399 __private_extern__ CFMutableDictionaryRef
400 _IOServiceMatching(const char *name)
401 {
402 #undef IOServiceMatching
403 static typeof (IOServiceMatching) *dyfunc = NULL;
404 if (!dyfunc) {
405 void *image = __loadIOKit();
406 if (image) dyfunc = dlsym(image, "IOServiceMatching");
407 }
408 return dyfunc ? dyfunc(name) : NULL;
409 }
410
411 #pragma mark -
412 #pragma mark Security.framework APIs
413
414 static void *
415 __loadSecurity(void) {
416 static void *image = NULL;
417 static dispatch_once_t once;
418
419 dispatch_once(&once, ^{
420 image = _SC_dlopen("/System/Library/Frameworks/Security.framework/Security");
421 });
422
423 return image;
424 }
425
426 #define SECURITY_FRAMEWORK_EXTERN(t, s) \
427 __private_extern__ t \
428 _ ## s() \
429 { \
430 static t *dysym = NULL; \
431 if (!dysym) { \
432 void *image = __loadSecurity(); \
433 if (image) dysym = dlsym(image, #s ); \
434 } \
435 return (dysym != NULL) ? *dysym : NULL; \
436 }
437
438 #if !TARGET_OS_IPHONE
439 SECURITY_FRAMEWORK_EXTERN(CFTypeRef, kSecAttrService)
440 SECURITY_FRAMEWORK_EXTERN(CFTypeRef, kSecClass)
441 SECURITY_FRAMEWORK_EXTERN(CFTypeRef, kSecClassGenericPassword)
442 SECURITY_FRAMEWORK_EXTERN(CFTypeRef, kSecMatchLimit)
443 SECURITY_FRAMEWORK_EXTERN(CFTypeRef, kSecMatchLimitAll)
444 SECURITY_FRAMEWORK_EXTERN(CFTypeRef, kSecMatchSearchList)
445 SECURITY_FRAMEWORK_EXTERN(CFTypeRef, kSecReturnRef)
446 SECURITY_FRAMEWORK_EXTERN(CFTypeRef, kSecGuestAttributePid)
447 SECURITY_FRAMEWORK_EXTERN(CFTypeRef, kSecCodeInfoIdentifier)
448 SECURITY_FRAMEWORK_EXTERN(CFTypeRef, kSecCodeInfoUnique)
449
450 __private_extern__ OSStatus
451 _AuthorizationMakeExternalForm(AuthorizationRef authorization, AuthorizationExternalForm *extForm)
452 {
453 #undef AuthorizationMakeExternalForm
454 static typeof (AuthorizationMakeExternalForm) *dyfunc = NULL;
455 if (!dyfunc) {
456 void *image = __loadSecurity();
457 if (image) dyfunc = dlsym(image, "AuthorizationMakeExternalForm");
458 }
459 return dyfunc ? dyfunc(authorization, extForm) : -1;
460 }
461
462 __private_extern__ OSStatus
463 _SecAccessCreate(CFStringRef descriptor, CFArrayRef trustedlist, SecAccessRef *accessRef)
464 {
465 #undef SecAccessCreate
466 static typeof (SecAccessCreate) *dyfunc = NULL;
467 if (!dyfunc) {
468 void *image = __loadSecurity();
469 if (image) dyfunc = dlsym(image, "SecAccessCreate");
470 }
471 return dyfunc ? dyfunc(descriptor, trustedlist, accessRef) : -1;
472 }
473
474 #if (__MAC_OS_X_VERSION_MIN_REQUIRED < 1070)
475 __private_extern__ OSStatus
476 _SecAccessCreateFromOwnerAndACL(const CSSM_ACL_OWNER_PROTOTYPE *owner, uint32 aclCount, const CSSM_ACL_ENTRY_INFO *acls, SecAccessRef *accessRef)
477 {
478 #undef SecAccessCreateFromOwnerAndACL
479 static typeof (SecAccessCreateFromOwnerAndACL) *dyfunc = NULL;
480 if (!dyfunc) {
481 void *image = __loadSecurity();
482 if (image) dyfunc = dlsym(image, "SecAccessCreateFromOwnerAndACL");
483 }
484 return dyfunc ? dyfunc(owner, aclCount, acls, accessRef) : -1;
485 }
486 #else // (__MAC_OS_X_VERSION_MIN_REQUIRED < 1070)
487 __private_extern__ SecAccessRef
488 _SecAccessCreateWithOwnerAndACL(uid_t userId, gid_t groupId, SecAccessOwnerType ownerType, CFArrayRef acls, CFErrorRef *error)
489 {
490 #undef SecAccessCreateWithOwnerAndACL
491 static typeof (SecAccessCreateWithOwnerAndACL) *dyfunc = NULL;
492 if (!dyfunc) {
493 void *image = __loadSecurity();
494 if (image) dyfunc = dlsym(image, "SecAccessCreateWithOwnerAndACL");
495 }
496 return dyfunc ? dyfunc(userId, groupId, ownerType, acls, error) : NULL;
497 }
498 #endif // (__MAC_OS_X_VERSION_MIN_REQUIRED < 1070)
499
500 __private_extern__ OSStatus
501 _SecItemCopyMatching(CFDictionaryRef query, CFTypeRef *result)
502 {
503 #undef SecItemCopyMatching
504 static typeof (SecItemCopyMatching) *dyfunc = NULL;
505 if (!dyfunc) {
506 void *image = __loadSecurity();
507 if (image) dyfunc = dlsym(image, "SecItemCopyMatching");
508 }
509 return dyfunc ? dyfunc(query, result) : -1;
510 }
511
512 __private_extern__ OSStatus
513 _SecKeychainCopyDomainDefault(SecPreferencesDomain domain, SecKeychainRef *keychain)
514 {
515 #undef SecKeychainCopyDomainDefault
516 static typeof (SecKeychainCopyDomainDefault) *dyfunc = NULL;
517 if (!dyfunc) {
518 void *image = __loadSecurity();
519 if (image) dyfunc = dlsym(image, "SecKeychainCopyDomainDefault");
520 }
521 return dyfunc ? dyfunc(domain, keychain) : -1;
522 }
523
524 __private_extern__ OSStatus
525 _SecKeychainOpen(const char *pathName, SecKeychainRef *keychain)
526 {
527 #undef SecKeychainOpen
528 static typeof (SecKeychainOpen) *dyfunc = NULL;
529 if (!dyfunc) {
530 void *image = __loadSecurity();
531 if (image) dyfunc = dlsym(image, "SecKeychainOpen");
532 }
533 return dyfunc ? dyfunc(pathName, keychain) : -1;
534 }
535
536 __private_extern__ OSStatus
537 _SecKeychainSetDomainDefault(SecPreferencesDomain domain, SecKeychainRef keychain)
538 {
539 #undef SecKeychainSetDomainDefault
540 static typeof (SecKeychainSetDomainDefault) *dyfunc = NULL;
541 if (!dyfunc) {
542 void *image = __loadSecurity();
543 if (image) dyfunc = dlsym(image, "SecKeychainSetDomainDefault");
544 }
545 return dyfunc ? dyfunc(domain, keychain) : -1;
546 }
547
548 __private_extern__ OSStatus
549 _SecKeychainItemCopyContent(SecKeychainItemRef itemRef, SecItemClass *itemClass, SecKeychainAttributeList *attrList, UInt32 *length, void **outData)
550 {
551 #undef SecKeychainItemCopyContent
552 static typeof (SecKeychainItemCopyContent) *dyfunc = NULL;
553 if (!dyfunc) {
554 void *image = __loadSecurity();
555 if (image) dyfunc = dlsym(image, "SecKeychainItemCopyContent");
556 }
557 return dyfunc ? dyfunc(itemRef, itemClass, attrList, length, outData) : -1;
558 }
559
560 __private_extern__ OSStatus
561 _SecKeychainItemCreateFromContent(SecItemClass itemClass, SecKeychainAttributeList *attrList, UInt32 length, const void *data, SecKeychainRef keychainRef, SecAccessRef initialAccess, SecKeychainItemRef *itemRef)
562 {
563 #undef SecKeychainItemCreateFromContent
564 static typeof (SecKeychainItemCreateFromContent) *dyfunc = NULL;
565 if (!dyfunc) {
566 void *image = __loadSecurity();
567 if (image) dyfunc = dlsym(image, "SecKeychainItemCreateFromContent");
568 }
569 return dyfunc ? dyfunc(itemClass, attrList, length, data, keychainRef, initialAccess, itemRef) : -1;
570 }
571
572 __private_extern__ OSStatus
573 _SecKeychainItemDelete(SecKeychainItemRef itemRef)
574 {
575 #undef SecKeychainItemDelete
576 static typeof (SecKeychainItemDelete) *dyfunc = NULL;
577 if (!dyfunc) {
578 void *image = __loadSecurity();
579 if (image) dyfunc = dlsym(image, "SecKeychainItemDelete");
580 }
581 return dyfunc ? dyfunc(itemRef) : -1;
582 }
583
584 __private_extern__ OSStatus
585 _SecKeychainItemFreeContent(SecKeychainAttributeList *attrList, void *data)
586 {
587 #undef SecKeychainItemFreeContent
588 static typeof (SecKeychainItemFreeContent) *dyfunc = NULL;
589 if (!dyfunc) {
590 void *image = __loadSecurity();
591 if (image) dyfunc = dlsym(image, "SecKeychainItemFreeContent");
592 }
593 return dyfunc ? dyfunc(attrList, data) : -1;
594 }
595
596 __private_extern__ OSStatus
597 _SecKeychainItemModifyContent(SecKeychainItemRef itemRef, const SecKeychainAttributeList *attrList, UInt32 length, const void *data)
598 {
599 #undef SecKeychainItemModifyContent
600 static typeof (SecKeychainItemModifyContent) *dyfunc = NULL;
601 if (!dyfunc) {
602 void *image = __loadSecurity();
603 if (image) dyfunc = dlsym(image, "SecKeychainItemModifyContent");
604 }
605 return dyfunc ? dyfunc(itemRef, attrList, length, data) : -1;
606 }
607
608
609 __private_extern__ OSStatus
610 _SecTrustedApplicationCreateFromPath(const char *path, SecTrustedApplicationRef *app)
611 {
612 #undef SecTrustedApplicationCreateFromPath
613 static typeof (SecTrustedApplicationCreateFromPath) *dyfunc = NULL;
614 if (!dyfunc) {
615 void *image = __loadSecurity();
616 if (image) dyfunc = dlsym(image, "SecTrustedApplicationCreateFromPath");
617 }
618 return dyfunc ? dyfunc(path, app) : -1;
619 }
620
621 #else // TARGET_OS_IPHONE
622
623 SECURITY_FRAMEWORK_EXTERN(CFStringRef, kSecPropertyKeyValue)
624 SECURITY_FRAMEWORK_EXTERN(CFStringRef, kSecPropertyKeyLabel)
625
626 __private_extern__ CFArrayRef
627 _SecCertificateCopyProperties(SecCertificateRef certRef)
628 {
629 #undef SecCertificateCopyProperties
630 static typeof (SecCertificateCopyProperties) *dyfunc = NULL;
631 if (!dyfunc) {
632 void *image = __loadSecurity();
633 if (image) dyfunc = dlsym(image, "SecCertificateCopyProperties");
634 }
635 return dyfunc ? dyfunc(certRef) : NULL;
636 }
637
638 #endif // TARGET_OS_IPHONE
639
640 __private_extern__ SecCertificateRef
641 _SecCertificateCreateWithData(CFAllocatorRef allocator, CFDataRef data)
642 {
643 #undef SecCertificateCreateWithData
644 static typeof (SecCertificateCreateWithData) *dyfunc = NULL;
645 if (!dyfunc) {
646 void *image = __loadSecurity();
647 if (image) dyfunc = dlsym(image, "SecCertificateCreateWithData");
648 }
649 return dyfunc ? dyfunc(allocator, data) : NULL;
650 }
651
652
653
654