- if (CFDictionaryGetCount(attributes) != 1)
- MacOSError::throwMe(errSecCSUnsupportedGuestAttributes); // had more
- if (CFGetTypeID(attr) == CFNumberGetTypeID())
- return (new ProcessCode(cfNumber<pid_t>(CFNumberRef(attr))))->retain();
- MacOSError::throwMe(errSecCSInvalidAttributeValues);
+ RefPointer<PidDiskRep> diskRep = NULL;
+
+ if (CFGetTypeID(attr) != CFNumberGetTypeID())
+ MacOSError::throwMe(errSecCSInvalidAttributeValues);
+
+ pid_t pid = cfNumber<pid_t>(CFNumberRef(attr));
+
+ if (CFDictionaryGetValue(attributes, kSecGuestAttributeDynamicCode) != NULL) {
+ CFDataRef infoPlist = (CFDataRef)CFDictionaryGetValue(attributes, kSecGuestAttributeDynamicCodeInfoPlist);
+ if (infoPlist && CFGetTypeID(infoPlist) != CFDataGetTypeID())
+ MacOSError::throwMe(errSecCSInvalidAttributeValues);
+
+ try {
+ diskRep = new PidDiskRep(pid, infoPlist);
+ } catch (...) { }
+ }
+ return (new ProcessCode(cfNumber<pid_t>(CFNumberRef(attr)), diskRep))->retain();