+
+#define COM_APPLE "com.apple."
+
+__private_extern__ void
+load_security_extensions (void)
+{
+ OSDictionary * extensionsDict = NULL; // don't release
+ OSCollectionIterator* keyIterator = NULL; // must release
+ OSString * key = NULL; // don't release
+ OSDictionary * extDict; // don't release
+ OSDictionary * extPlist; // don't release
+ OSBoolean * isSec = 0; // don't release
+ Boolean ret;
+
+ extensionsDict = getStartupExtensions();
+ if (!extensionsDict) {
+ IOLog("startup extensions dictionary is missing\n");
+ LOG_DELAY(1);
+ return;
+ }
+
+ keyIterator = OSCollectionIterator::withCollection(extensionsDict);
+ if (!keyIterator) {
+ IOLog("Error: Failed to allocate iterator for extensions.\n");
+ LOG_DELAY(1);
+ return;
+ }
+
+ while ((key = OSDynamicCast(OSString, keyIterator->getNextObject()))) {
+
+ const char * bundle_id = key->getCStringNoCopy();
+
+ /* Skip extensions whose bundle IDs don't start with "com.apple.".
+ */
+ if (!bundle_id || (strncmp(bundle_id, COM_APPLE, strlen(COM_APPLE)) != 0)) {
+ continue;
+ }
+
+ extDict = OSDynamicCast(OSDictionary, extensionsDict->getObject(key));
+ if (!extDict) {
+ IOLog("extension \"%s\" cannot be found\n",
+ key->getCStringNoCopy());
+ continue;
+ }
+
+ extPlist = OSDynamicCast(OSDictionary, extDict->getObject("plist"));
+ if (!extPlist) {
+ IOLog("extension \"%s\" has no info dictionary\n",
+ key->getCStringNoCopy());
+ continue;
+ }
+
+ isSec = OSDynamicCast(OSBoolean,
+ extPlist->getObject("AppleSecurityExtension"));
+ if (isSec && isSec->isTrue()) {
+ printf("Loading security extension %s\n", key->getCStringNoCopy());
+ ret = kmod_load_request(key->getCStringNoCopy(), false);
+ if (!ret) {
+ load_kernel_extension((char *)key->getCStringNoCopy());
+ }
+ }
+ }
+
+ if (keyIterator)
+ keyIterator->release();
+
+ return;
+}