Run a virtual iPhone on an Apple Silicon Mac.
Swift
Restart installd too when the profile UDID changes
Lakr3cd176ea1834
diff --git a/VPhoneDaemon/Daemon/GuestAPI+DeviceIdentity.swift b/VPhoneDaemon/Daemon/GuestAPI+DeviceIdentity.swiftindex 40a714f4..7b67a648 100644--- a/VPhoneDaemon/Daemon/GuestAPI+DeviceIdentity.swift+++ b/VPhoneDaemon/Daemon/GuestAPI+DeviceIdentity.swift@@ -3,10 +3,10 @@ import Foundation// MARK: - Profile UDID-/// The UDID libmisfix gives misagent when it checks a provisioning profile's-/// `ProvisionedDevices` (`VPhoneGuestComponents/MISFix`). Lockdown, Xcode and-/// devicectl keep seeing the guest's own UDID; only the hooked daemon sees-/// this one.+/// The UDID libmisfix gives the hooked daemons when they check a provisioning+/// profile's `ProvisionedDevices` (`VPhoneGuestComponents/MISFix`). Lockdown,+/// Xcode and devicectl keep seeing the guest's own UDID; only the hooked+/// daemons see this one.////// The hook reads the first of two files that exists and re-reads it when its/// modification time or size changes. vphoned owns the data-volume file.@@ -14,15 +14,41 @@ import Foundation/// the file then still comes first, so a UDID left in the `/usr/lib` copy/// cannot take over again.///-/// A change also stops misagent, so the next profile check runs in a fresh-/// process that has cached nothing. launchd starts misagent on demand.-/// installd is left alone: it asks misagent, and stopping it would abort an-/// install in progress.+/// A change also stops every daemon that carries the hook, so the next check+/// runs in a fresh process that has cached nothing. launchd starts them on+/// demand.+///+/// That means installd as well as misagent, and it used to mean only misagent.+/// The reason given was that installd "asks misagent", and it does not: a+/// lockdown-path install runs+/// `+[MICodeSigningVerifier _validateSignatureAndCopyInfoForURL:withOptions:error:]`+/// inside installd, which calls `MISValidateSignatureAndCopyInfo` and evaluates+/// the profile's `ProvisionedDevices` itself. Two processes answer the UDID+/// question independently — which is why `cfw install` injects libmisfix into+/// both — so refreshing one and not the other leaves them disagreeing.+///+/// Measured on test-26.4 (2026-09-30): with the override changed to a UDID in+/// the profile and only misagent restarted, `_installEmbeddedProfilesWithError:`+/// passed and installd then failed the same install with `0xE8008015`, "A valid+/// provisioning profile for this executable was not found", because installd was+/// still holding the previous UDID from before the change.+///+/// Stopping installd can abort an install already in flight. That is the lesser+/// evil: changing the device's identity underneath a running install is+/// incoherent anyway, whereas leaving one of the two evaluators on a stale+/// answer fails later, somewhere else, with an error that does not mention the+/// UDID at all.extension GuestAPI {/// Must match `kConfigPaths` in `MISFixConfig.c`, in the same order.static let udidConfigPaths = ["/var/db/vphone/misfix.plist", "/usr/lib/libmisfix.plist"]static let udidConfigKey = "UniqueDeviceID"+ /// The daemons `cfw install` injects libmisfix into, and so the ones holding+ /// a UDID answer that a change has to invalidate. Keep in step with the+ /// `injectedDylibPath: "/usr/lib/libmisfix.dylib"` call sites in+ /// `VPhoneCustomFirmwareInstaller`.+ static let udidHookedDaemons = ["misagent", "installd"]+static func executeDeviceIdentity(_ method: String, _ params: [String: Any]) throws -> [String: Any]? {switch method {case "udid.get":@@ -40,14 +66,14 @@ extension GuestAPI {}/// Writes the setting, reads it back the way the hook resolves it, and- /// restarts misagent.+ /// restarts every daemon that carries the hook.private static func applyUDID(_ udid: String?) throws -> [String: Any] {try writeUDIDConfiguration(udid)var state = udidState()guard state["path"] as? String == udidConfigPaths[0], state["udid"] as? String == udid else {throw GuestAPIError.operationFailed("\(udidConfigPaths[0]) did not read back as written")}- state["restarted_pids"] = stopProcesses(named: "misagent")+ state["restarted_pids"] = udidHookedDaemons.flatMap { stopProcesses(named: $0) }return state}@@ -91,7 +117,8 @@ extension GuestAPI {} catch {throw GuestAPIError.operationFailed("Could not write \(path): \(error.localizedDescription)")}- // misagent and installd do not run as root; the hook only reads.+ // World-readable: the hook only ever reads, and this file has to be+ // reachable from whatever uid each hooked daemon runs under.chmod(path, 0o644)}}