Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

fix(cfw): three things the end-to-end review of the verbs found

Lakr29cefe70b171
diff --git a/cfw-kit/lib/common.sh b/cfw-kit/lib/common.sh
index 8ca0dcc8..7d446b35 100644
--- a/cfw-kit/lib/common.sh
+++ b/cfw-kit/lib/common.sh
@@ -183,8 +183,12 @@ preflight() {
# (missing argument) and 64 for a typo, and would actually RUN any verb
# that happens to need no arguments.
local -a have
- have=("${(@f)$("$VPHONE_CLI" cfw --help 2>&1 |
- awk '/^SUBCOMMANDS:/ {f = 1; next} f && /^ [a-z]/ {print $1}')}")
+ # (@f) on empty output yields one empty element, not an empty array, so
+ # a count test never fires. Drop empties first — that is what makes the
+ # "could not read the list" branch below reachable at all.
+ have=(${(@f)"$("$VPHONE_CLI" cfw --help 2>&1 |
+ awk '/^SUBCOMMANDS:/ {f = 1; next} f && /^ [a-z]/ {print $1}')"})
+ have=(${have:#})
if (( ${#have} == 0 )); then
warn "could not read the subcommand list from '$VPHONE_CLI cfw --help'"
fatal=1
diff --git a/research/0_binary_patch_comparison.md b/research/0_binary_patch_comparison.md
index c56fa689..bd63e4a7 100644
--- a/research/0_binary_patch_comparison.md
+++ b/research/0_binary_patch_comparison.md
@@ -371,6 +371,15 @@ hashed to `dfe38096…`, and the guest dies on the first demand-page-in of it.
`DSCFoundationTests.pageStraddlingWriteAttestsEveryDirtiedPage` pins both the fix
and the reference's value, so the divergence stays on the record.
+**One verb is semantically, not byte, identical.** `cfw inject-daemons` writes a
+plist, and the two XML writers disagree on one thing: Python's `plistlib`
+serialises an integral double as `<real>1.0</real>` where Foundation emits
+`<real>1</real>`. Both parse back to the same value, and matching the Python
+byte for byte would mean reimplementing `plistlib`'s writer — which is why the
+plan set the bar for plists at semantic equivalence (type, order, key set,
+`Data` bytes) rather than bytes. Recorded here so "byte-identical" is not read
+as covering the plist verbs.
+
**Two behavioural differences kept on purpose**, both on the already-patched path
and neither changing a byte:
diff --git a/sources/vphone-cli/VPhoneCreateOrchestrator.swift b/sources/vphone-cli/VPhoneCreateOrchestrator.swift
index 8ae68866..c3bf0758 100644
--- a/sources/vphone-cli/VPhoneCreateOrchestrator.swift
+++ b/sources/vphone-cli/VPhoneCreateOrchestrator.swift
@@ -484,6 +484,12 @@ public struct VPhoneCreateOrchestrator {
// <verb>` now, so nothing under this script reads a python. Asking for
// one here would only force a venv bootstrap nobody uses.
var scriptEnv: [String: String] = [
+ // What replaced it. The script re-execs under sudo, so it cannot
+ // work out where we live from its own path in the bundled case —
+ // same reason `cfw install` passes it (VPhoneRestoreCLI). Without
+ // it the script falls back to guessing, which works in a dev tree
+ // and in the .app but is a guess either way.
+ "VPHONE_CLI_BIN": VPhoneResources.runningExecutable().path,
"IPSW_DIR": resources.ipswCacheDir.path,
"VPHONE_SEAL_DIR": resources.sealVolumeCacheDir.path,
"VPHONE_DEBS_DIR": resources.debsCacheDir.path,
@@ -511,7 +517,7 @@ public struct VPhoneCreateOrchestrator {
var env = ProcessInfo.processInfo.environment
for (key, value) in scriptEnv { env[key] = value }
for (key, value) in sudoEnvExtras { env[key] = value }
- let envKeys = (["IPSW_DIR", "VPHONE_SEAL_DIR"] + sudoEnvExtras.keys.sorted())
+ let envKeys = (["VPHONE_CLI_BIN", "IPSW_DIR", "VPHONE_SEAL_DIR"] + sudoEnvExtras.keys.sorted())
.joined(separator: ", ")
trace("spawn /bin/zsh \(args.joined(separator: " ")) (env keys: \(envKeys))", v)
// With an askpass credential sudo is non-interactive → honor verbosity.