From 9bd1a75b2d38dce78c310d6ecbe30622e47f5319 Mon Sep 17 00:00:00 2001 From: Moussa Ouallaf Date: Fri, 17 Jul 2026 02:43:21 +0200 Subject: [PATCH] build(deps): fix pkg-config skew, libusb include, libplist/libirecovery drift Sync PKGCONFIG_DEPS with Makefile (add libcurl); normalize include across 6 files; add compat shims for libplist 2.2/2.3 and libirecovery IRECV_SEND_OPT_DFU_NOTIFY_FINISH; add pacman/zypper/apk installer branches; drop bogus info->pid read in path_b_identity.c in favor of irecv_get_mode(). Extend the mock libirecovery to expose irecv_get_mode() so the mock test build keeps passing against the new call site. Add Makefile compile canaries that emit -DTP_PLIST_HAS_MEM_FREE, -DTP_PLIST_HAS_FMT_ARG, and -DTP_IRECV_HAS_NOTIFY_FINISH plus a .build-flags diagnostic file consumed by tr4mpass doctor. Files modified: - Makefile - start.sh - start-helpers.sh - include/compat/plist_compat.h (new) - include/compat/libirecovery_compat.h (new) - include/util/usb_helpers.h - include/util/plist_helpers.h - include/exploit/dfu_proto.h - include/device/device.h - include/device/usb_dfu.h - include/activation/activation.h - include/activation/record.h - src/bypass/path_b_identity.c - src/bypass/path_b.c - src/bypass/path_a_ramdisk.c - src/activation/session_online.c - tests/mocks/mock_irecv_sym.c - .gitignore Closes: #70, #74, #67, #54, #51, #44, #21, #55, #31, #24, #19 --- .gitignore | 1 + Makefile | 59 +++++++++++++++++-- include/activation/activation.h | 2 +- include/activation/record.h | 2 +- include/compat/libirecovery_compat.h | 28 +++++++++ include/compat/plist_compat.h | 59 +++++++++++++++++++ include/device/device.h | 2 +- include/device/usb_dfu.h | 2 +- include/exploit/dfu_proto.h | 2 +- include/util/plist_helpers.h | 2 +- include/util/usb_helpers.h | 2 +- src/activation/session_online.c | 10 ++-- src/bypass/path_a_ramdisk.c | 10 +++- src/bypass/path_b.c | 2 +- src/bypass/path_b_identity.c | 23 ++++---- start-helpers.sh | 85 ++++++++++++++++++++++------ start.sh | 1 + tests/mocks/mock_irecv_sym.c | 12 ++++ 18 files changed, 257 insertions(+), 47 deletions(-) create mode 100644 include/compat/libirecovery_compat.h create mode 100644 include/compat/plist_compat.h diff --git a/.gitignore b/.gitignore index f1b8a47..528ca92 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ itr4m tr4mpass tests/run_tests tests/run_mock_tests +.build-flags # OS files .DS_Store diff --git a/Makefile b/Makefile index 175cbeb..edf8c9b 100644 --- a/Makefile +++ b/Makefile @@ -11,12 +11,41 @@ LDFLAGS += $(shell pkg-config --libs $(PKG_LIBS) 2>/dev/null) $(foreach lib,$(PKG_LIBS),$(if $(shell pkg-config --exists $(lib) 2>/dev/null && echo ok),,$(warning Library $(lib) not found by pkg-config))) +# ------------------------------------------------------------------ # +# Feature probes for optional library symbols. # +# # +# libplist 2.3 added plist_mem_free() and a 4-arg plist_from_memory. # +# Older libirecovery lacked IRECV_SEND_OPT_DFU_NOTIFY_FINISH. # +# We probe by compiling a canary; on success we emit -D flags so the # +# include/compat/*.h shims pick the right branch. Results are also # +# written to .build-flags for `tr4mpass doctor` (task 005) to # +# surface at runtime. # +# ------------------------------------------------------------------ # + +PROBE_CFLAGS := $(shell pkg-config --cflags libplist-2.0 libirecovery-1.0 2>/dev/null) + +# `#` is a make comment even inside $(shell ...), so emit the `#include` +# via printf's octal escape (\043). +HAVE_PLIST_MEM_FREE := $(shell printf '\043include \nint main(void){plist_mem_free((void*)0);return 0;}\n' | $(CC) $(PROBE_CFLAGS) -x c -c - -o /dev/null 2>/dev/null && echo 1 || echo 0) +HAVE_PLIST_FROM_MEM4 := $(shell printf '\043include \nint main(void){plist_t p=0; plist_from_memory("",0,&p,(plist_format_t*)0);return 0;}\n' | $(CC) $(PROBE_CFLAGS) -x c -c - -o /dev/null 2>/dev/null && echo 1 || echo 0) +HAVE_IRECV_NOTIFY := $(shell printf '\043include \nint main(void){return (int)IRECV_SEND_OPT_DFU_NOTIFY_FINISH;}\n' | $(CC) $(PROBE_CFLAGS) -x c -c - -o /dev/null 2>/dev/null && echo 1 || echo 0) + +ifeq ($(HAVE_PLIST_MEM_FREE),1) + CFLAGS += -DTP_PLIST_HAS_MEM_FREE=1 +endif +ifeq ($(HAVE_PLIST_FROM_MEM4),1) + CFLAGS += -DTP_PLIST_HAS_FMT_ARG=1 +endif +ifeq ($(HAVE_IRECV_NOTIFY),1) + CFLAGS += -DTP_IRECV_HAS_NOTIFY_FINISH=1 +endif + # Auto-discover all C sources under src/ SRCS = $(shell find src -name '*.c') OBJS = $(SRCS:.c=.o) TARGET = tr4mpass -all: $(TARGET) +all: .build-flags $(TARGET) $(TARGET): $(OBJS) $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) @@ -24,9 +53,16 @@ $(TARGET): $(OBJS) %.o: %.c $(CC) $(CFLAGS) -Iinclude -c -o $@ $< +# .build-flags is a diagnostic file consumed by `tr4mpass doctor`. +# It records which optional symbols the probes detected on this host. +.build-flags: + @printf 'HAVE_PLIST_MEM_FREE=%s\n' '$(HAVE_PLIST_MEM_FREE)' > $@ + @printf 'HAVE_PLIST_FROM_MEM4=%s\n' '$(HAVE_PLIST_FROM_MEM4)' >> $@ + @printf 'HAVE_IRECV_NOTIFY_FINISH=%s\n' '$(HAVE_IRECV_NOTIFY)' >> $@ + clean: find src -name '*.o' -delete - rm -f $(TARGET) $(TEST_TARGET) $(MOCK_TARGET) + rm -f $(TARGET) $(TEST_TARGET) $(MOCK_TARGET) .build-flags find tests -name '*.o' -delete 2>/dev/null || true # ------------------------------------------------------------------ # @@ -88,10 +124,25 @@ MOCK_TARGET = tests/run_mock_tests # Only link libs that the SUT still needs at runtime and we did NOT mock. MOCK_PKG_LIBS = libplist-2.0 openssl +# Headers-only pkg-config libs: symbols are mocked so we do NOT link them, +# but SUT sources still #include their public headers, so we need the +# include paths at compile time. libusb-1.0 lives under +# /include/libusb-1.0/ on every distro; without the -I flag the +# `#include ` in include/device/device.h cannot be resolved. +MOCK_HEADER_LIBS = libusb-1.0 libimobiledevice-1.0 libirecovery-1.0 libssh2 libcurl MOCK_CFLAGS = -Wall -Wextra -std=c99 -D_GNU_SOURCE -O2 \ - $(shell pkg-config --cflags $(MOCK_PKG_LIBS) 2>/dev/null) \ + $(shell pkg-config --cflags $(MOCK_PKG_LIBS) $(MOCK_HEADER_LIBS) 2>/dev/null) \ -Iinclude -Itests -Itests/integration -Itests/mocks \ -DTEST_MODE -DUNIT_TEST +ifeq ($(HAVE_PLIST_MEM_FREE),1) + MOCK_CFLAGS += -DTP_PLIST_HAS_MEM_FREE=1 +endif +ifeq ($(HAVE_PLIST_FROM_MEM4),1) + MOCK_CFLAGS += -DTP_PLIST_HAS_FMT_ARG=1 +endif +ifeq ($(HAVE_IRECV_NOTIFY),1) + MOCK_CFLAGS += -DTP_IRECV_HAS_NOTIFY_FINISH=1 +endif MOCK_LDFLAGS = $(shell pkg-config --libs $(MOCK_PKG_LIBS) 2>/dev/null) test-mocks: $(MOCK_TARGET) @@ -100,4 +151,4 @@ test-mocks: $(MOCK_TARGET) $(MOCK_TARGET): $(MOCK_ALL_SRCS) $(CC) $(MOCK_CFLAGS) -o $@ $^ $(MOCK_LDFLAGS) -.PHONY: all clean test test-mocks +.PHONY: all clean test test-mocks .build-flags diff --git a/include/activation/activation.h b/include/activation/activation.h index f17343e..d0f8a2f 100644 --- a/include/activation/activation.h +++ b/include/activation/activation.h @@ -11,7 +11,7 @@ #include #include -#include +#include "compat/plist_compat.h" #include #include #include "device/device.h" diff --git a/include/activation/record.h b/include/activation/record.h index 00035b9..5ac783d 100644 --- a/include/activation/record.h +++ b/include/activation/record.h @@ -11,7 +11,7 @@ #define RECORD_H #include -#include +#include "compat/plist_compat.h" #include #include "device/device.h" diff --git a/include/compat/libirecovery_compat.h b/include/compat/libirecovery_compat.h new file mode 100644 index 0000000..c6c721c --- /dev/null +++ b/include/compat/libirecovery_compat.h @@ -0,0 +1,28 @@ +#ifndef TP_LIBIRECOVERY_COMPAT_H +#define TP_LIBIRECOVERY_COMPAT_H + +/* + * libirecovery_compat.h -- libirecovery API drift shim. + * + * Older libirecovery releases lacked IRECV_SEND_OPT_DFU_NOTIFY_FINISH, + * the send-flag that instructs irecv_send_file() to terminate a DFU + * transfer with a zero-length packet. The Makefile probes for the + * symbol and passes -DTP_IRECV_HAS_NOTIFY_FINISH when present. + * + * When absent we provide a no-op flag value and set + * TP_IRECV_NEEDS_MANUAL_ZLP=1 so callers can send the ZLP by hand + * after irecv_send_file() returns. + */ + +#include + +#ifdef TP_IRECV_HAS_NOTIFY_FINISH + #define TP_IRECV_NEEDS_MANUAL_ZLP 0 +#else + #ifndef IRECV_SEND_OPT_DFU_NOTIFY_FINISH + #define IRECV_SEND_OPT_DFU_NOTIFY_FINISH 0 + #endif + #define TP_IRECV_NEEDS_MANUAL_ZLP 1 +#endif + +#endif /* TP_LIBIRECOVERY_COMPAT_H */ diff --git a/include/compat/plist_compat.h b/include/compat/plist_compat.h new file mode 100644 index 0000000..2ba7812 --- /dev/null +++ b/include/compat/plist_compat.h @@ -0,0 +1,59 @@ +#ifndef TP_PLIST_COMPAT_H +#define TP_PLIST_COMPAT_H + +/* + * plist_compat.h -- libplist API drift shim. + * + * libplist 2.3.0 introduced plist_mem_free() and expanded + * plist_from_memory() to a 4-arg form that also reports the parsed + * format. Older distros still ship 2.2.x, so we detect both at build + * time. The Makefile runs compile canaries and passes + * -DTP_PLIST_HAS_MEM_FREE / -DTP_PLIST_HAS_FMT_ARG when the installed + * header provides them; the header falls back otherwise. + * + * Callers should: + * - free plist-allocated buffers via plist_mem_free() (falls back + * to free() when the symbol is unavailable) + * - parse in-memory plists via tp_plist_from_memory(), which maps + * to the 3-arg or 4-arg form as detected at build time. + */ + +#include +#include + +#ifndef TP_PLIST_HAS_MEM_FREE + /* Pre-2.3: no plist_mem_free(); libplist used plain malloc/free. */ + #ifndef plist_mem_free + #define plist_mem_free(p) free(p) + #endif +#endif + +static inline void tp_plist_mem_free(void *p) +{ + if (p) plist_mem_free(p); +} + +#ifdef TP_PLIST_HAS_FMT_ARG + /* 4-arg form: (data, length, out, format_out). */ + static inline int tp_plist_from_memory(const char *data, + uint32_t length, + plist_t *out, + plist_format_t *fmt_out) + { + return (int)plist_from_memory(data, length, out, fmt_out); + } +#else + /* Pre-2.3: 3-arg form; format_out is ignored because the older + * API cannot report the parsed format. + */ + static inline int tp_plist_from_memory(const char *data, + uint32_t length, + plist_t *out, + void *fmt_out) + { + (void)fmt_out; + return (int)plist_from_memory(data, length, out); + } +#endif + +#endif /* TP_PLIST_COMPAT_H */ diff --git a/include/device/device.h b/include/device/device.h index 8b1c759..1f74845 100644 --- a/include/device/device.h +++ b/include/device/device.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include #define DEVICE_FIELD_LEN 128 #define DEVICE_UDID_LEN 64 diff --git a/include/device/usb_dfu.h b/include/device/usb_dfu.h index 2da7eac..4009653 100644 --- a/include/device/usb_dfu.h +++ b/include/device/usb_dfu.h @@ -3,7 +3,7 @@ #include #include -#include +#include /* Apple USB identifiers */ #define APPLE_VID 0x05AC diff --git a/include/exploit/dfu_proto.h b/include/exploit/dfu_proto.h index 1685e53..685f781 100644 --- a/include/exploit/dfu_proto.h +++ b/include/exploit/dfu_proto.h @@ -5,7 +5,7 @@ #include #include -#include +#include /* ------------------------------------------------------------------ */ /* DFU class-specific request codes (USB DFU 1.1 spec, Table 3.2) */ diff --git a/include/util/plist_helpers.h b/include/util/plist_helpers.h index 0ce6cc3..9fd194a 100644 --- a/include/util/plist_helpers.h +++ b/include/util/plist_helpers.h @@ -2,7 +2,7 @@ #define PLIST_HELPERS_H #include -#include +#include "compat/plist_compat.h" /* * Retrieve a string value from a plist dict by key. diff --git a/include/util/usb_helpers.h b/include/util/usb_helpers.h index 30b6710..768e013 100644 --- a/include/util/usb_helpers.h +++ b/include/util/usb_helpers.h @@ -2,7 +2,7 @@ #define USB_HELPERS_H #include -#include +#include /* * Perform a USB control transfer with a data stage. diff --git a/src/activation/session_online.c b/src/activation/session_online.c index c011215..b7f8d55 100644 --- a/src/activation/session_online.c +++ b/src/activation/session_online.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include "compat/plist_compat.h" #include "activation/session.h" #include "device/device.h" @@ -116,7 +116,7 @@ int session_drm_handshake_online(device_info_t *dev, plist_t session_info, log_info("[session_online] Got %zu bytes from drmHandshake", resp.len); - plist_from_memory((const char *)resp.data, (uint32_t)resp.len, + tp_plist_from_memory((const char *)resp.data, (uint32_t)resp.len, handshake_response, NULL); free(resp.data); @@ -184,7 +184,7 @@ int session_device_activation_online(device_info_t *dev, log_info("[session_online] Got %zu bytes from deviceActivation", resp.len); - plist_from_memory((const char *)resp.data, (uint32_t)resp.len, + tp_plist_from_memory((const char *)resp.data, (uint32_t)resp.len, activation_record, NULL); free(resp.data); @@ -292,7 +292,7 @@ int session_probe_albert(device_info_t *dev, plist_t session_info) if (cb_data && cb_len > 0) { /* CollectionBlob bytes are themselves an XML plist */ plist_t cb_plist = NULL; - plist_from_memory(cb_data, (uint32_t)cb_len, &cb_plist, NULL); + tp_plist_from_memory(cb_data, (uint32_t)cb_len, &cb_plist, NULL); if (cb_plist) { plist_t ib = plist_dict_get_item(cb_plist, "IngestBody"); @@ -380,7 +380,7 @@ skip_ingest: resp.len); /* Parse and dump top-level keys of the handshake response */ - plist_from_memory((const char *)resp.data, (uint32_t)resp.len, + tp_plist_from_memory((const char *)resp.data, (uint32_t)resp.len, &hs_resp, NULL); free(resp.data); diff --git a/src/bypass/path_a_ramdisk.c b/src/bypass/path_a_ramdisk.c index d54793b..1b04b51 100644 --- a/src/bypass/path_a_ramdisk.c +++ b/src/bypass/path_a_ramdisk.c @@ -33,7 +33,7 @@ #include #include -#include +#include "compat/libirecovery_compat.h" #include "bypass/path_a_internal.h" #include "bypass/path_a_ramdisk_internal.h" @@ -146,6 +146,14 @@ send_staged_image(irecv_client_t client, const char *path, label, irecv_strerror(err)); return -1; } +#if TP_IRECV_NEEDS_MANUAL_ZLP + /* Older libirecovery cannot request the DFU notify-finish ZLP via + * the send flag, so emit one by hand to mark end-of-transfer. */ + { + unsigned char zlp = 0; + (void)irecv_send_buffer(client, &zlp, 0, 0); + } +#endif return 0; } diff --git a/src/bypass/path_b.c b/src/bypass/path_b.c index fa5d1e5..75696ac 100644 --- a/src/bypass/path_b.c +++ b/src/bypass/path_b.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/bypass/path_b_identity.c b/src/bypass/path_b_identity.c index e9d8f77..0a2a113 100644 --- a/src/bypass/path_b_identity.c +++ b/src/bypass/path_b_identity.c @@ -9,8 +9,8 @@ #include #include #include -#include -#include +#include +#include "compat/libirecovery_compat.h" #include "bypass/path_b.h" #include "device/usb_dfu.h" @@ -30,9 +30,6 @@ /* Maximum USB string descriptor length per USB 2.0 spec */ #define USB_DESC_MAX_LEN 255 -/* Apple recovery mode USB product ID */ -#define APPLE_RECOVERY_PID 0x1281 - /* * usb_get_string_descriptor -- GET_DESCRIPTOR control transfer for a * USB string descriptor. Returns bytes received, or -1 on error. @@ -185,7 +182,7 @@ int path_b_write_serial_irecovery(device_info_t *dev, const char *new_serial) { irecv_client_t client = NULL; irecv_error_t err; - const struct irecv_device_info *info; + int mode = 0; char cmd[DFU_SERIAL_MAX + 32]; int rc = -1; @@ -207,11 +204,15 @@ int path_b_write_serial_irecovery(device_info_t *dev, const char *new_serial) return -1; } - /* Verify the device is actually in recovery (not DFU or normal) */ - info = irecv_get_device_info(client); - if (!info || info->pid != APPLE_RECOVERY_PID) { - log_error("[path_b_id] Device is not in recovery mode (pid=0x%04X)", - info ? (unsigned)info->pid : 0); + /* Verify the device is actually in recovery (not DFU or normal). + * struct irecv_device_info has no pid field on any released + * libirecovery; query the mode via irecv_get_mode() instead and + * accept any of the four recovery-mode PIDs (0x1280..0x1283). */ + err = irecv_get_mode(client, &mode); + if (err != IRECV_E_SUCCESS || + mode < IRECV_K_RECOVERY_MODE_1 || mode > IRECV_K_RECOVERY_MODE_4) { + log_error("[path_b_id] Device is not in recovery mode (mode=0x%04X, err=%s)", + (unsigned)mode, irecv_strerror(err)); irecv_close(client); return -1; } diff --git a/start-helpers.sh b/start-helpers.sh index ed29a0b..7b0b48d 100755 --- a/start-helpers.sh +++ b/start-helpers.sh @@ -75,8 +75,12 @@ detect_linux_pm() { LINUX_PM="dnf" elif command -v pacman >/dev/null 2>&1; then LINUX_PM="pacman" + elif command -v zypper >/dev/null 2>&1; then + LINUX_PM="zypper" + elif command -v apk >/dev/null 2>&1; then + LINUX_PM="apk" else - msg_err "No supported package manager found (need apt, dnf, or pacman)." + msg_err "No supported package manager found (need apt, dnf, pacman, zypper, or apk)." exit 1 fi } @@ -101,14 +105,32 @@ install_deps_macos() { exit 1 fi - local brew_pkgs="libimobiledevice libirecovery libusb libplist openssl pkg-config libssh2" + local brew_pkgs="libimobiledevice libirecovery libusb libplist openssl curl pkg-config libssh2" msg_info "Installing dependencies via Homebrew..." brew install $brew_pkgs msg_ok "Homebrew dependencies installed." } +# openssl and curl are keg-only under Homebrew; their .pc files never +# land on the default pkg-config search path. Prepend the two prefixes +# so pkg-config can find libcrypto and libcurl without editing the +# Makefile. +macos_prep_pkgconfig() { + if ! command -v brew >/dev/null 2>&1; then + return 0 + fi + local ossl_prefix curl_prefix extra="" + ossl_prefix="$(brew --prefix openssl 2>/dev/null || true)" + curl_prefix="$(brew --prefix curl 2>/dev/null || true)" + [ -n "$ossl_prefix" ] && extra="${ossl_prefix}/lib/pkgconfig" + [ -n "$curl_prefix" ] && extra="${extra:+${extra}:}${curl_prefix}/lib/pkgconfig" + if [ -n "$extra" ]; then + export PKG_CONFIG_PATH="${extra}${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}" + fi +} + install_deps_linux_apt() { - local apt_pkgs="libimobiledevice-dev libirecovery-1.0-dev libusb-1.0-0-dev libplist-dev libssl-dev libssh2-1-dev pkg-config build-essential" + local apt_pkgs="libimobiledevice-dev libirecovery-1.0-dev libusb-1.0-0-dev libplist-dev libssl-dev libcurl4-openssl-dev libssh2-1-dev pkg-config build-essential" msg_info "Installing dependencies via apt..." sudo apt-get update -qq sudo apt-get install -y $apt_pkgs @@ -116,13 +138,38 @@ install_deps_linux_apt() { } install_deps_linux_dnf() { - local dnf_pkgs="libimobiledevice-devel libirecovery-devel libusb1-devel libplist-devel openssl-devel libssh2-devel pkg-config gcc make" + local dnf_pkgs="libimobiledevice-devel libirecovery-devel libusb1-devel libplist-devel openssl-devel libcurl-devel libssh2-devel pkg-config gcc make" msg_info "Installing dependencies via dnf..." sudo dnf install -y $dnf_pkgs msg_ok "DNF dependencies installed." } +install_deps_linux_pacman() { + local pacman_pkgs="libimobiledevice libirecovery libusb libplist openssl libssh2 curl pkgconf base-devel" + msg_info "Installing dependencies via pacman..." + sudo pacman -S --needed --noconfirm $pacman_pkgs + msg_ok "pacman dependencies installed." +} + +install_deps_linux_zypper() { + local zypper_pkgs="libimobiledevice-devel libirecovery-devel libusb-1_0-devel libplist-2_0-devel openssl-devel libssh2-devel libcurl-devel pkg-config gcc make" + msg_info "Installing dependencies via zypper..." + sudo zypper install -y $zypper_pkgs + msg_ok "zypper dependencies installed." +} + +install_deps_linux_apk() { + local apk_pkgs="libimobiledevice-dev libirecovery-dev libusb-dev libplist-dev openssl-dev libssh2-dev curl-dev pkgconfig gcc make musl-dev" + msg_info "Installing dependencies via apk..." + sudo apk add --no-cache $apk_pkgs + msg_ok "apk dependencies installed." +} + install_deps() { + if [ "$DETECTED_OS" = "macos" ]; then + macos_prep_pkgconfig + fi + if ! command -v pkg-config >/dev/null 2>&1; then msg_warn "pkg-config not found, installing it first..." case "$DETECTED_OS" in @@ -130,9 +177,11 @@ install_deps() { linux|wsl) detect_linux_pm case "$LINUX_PM" in - apt) sudo apt-get update -qq && sudo apt-get install -y pkg-config ;; - dnf) sudo dnf install -y pkg-config ;; - pacman) sudo pacman -S --noconfirm pkg-config ;; + apt) sudo apt-get update -qq && sudo apt-get install -y pkg-config ;; + dnf) sudo dnf install -y pkg-config ;; + pacman) sudo pacman -S --needed --noconfirm pkgconf ;; + zypper) sudo zypper install -y pkg-config ;; + apk) sudo apk add --no-cache pkgconfig ;; esac ;; esac @@ -148,19 +197,18 @@ install_deps() { msg_warn "Missing dependencies: ${MISSING_DEPS[*]}" case "$DETECTED_OS" in - macos) install_deps_macos ;; + macos) + install_deps_macos + macos_prep_pkgconfig + ;; linux|wsl) detect_linux_pm case "$LINUX_PM" in - apt) install_deps_linux_apt ;; - dnf) install_deps_linux_dnf ;; - pacman) - msg_warn "Arch Linux detected. Install from AUR:" - msg_info " yay -S libimobiledevice libirecovery libusb libplist openssl libssh2 pkg-config base-devel" - msg_info " or: paru -S libimobiledevice-git libirecovery-git libssh2" - msg_info "Re-run this script after installing." - exit 1 - ;; + apt) install_deps_linux_apt ;; + dnf) install_deps_linux_dnf ;; + pacman) install_deps_linux_pacman ;; + zypper) install_deps_linux_zypper ;; + apk) install_deps_linux_apk ;; esac ;; esac @@ -170,7 +218,8 @@ install_deps() { msg_err "Still missing after install: ${MISSING_DEPS[*]}" msg_info "Please install them manually and re-run this script." msg_info " libssh2 is required for Phase 2C SSH jailbreak delivery." - msg_info " If libssh2 was just installed, re-running should pick it up." + msg_info " libcurl is required for Albert activation server calls." + msg_info " If either was just installed, re-running should pick it up." exit 1 fi diff --git a/start.sh b/start.sh index 9c078a7..b709bc5 100755 --- a/start.sh +++ b/start.sh @@ -40,6 +40,7 @@ PKGCONFIG_DEPS=( "libusb-1.0" "libplist-2.0" "openssl" + "libcurl" "libssh2" ) diff --git a/tests/mocks/mock_irecv_sym.c b/tests/mocks/mock_irecv_sym.c index 7a63e61..d73e177 100644 --- a/tests/mocks/mock_irecv_sym.c +++ b/tests/mocks/mock_irecv_sym.c @@ -114,6 +114,18 @@ const struct irecv_device_info *irecv_get_device_info(irecv_client_t client) return &client->info; } +irecv_error_t irecv_get_mode(irecv_client_t client, int *mode) +{ + mock_log_append("irecv_get_mode"); + if (!client || !mode) + return (irecv_error_t)-1; + /* Reflect the configured USB product ID: recovery PIDs live in + * 0x1280..0x1283, DFU is 0x1227. Callers compare against + * IRECV_K_RECOVERY_MODE_[1..4] which are the recovery PIDs. */ + *mode = (int)g_irecv_info_pid; + return IRECV_E_SUCCESS; +} + irecv_error_t irecv_send_command(irecv_client_t client, const char *command) { (void)client;