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