build(deps): fix pkg-config skew, libusb include, libplist/libirecovery drift

Sync PKGCONFIG_DEPS with Makefile (add libcurl); normalize
<libusb.h> 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
This commit is contained in:
Moussa Ouallaf 2026-07-17 02:43:21 +02:00
parent d18b57a66f
commit 9bd1a75b2d
18 changed files with 257 additions and 47 deletions

View file

@ -4,7 +4,7 @@
#include <string.h>
#include <stdio.h>
#include <curl/curl.h>
#include <plist/plist.h>
#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);

View file

@ -33,7 +33,7 @@
#include <time.h>
#include <unistd.h>
#include <libirecovery.h>
#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;
}

View file

@ -14,7 +14,7 @@
#include <string.h>
#include <unistd.h>
#include <plist/plist.h>
#include <libusb-1.0/libusb.h>
#include <libusb.h>
#include <libimobiledevice/libimobiledevice.h>
#include <libirecovery.h>

View file

@ -9,8 +9,8 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <libusb-1.0/libusb.h>
#include <libirecovery.h>
#include <libusb.h>
#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;
}