diff options
Diffstat (limited to 'tools/idevicebackup2.c')
| -rw-r--r-- | tools/idevicebackup2.c | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c index 8efc2c8..a9bf071 100644 --- a/tools/idevicebackup2.c +++ b/tools/idevicebackup2.c | |||
| @@ -275,56 +275,56 @@ static plist_t mobilebackup_factory_info_plist_new(const char* udid, lockdownd_c | |||
| 275 | 275 | ||
| 276 | /* set fields we understand */ | 276 | /* set fields we understand */ |
| 277 | value_node = plist_dict_get_item(root_node, "BuildVersion"); | 277 | value_node = plist_dict_get_item(root_node, "BuildVersion"); |
| 278 | plist_dict_insert_item(ret, "Build Version", plist_copy(value_node)); | 278 | plist_dict_set_item(ret, "Build Version", plist_copy(value_node)); |
| 279 | 279 | ||
| 280 | value_node = plist_dict_get_item(root_node, "DeviceName"); | 280 | value_node = plist_dict_get_item(root_node, "DeviceName"); |
| 281 | plist_dict_insert_item(ret, "Device Name", plist_copy(value_node)); | 281 | plist_dict_set_item(ret, "Device Name", plist_copy(value_node)); |
| 282 | plist_dict_insert_item(ret, "Display Name", plist_copy(value_node)); | 282 | plist_dict_set_item(ret, "Display Name", plist_copy(value_node)); |
| 283 | 283 | ||
| 284 | /* FIXME: How is the GUID generated? */ | 284 | /* FIXME: How is the GUID generated? */ |
| 285 | plist_dict_insert_item(ret, "GUID", plist_new_string("---")); | 285 | plist_dict_set_item(ret, "GUID", plist_new_string("---")); |
| 286 | 286 | ||
| 287 | value_node = plist_dict_get_item(root_node, "IntegratedCircuitCardIdentity"); | 287 | value_node = plist_dict_get_item(root_node, "IntegratedCircuitCardIdentity"); |
| 288 | if (value_node) | 288 | if (value_node) |
| 289 | plist_dict_insert_item(ret, "ICCID", plist_copy(value_node)); | 289 | plist_dict_set_item(ret, "ICCID", plist_copy(value_node)); |
| 290 | 290 | ||
| 291 | value_node = plist_dict_get_item(root_node, "InternationalMobileEquipmentIdentity"); | 291 | value_node = plist_dict_get_item(root_node, "InternationalMobileEquipmentIdentity"); |
| 292 | if (value_node) | 292 | if (value_node) |
| 293 | plist_dict_insert_item(ret, "IMEI", plist_copy(value_node)); | 293 | plist_dict_set_item(ret, "IMEI", plist_copy(value_node)); |
| 294 | 294 | ||
| 295 | plist_dict_insert_item(ret, "Last Backup Date", plist_new_date(time(NULL), 0)); | 295 | plist_dict_set_item(ret, "Last Backup Date", plist_new_date(time(NULL), 0)); |
| 296 | 296 | ||
| 297 | value_node = plist_dict_get_item(root_node, "PhoneNumber"); | 297 | value_node = plist_dict_get_item(root_node, "PhoneNumber"); |
| 298 | if (value_node && (plist_get_node_type(value_node) == PLIST_STRING)) { | 298 | if (value_node && (plist_get_node_type(value_node) == PLIST_STRING)) { |
| 299 | plist_dict_insert_item(ret, "Phone Number", plist_copy(value_node)); | 299 | plist_dict_set_item(ret, "Phone Number", plist_copy(value_node)); |
| 300 | } | 300 | } |
| 301 | 301 | ||
| 302 | value_node = plist_dict_get_item(root_node, "ProductType"); | 302 | value_node = plist_dict_get_item(root_node, "ProductType"); |
| 303 | plist_dict_insert_item(ret, "Product Type", plist_copy(value_node)); | 303 | plist_dict_set_item(ret, "Product Type", plist_copy(value_node)); |
| 304 | 304 | ||
| 305 | value_node = plist_dict_get_item(root_node, "ProductVersion"); | 305 | value_node = plist_dict_get_item(root_node, "ProductVersion"); |
| 306 | plist_dict_insert_item(ret, "Product Version", plist_copy(value_node)); | 306 | plist_dict_set_item(ret, "Product Version", plist_copy(value_node)); |
| 307 | 307 | ||
| 308 | value_node = plist_dict_get_item(root_node, "SerialNumber"); | 308 | value_node = plist_dict_get_item(root_node, "SerialNumber"); |
| 309 | plist_dict_insert_item(ret, "Serial Number", plist_copy(value_node)); | 309 | plist_dict_set_item(ret, "Serial Number", plist_copy(value_node)); |
| 310 | 310 | ||
| 311 | /* FIXME Sync Settings? */ | 311 | /* FIXME Sync Settings? */ |
| 312 | 312 | ||
| 313 | value_node = plist_dict_get_item(root_node, "UniqueDeviceID"); | 313 | value_node = plist_dict_get_item(root_node, "UniqueDeviceID"); |
| 314 | plist_dict_insert_item(ret, "Target Identifier", plist_new_string(udid)); | 314 | plist_dict_set_item(ret, "Target Identifier", plist_new_string(udid)); |
| 315 | 315 | ||
| 316 | plist_dict_insert_item(ret, "Target Type", plist_new_string("Device")); | 316 | plist_dict_set_item(ret, "Target Type", plist_new_string("Device")); |
| 317 | 317 | ||
| 318 | /* uppercase */ | 318 | /* uppercase */ |
| 319 | udid_uppercase = str_toupper((char*)udid); | 319 | udid_uppercase = str_toupper((char*)udid); |
| 320 | plist_dict_insert_item(ret, "Unique Identifier", plist_new_string(udid_uppercase)); | 320 | plist_dict_set_item(ret, "Unique Identifier", plist_new_string(udid_uppercase)); |
| 321 | free(udid_uppercase); | 321 | free(udid_uppercase); |
| 322 | 322 | ||
| 323 | char *data_buf = NULL; | 323 | char *data_buf = NULL; |
| 324 | uint64_t data_size = 0; | 324 | uint64_t data_size = 0; |
| 325 | mobilebackup_afc_get_file_contents(afc, "/Books/iBooksData2.plist", &data_buf, &data_size); | 325 | mobilebackup_afc_get_file_contents(afc, "/Books/iBooksData2.plist", &data_buf, &data_size); |
| 326 | if (data_buf) { | 326 | if (data_buf) { |
| 327 | plist_dict_insert_item(ret, "iBooks Data 2", plist_new_data(data_buf, data_size)); | 327 | plist_dict_set_item(ret, "iBooks Data 2", plist_new_data(data_buf, data_size)); |
| 328 | free(data_buf); | 328 | free(data_buf); |
| 329 | } | 329 | } |
| 330 | 330 | ||
| @@ -352,17 +352,17 @@ static plist_t mobilebackup_factory_info_plist_new(const char* udid, lockdownd_c | |||
| 352 | mobilebackup_afc_get_file_contents(afc, fname, &data_buf, &data_size); | 352 | mobilebackup_afc_get_file_contents(afc, fname, &data_buf, &data_size); |
| 353 | free(fname); | 353 | free(fname); |
| 354 | if (data_buf) { | 354 | if (data_buf) { |
| 355 | plist_dict_insert_item(files, itunesfiles[i], plist_new_data(data_buf, data_size)); | 355 | plist_dict_set_item(files, itunesfiles[i], plist_new_data(data_buf, data_size)); |
| 356 | free(data_buf); | 356 | free(data_buf); |
| 357 | } | 357 | } |
| 358 | } | 358 | } |
| 359 | plist_dict_insert_item(ret, "iTunes Files", files); | 359 | plist_dict_set_item(ret, "iTunes Files", files); |
| 360 | 360 | ||
| 361 | plist_t itunes_settings = NULL; | 361 | plist_t itunes_settings = NULL; |
| 362 | lockdownd_get_value(lockdown, "com.apple.iTunes", NULL, &itunes_settings); | 362 | lockdownd_get_value(lockdown, "com.apple.iTunes", NULL, &itunes_settings); |
| 363 | plist_dict_insert_item(ret, "iTunes Settings", itunes_settings ? itunes_settings : plist_new_dict()); | 363 | plist_dict_set_item(ret, "iTunes Settings", itunes_settings ? itunes_settings : plist_new_dict()); |
| 364 | 364 | ||
| 365 | plist_dict_insert_item(ret, "iTunes Version", plist_new_string("10.0.1")); | 365 | plist_dict_set_item(ret, "iTunes Version", plist_new_string("10.0.1")); |
| 366 | 366 | ||
| 367 | plist_free(root_node); | 367 | plist_free(root_node); |
| 368 | 368 | ||
| @@ -589,9 +589,9 @@ static void mb2_multi_status_add_file_error(plist_t status_dict, const char *pat | |||
| 589 | { | 589 | { |
| 590 | if (!status_dict) return; | 590 | if (!status_dict) return; |
| 591 | plist_t filedict = plist_new_dict(); | 591 | plist_t filedict = plist_new_dict(); |
| 592 | plist_dict_insert_item(filedict, "DLFileErrorString", plist_new_string(error_message)); | 592 | plist_dict_set_item(filedict, "DLFileErrorString", plist_new_string(error_message)); |
| 593 | plist_dict_insert_item(filedict, "DLFileErrorCode", plist_new_uint(error_code)); | 593 | plist_dict_set_item(filedict, "DLFileErrorCode", plist_new_uint(error_code)); |
| 594 | plist_dict_insert_item(status_dict, path, filedict); | 594 | plist_dict_set_item(status_dict, path, filedict); |
| 595 | } | 595 | } |
| 596 | 596 | ||
| 597 | static int errno_to_device_error(int errno_value) | 597 | static int errno_to_device_error(int errno_value) |
| @@ -1055,11 +1055,11 @@ static void mb2_handle_list_directory(mobilebackup2_client_t mobilebackup2, plis | |||
| 1055 | } else if (S_ISREG(st.st_mode)) { | 1055 | } else if (S_ISREG(st.st_mode)) { |
| 1056 | ftype = "DLFileTypeRegular"; | 1056 | ftype = "DLFileTypeRegular"; |
| 1057 | } | 1057 | } |
| 1058 | plist_dict_insert_item(fdict, "DLFileType", plist_new_string(ftype)); | 1058 | plist_dict_set_item(fdict, "DLFileType", plist_new_string(ftype)); |
| 1059 | plist_dict_insert_item(fdict, "DLFileSize", plist_new_uint(st.st_size)); | 1059 | plist_dict_set_item(fdict, "DLFileSize", plist_new_uint(st.st_size)); |
| 1060 | plist_dict_insert_item(fdict, "DLFileModificationDate", plist_new_date(st.st_mtime, 0)); | 1060 | plist_dict_set_item(fdict, "DLFileModificationDate", plist_new_date(st.st_mtime, 0)); |
| 1061 | 1061 | ||
| 1062 | plist_dict_insert_item(dirlist, ep->d_name, fdict); | 1062 | plist_dict_set_item(dirlist, ep->d_name, fdict); |
| 1063 | free(fpath); | 1063 | free(fpath); |
| 1064 | } | 1064 | } |
| 1065 | } | 1065 | } |
| @@ -1719,7 +1719,7 @@ checkpoint: | |||
| 1719 | switch(cmd) { | 1719 | switch(cmd) { |
| 1720 | case CMD_CLOUD: | 1720 | case CMD_CLOUD: |
| 1721 | opts = plist_new_dict(); | 1721 | opts = plist_new_dict(); |
| 1722 | plist_dict_insert_item(opts, "CloudBackupState", plist_new_bool(cmd_flags & CMD_FLAG_CLOUD_ENABLE ? 1: 0)); | 1722 | plist_dict_set_item(opts, "CloudBackupState", plist_new_bool(cmd_flags & CMD_FLAG_CLOUD_ENABLE ? 1: 0)); |
| 1723 | err = mobilebackup2_send_request(mobilebackup2, "EnableCloudBackup", udid, source_udid, opts); | 1723 | err = mobilebackup2_send_request(mobilebackup2, "EnableCloudBackup", udid, source_udid, opts); |
| 1724 | plist_free(opts); | 1724 | plist_free(opts); |
| 1725 | opts = NULL; | 1725 | opts = NULL; |
| @@ -1767,7 +1767,7 @@ checkpoint: | |||
| 1767 | if (cmd_flags & CMD_FLAG_FORCE_FULL_BACKUP) { | 1767 | if (cmd_flags & CMD_FLAG_FORCE_FULL_BACKUP) { |
| 1768 | PRINT_VERBOSE(1, "Enforcing full backup from device.\n"); | 1768 | PRINT_VERBOSE(1, "Enforcing full backup from device.\n"); |
| 1769 | opts = plist_new_dict(); | 1769 | opts = plist_new_dict(); |
| 1770 | plist_dict_insert_item(opts, "ForceFullBackup", plist_new_bool(1)); | 1770 | plist_dict_set_item(opts, "ForceFullBackup", plist_new_bool(1)); |
| 1771 | } | 1771 | } |
| 1772 | /* request backup from device with manifest from last backup */ | 1772 | /* request backup from device with manifest from last backup */ |
| 1773 | if (willEncrypt) { | 1773 | if (willEncrypt) { |
| @@ -1809,21 +1809,21 @@ checkpoint: | |||
| 1809 | PRINT_VERBOSE(1, "Starting Restore...\n"); | 1809 | PRINT_VERBOSE(1, "Starting Restore...\n"); |
| 1810 | 1810 | ||
| 1811 | opts = plist_new_dict(); | 1811 | opts = plist_new_dict(); |
| 1812 | plist_dict_insert_item(opts, "RestoreSystemFiles", plist_new_bool(cmd_flags & CMD_FLAG_RESTORE_SYSTEM_FILES)); | 1812 | plist_dict_set_item(opts, "RestoreSystemFiles", plist_new_bool(cmd_flags & CMD_FLAG_RESTORE_SYSTEM_FILES)); |
| 1813 | PRINT_VERBOSE(1, "Restoring system files: %s\n", (cmd_flags & CMD_FLAG_RESTORE_SYSTEM_FILES ? "Yes":"No")); | 1813 | PRINT_VERBOSE(1, "Restoring system files: %s\n", (cmd_flags & CMD_FLAG_RESTORE_SYSTEM_FILES ? "Yes":"No")); |
| 1814 | if ((cmd_flags & CMD_FLAG_RESTORE_REBOOT) == 0) | 1814 | if ((cmd_flags & CMD_FLAG_RESTORE_REBOOT) == 0) |
| 1815 | plist_dict_insert_item(opts, "RestoreShouldReboot", plist_new_bool(0)); | 1815 | plist_dict_set_item(opts, "RestoreShouldReboot", plist_new_bool(0)); |
| 1816 | PRINT_VERBOSE(1, "Rebooting after restore: %s\n", (cmd_flags & CMD_FLAG_RESTORE_REBOOT ? "Yes":"No")); | 1816 | PRINT_VERBOSE(1, "Rebooting after restore: %s\n", (cmd_flags & CMD_FLAG_RESTORE_REBOOT ? "Yes":"No")); |
| 1817 | if ((cmd_flags & CMD_FLAG_RESTORE_COPY_BACKUP) == 0) | 1817 | if ((cmd_flags & CMD_FLAG_RESTORE_COPY_BACKUP) == 0) |
| 1818 | plist_dict_insert_item(opts, "RestoreDontCopyBackup", plist_new_bool(1)); | 1818 | plist_dict_set_item(opts, "RestoreDontCopyBackup", plist_new_bool(1)); |
| 1819 | PRINT_VERBOSE(1, "Don't copy backup: %s\n", ((cmd_flags & CMD_FLAG_RESTORE_COPY_BACKUP) == 0 ? "Yes":"No")); | 1819 | PRINT_VERBOSE(1, "Don't copy backup: %s\n", ((cmd_flags & CMD_FLAG_RESTORE_COPY_BACKUP) == 0 ? "Yes":"No")); |
| 1820 | plist_dict_insert_item(opts, "RestorePreserveSettings", plist_new_bool((cmd_flags & CMD_FLAG_RESTORE_SETTINGS) == 0)); | 1820 | plist_dict_set_item(opts, "RestorePreserveSettings", plist_new_bool((cmd_flags & CMD_FLAG_RESTORE_SETTINGS) == 0)); |
| 1821 | PRINT_VERBOSE(1, "Preserve settings of device: %s\n", ((cmd_flags & CMD_FLAG_RESTORE_SETTINGS) == 0 ? "Yes":"No")); | 1821 | PRINT_VERBOSE(1, "Preserve settings of device: %s\n", ((cmd_flags & CMD_FLAG_RESTORE_SETTINGS) == 0 ? "Yes":"No")); |
| 1822 | if (cmd_flags & CMD_FLAG_RESTORE_REMOVE_ITEMS) | 1822 | if (cmd_flags & CMD_FLAG_RESTORE_REMOVE_ITEMS) |
| 1823 | plist_dict_insert_item(opts, "RemoveItemsNotRestored", plist_new_bool(1)); | 1823 | plist_dict_set_item(opts, "RemoveItemsNotRestored", plist_new_bool(1)); |
| 1824 | PRINT_VERBOSE(1, "Remove items that are not restored: %s\n", ((cmd_flags & CMD_FLAG_RESTORE_REMOVE_ITEMS) ? "Yes":"No")); | 1824 | PRINT_VERBOSE(1, "Remove items that are not restored: %s\n", ((cmd_flags & CMD_FLAG_RESTORE_REMOVE_ITEMS) ? "Yes":"No")); |
| 1825 | if (backup_password != NULL) { | 1825 | if (backup_password != NULL) { |
| 1826 | plist_dict_insert_item(opts, "Password", plist_new_string(backup_password)); | 1826 | plist_dict_set_item(opts, "Password", plist_new_string(backup_password)); |
| 1827 | } | 1827 | } |
| 1828 | PRINT_VERBOSE(1, "Backup password: %s\n", (backup_password == NULL ? "No":"Yes")); | 1828 | PRINT_VERBOSE(1, "Backup password: %s\n", (backup_password == NULL ? "No":"Yes")); |
| 1829 | 1829 | ||
| @@ -1860,7 +1860,7 @@ checkpoint: | |||
| 1860 | PRINT_VERBOSE(1, "Starting to unpack backup...\n"); | 1860 | PRINT_VERBOSE(1, "Starting to unpack backup...\n"); |
| 1861 | if (backup_password != NULL) { | 1861 | if (backup_password != NULL) { |
| 1862 | opts = plist_new_dict(); | 1862 | opts = plist_new_dict(); |
| 1863 | plist_dict_insert_item(opts, "Password", plist_new_string(backup_password)); | 1863 | plist_dict_set_item(opts, "Password", plist_new_string(backup_password)); |
| 1864 | } | 1864 | } |
| 1865 | PRINT_VERBOSE(1, "Backup password: %s\n", (backup_password == NULL ? "No":"Yes")); | 1865 | PRINT_VERBOSE(1, "Backup password: %s\n", (backup_password == NULL ? "No":"Yes")); |
| 1866 | err = mobilebackup2_send_request(mobilebackup2, "Unback", udid, source_udid, opts); | 1866 | err = mobilebackup2_send_request(mobilebackup2, "Unback", udid, source_udid, opts); |
| @@ -1874,7 +1874,7 @@ checkpoint: | |||
| 1874 | break; | 1874 | break; |
| 1875 | case CMD_CHANGEPW: | 1875 | case CMD_CHANGEPW: |
| 1876 | opts = plist_new_dict(); | 1876 | opts = plist_new_dict(); |
| 1877 | plist_dict_insert_item(opts, "TargetIdentifier", plist_new_string(udid)); | 1877 | plist_dict_set_item(opts, "TargetIdentifier", plist_new_string(udid)); |
| 1878 | if (cmd_flags & CMD_FLAG_ENCRYPTION_ENABLE) { | 1878 | if (cmd_flags & CMD_FLAG_ENCRYPTION_ENABLE) { |
| 1879 | if (!willEncrypt) { | 1879 | if (!willEncrypt) { |
| 1880 | if (!newpw) { | 1880 | if (!newpw) { |
| @@ -1924,10 +1924,10 @@ checkpoint: | |||
| 1924 | } | 1924 | } |
| 1925 | } | 1925 | } |
| 1926 | if (newpw) { | 1926 | if (newpw) { |
| 1927 | plist_dict_insert_item(opts, "NewPassword", plist_new_string(newpw)); | 1927 | plist_dict_set_item(opts, "NewPassword", plist_new_string(newpw)); |
| 1928 | } | 1928 | } |
| 1929 | if (backup_password) { | 1929 | if (backup_password) { |
| 1930 | plist_dict_insert_item(opts, "OldPassword", plist_new_string(backup_password)); | 1930 | plist_dict_set_item(opts, "OldPassword", plist_new_string(backup_password)); |
| 1931 | } | 1931 | } |
| 1932 | if (newpw || backup_password) { | 1932 | if (newpw || backup_password) { |
| 1933 | mobilebackup2_send_message(mobilebackup2, "ChangePassword", opts); | 1933 | mobilebackup2_send_message(mobilebackup2, "ChangePassword", opts); |
