From eda2c5ea71829f11d69342e6858d09aa53943938 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Fri, 21 Apr 2023 16:51:26 +0200 Subject: Updated to use latest libplist API changes --- common/userpref.c | 2 +- configure.ac | 2 +- src/lockdown-cu.c | 2 +- tools/idevicebackup.c | 23 ++++++++++++----------- tools/idevicebackup2.c | 9 +++++---- tools/idevicecrashreport.c | 2 +- tools/ideviceimagemounter.c | 41 ++++++----------------------------------- tools/ideviceinfo.c | 6 +++--- tools/idevicepair.c | 5 ++--- tools/ideviceprovision.c | 4 ++-- 10 files changed, 34 insertions(+), 62 deletions(-) diff --git a/common/userpref.c b/common/userpref.c index ddd380a..11e28ba 100644 --- a/common/userpref.c +++ b/common/userpref.c @@ -338,7 +338,7 @@ userpref_error_t userpref_read_pair_record(const char *udid, plist_t *pair_recor } *pair_record = NULL; - plist_from_memory(record_data, record_size, pair_record); + plist_from_memory(record_data, record_size, pair_record, NULL); free(record_data); if (!*pair_record) { diff --git a/configure.ac b/configure.ac index 503051f..8ba094a 100644 --- a/configure.ac +++ b/configure.ac @@ -26,7 +26,7 @@ fi dnl Minimum package versions LIBUSBMUXD_VERSION=2.0.2 -LIBPLIST_VERSION=2.2.0 +LIBPLIST_VERSION=2.3.0 LIMD_GLUE_VERSION=1.0.0 AC_SUBST(LIBUSBMUXD_VERSION) diff --git a/src/lockdown-cu.c b/src/lockdown-cu.c index 61a1c03..d8d7f42 100644 --- a/src/lockdown-cu.c +++ b/src/lockdown-cu.c @@ -1032,7 +1032,7 @@ LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_cu_send_request_and_get_reply(l plist_free(dict); dict = NULL; - plist_from_memory((const char*)decrypted, decrypted_len, &dict); + plist_from_memory((const char*)decrypted, decrypted_len, &dict, NULL); if (!dict) { ret = LOCKDOWN_E_PLIST_ERROR; debug_info("Failed to parse PLIST from decrypted payload:"); diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c index 2856fda..1684666 100644 --- a/tools/idevicebackup.c +++ b/tools/idevicebackup.c @@ -57,6 +57,7 @@ #include #include #include +#include #define MOBILEBACKUP_SERVICE_NAME "com.apple.mobilebackup" #define NP_SERVICE_NAME "com.apple.mobile.notification_proxy" @@ -317,7 +318,7 @@ static void mobilebackup_write_status(const char *path, int status) if (stat(file_path, &st) == 0) remove(file_path); - plist_write_to_filename(status_plist, file_path, PLIST_FORMAT_XML); + plist_write_to_file(status_plist, file_path, PLIST_FORMAT_XML, 0); plist_free(status_plist); status_plist = NULL; @@ -331,7 +332,7 @@ static int mobilebackup_read_status(const char *path) plist_t status_plist = NULL; char *file_path = mobilebackup_build_path(path, "Status", ".plist"); - plist_read_from_filename(&status_plist, file_path); + plist_read_from_file(file_path, &status_plist, NULL); free(file_path); if (!status_plist) { printf("Could not read Status.plist!\n"); @@ -454,7 +455,7 @@ static int mobilebackup_check_file_integrity(const char *backup_directory, const } infopath = mobilebackup_build_path(backup_directory, hash, ".mdinfo"); - plist_read_from_filename(&mdinfo, infopath); + plist_read_from_file(infopath, &mdinfo, NULL); free(infopath); if (!mdinfo) { printf("\r\n"); @@ -882,7 +883,7 @@ int main(int argc, char *argv[]) /* verify existing Info.plist */ if (stat(info_path, &st) == 0) { printf("Reading Info.plist from backup.\n"); - plist_read_from_filename(&info_plist, info_path); + plist_read_from_file(info_path, &info_plist, NULL); if (!info_plist) { printf("Could not read Info.plist\n"); @@ -893,7 +894,7 @@ int main(int argc, char *argv[]) /* update the last backup time within Info.plist */ mobilebackup_info_update_last_backup_date(info_plist); remove(info_path); - plist_write_to_filename(info_plist, info_path, PLIST_FORMAT_XML); + plist_write_to_file(info_plist, info_path, PLIST_FORMAT_XML, 0); } else { printf("Aborting backup. Backup is not compatible with the current device.\n"); cmd = CMD_LEAVE; @@ -959,7 +960,7 @@ int main(int argc, char *argv[]) /* read the last Manifest.plist */ if (!is_full_backup) { printf("Reading existing Manifest.\n"); - plist_read_from_filename(&manifest_plist, manifest_path); + plist_read_from_file(manifest_path, &manifest_plist, NULL); if (!manifest_plist) { printf("Could not read Manifest.plist, switching to full backup mode.\n"); is_full_backup = 1; @@ -977,7 +978,7 @@ int main(int argc, char *argv[]) remove(info_path); printf("Creating Info.plist for new backup.\n"); info_plist = mobilebackup_factory_info_plist_new(udid); - plist_write_to_filename(info_plist, info_path, PLIST_FORMAT_XML); + plist_write_to_file(info_plist, info_path, PLIST_FORMAT_XML, 0); } free(info_path); @@ -1116,7 +1117,7 @@ int main(int argc, char *argv[]) remove(filename_mdinfo); node = plist_dict_get_item(node_tmp, "BackupFileInfo"); - plist_write_to_filename(node, filename_mdinfo, PLIST_FORMAT_BINARY); + plist_write_to_file(node, filename_mdinfo, PLIST_FORMAT_BINARY, 0); free(filename_mdinfo); } @@ -1228,7 +1229,7 @@ files_out: if (manifest_plist) { remove(manifest_path); printf("Storing Manifest.plist...\n"); - plist_write_to_filename(manifest_plist, manifest_path, PLIST_FORMAT_XML); + plist_write_to_file(manifest_plist, manifest_path, PLIST_FORMAT_XML, 0); } backup_ok = 1; @@ -1259,7 +1260,7 @@ files_out: } /* now make sure backup integrity is ok! verify all files */ printf("Reading existing Manifest.\n"); - plist_read_from_filename(&manifest_plist, manifest_path); + plist_read_from_file(manifest_path, &manifest_plist, NULL); if (!manifest_plist) { printf("Could not read Manifest.plist. Aborting.\n"); break; @@ -1386,7 +1387,7 @@ files_out: while (node) { /* TODO: read mddata/mdinfo files and send to device using DLSendFile */ file_info_path = mobilebackup_build_path(backup_directory, hash, ".mdinfo"); - plist_read_from_filename(&file_info, file_info_path); + plist_read_from_file(file_info_path, &file_info, NULL); /* get encryption state */ tmp_node = plist_dict_get_item(file_info, "IsEncrypted"); diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c index 82dc90d..c73b269 100644 --- a/tools/idevicebackup2.c +++ b/tools/idevicebackup2.c @@ -47,6 +47,7 @@ #include #include #include +#include #include @@ -606,7 +607,7 @@ static int mb2_status_check_snapshot_state(const char *path, const char *udid, c plist_t status_plist = NULL; char *file_path = string_build_path(path, udid, "Status.plist", NULL); - plist_read_from_filename(&status_plist, file_path); + plist_read_from_file(file_path, &status_plist, NULL); free(file_path); if (!status_plist) { printf("Could not read Status.plist!\n"); @@ -1780,7 +1781,7 @@ int main(int argc, char *argv[]) free(info_path); } plist_t manifest_plist = NULL; - plist_read_from_filename(&manifest_plist, manifest_path); + plist_read_from_file(manifest_path, &manifest_plist, NULL); if (!manifest_plist) { idevice_free(device); free(info_path); @@ -1936,7 +1937,7 @@ int main(int argc, char *argv[]) /* verify existing Info.plist */ if (info_path && (stat(info_path, &st) == 0) && cmd != CMD_CLOUD) { PRINT_VERBOSE(1, "Reading Info.plist from backup.\n"); - plist_read_from_filename(&info_plist, info_path); + plist_read_from_file(info_path, &info_plist, NULL); if (!info_plist) { printf("Could not read Info.plist\n"); @@ -2030,7 +2031,7 @@ checkpoint: cmd = CMD_LEAVE; } remove_file(info_path); - plist_write_to_filename(info_plist, info_path, PLIST_FORMAT_XML); + plist_write_to_file(info_plist, info_path, PLIST_FORMAT_XML, 0); free(info_path); plist_free(info_plist); diff --git a/tools/idevicecrashreport.c b/tools/idevicecrashreport.c index d0d2147..484212e 100644 --- a/tools/idevicecrashreport.c +++ b/tools/idevicecrashreport.c @@ -81,7 +81,7 @@ static int extract_raw_crash_report(const char* filename) strcpy(p, ".crash"); /* read plist crash report */ - if (plist_read_from_filename(&report, filename)) { + if (plist_read_from_file(filename, &report, NULL)) { plist_t description_node = plist_dict_get_item(report, "description"); if (description_node && plist_get_node_type(description_node) == PLIST_STRING) { plist_get_string_val(description_node, &raw); diff --git a/tools/ideviceimagemounter.c b/tools/ideviceimagemounter.c index 4ea38a9..f551b6c 100644 --- a/tools/ideviceimagemounter.c +++ b/tools/ideviceimagemounter.c @@ -46,7 +46,7 @@ #include #include #include -#include +#include static int list_mode = 0; static int use_network = 0; @@ -143,15 +143,6 @@ static void parse_opts(int argc, char **argv) } } -static void print_xml(plist_t node) -{ - char *xml = NULL; - uint32_t len = 0; - plist_to_xml(node, &xml, &len); - if (xml) - puts(xml); -} - static ssize_t mim_upload_cb(void* buf, size_t size, void* userdata) { return fread(buf, 1, size, (FILE*)userdata); @@ -297,11 +288,7 @@ int main(int argc, char **argv) err = mobile_image_mounter_lookup_image(mim, imagetype, &result); if (err == MOBILE_IMAGE_MOUNTER_E_SUCCESS) { res = 0; - if (xml_mode) { - print_xml(result); - } else { - plist_print_to_stream(result, stdout); - } + plist_write_to_stream(result, stdout, (xml_mode) ? PLIST_FORMAT_XML : PLIST_FORMAT_LIMD, 0); } else { printf("Error: lookup_image returned %d\n", err); } @@ -429,20 +416,12 @@ int main(int argc, char **argv) res = 0; } else { printf("unexpected status value:\n"); - if (xml_mode) { - print_xml(result); - } else { - plist_print_to_stream(result, stdout); - } + plist_write_to_stream(result, stdout, (xml_mode) ? PLIST_FORMAT_XML : PLIST_FORMAT_LIMD, 0); } free(status); } else { printf("unexpected result:\n"); - if (xml_mode) { - print_xml(result); - } else { - plist_print_to_stream(result, stdout); - } + plist_write_to_stream(result, stdout, (xml_mode) ? PLIST_FORMAT_XML : PLIST_FORMAT_LIMD, 0); } } node = plist_dict_get_item(result, "Error"); @@ -454,19 +433,11 @@ int main(int argc, char **argv) free(error); } else { printf("unexpected result:\n"); - if (xml_mode) { - print_xml(result); - } else { - plist_print_to_stream(result, stdout); - } + plist_write_to_stream(result, stdout, (xml_mode) ? PLIST_FORMAT_XML : PLIST_FORMAT_LIMD, 0); } } else { - if (xml_mode) { - print_xml(result); - } else { - plist_print_to_stream(result, stdout); - } + plist_write_to_stream(result, stdout, (xml_mode) ? PLIST_FORMAT_XML : PLIST_FORMAT_LIMD, 0); } } } else { diff --git a/tools/ideviceinfo.c b/tools/ideviceinfo.c index fc0527d..fd45763 100644 --- a/tools/ideviceinfo.c +++ b/tools/ideviceinfo.c @@ -37,7 +37,7 @@ #include #include -#include +#include #define FORMAT_KEY_VALUE 1 #define FORMAT_XML 2 @@ -241,11 +241,11 @@ int main(int argc, char *argv[]) free(xml_doc); break; case FORMAT_KEY_VALUE: - plist_print_to_stream(node, stdout); + plist_write_to_stream(node, stdout, PLIST_FORMAT_LIMD, 0); break; default: if (key != NULL) - plist_print_to_stream(node, stdout); + plist_write_to_stream(node, stdout, PLIST_FORMAT_LIMD, 0); break; } plist_free(node); diff --git a/tools/idevicepair.c b/tools/idevicepair.c index dda02ec..94d3f04 100644 --- a/tools/idevicepair.c +++ b/tools/idevicepair.c @@ -41,7 +41,6 @@ #endif #include "common/userpref.h" -#include #include #include @@ -104,7 +103,7 @@ static void pairing_cb(lockdownd_cu_pairing_cb_type_t cb_type, void *user_data, printf("\n"); } else if (cb_type == LOCKDOWN_CU_PAIRING_DEVICE_INFO) { printf("Device info:\n"); - plist_print_to_stream_with_indentation((plist_t)data_ptr, stdout, 2); + plist_write_to_stream((plist_t)data_ptr, stdout, PLIST_FORMAT_LIMD, PLIST_OPT_INDENT | PLIST_OPT_INDENT_BY(2)); } else if (cb_type == LOCKDOWN_CU_PAIRING_ERROR) { printf("ERROR: %s\n", (data_ptr) ? (char*)data_ptr : "(unknown)"); } @@ -257,7 +256,7 @@ int main(int argc, char **argv) goto leave; } if (*optarg == '@') { - plist_read_from_filename(&host_info_plist, optarg+1); + plist_read_from_file(optarg+1, &host_info_plist, NULL); if (!host_info_plist) { fprintf(stderr, "ERROR: Could not read from file '%s'\n", optarg+1); result = EXIT_FAILURE; diff --git a/tools/ideviceprovision.c b/tools/ideviceprovision.c index 7cd4f3f..4080a28 100644 --- a/tools/ideviceprovision.c +++ b/tools/ideviceprovision.c @@ -45,7 +45,7 @@ #include #include #include -#include +#include static void print_usage(int argc, char **argv, int is_error) { @@ -436,7 +436,7 @@ int main(int argc, char *argv[]) } } else { if (pl && (plist_get_node_type(pl) == PLIST_DICT)) { - plist_print_to_stream(pl, stdout); + plist_write_to_stream(pl, stdout, PLIST_FORMAT_LIMD, 0); } else { fprintf(stderr, "ERROR: unexpected node type in profile plist (not PLIST_DICT)\n"); res = -1; -- cgit v1.1-32-gdbae