+
+ // Extract information from pid and audit token as presented. We need at least one.
+ // If both are specified, we pass them both to the kernel, which will fail if they
+ // don't agree.
+ if (auditData && CFDataGetLength(auditData) != sizeof(audit_token_t))
+ MacOSError::throwMe(errSecCSInvalidAttributeValues);
+ pid_t pid = 0;
+ audit_token_t* audit = NULL;
+ if (pidNumber)
+ pid = cfNumber<pid_t>(pidNumber);
+ if (auditData)
+ audit = (audit_token_t*)CFDataGetBytePtr(auditData);
+ if (audit && pid == 0)
+ pid = audit_token_to_pid(*audit);
+
+ // handle requests for server-based validation
+ RefPointer<PidDiskRep> diskRep = NULL;
+ 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(pid, audit, diskRep))->retain();
+#else
+ MacOSError::throwMe(errSecCSUnimplemented);
+#endif