diff options
| -rw-r--r-- | tools/idevicebackup2.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c index 4ca0f2a..b7e33f6 100644 --- a/tools/idevicebackup2.c +++ b/tools/idevicebackup2.c | |||
| @@ -1456,6 +1456,7 @@ int main(int argc, char *argv[]) | |||
| 1456 | source_udid = strdup(udid); | 1456 | source_udid = strdup(udid); |
| 1457 | } | 1457 | } |
| 1458 | 1458 | ||
| 1459 | uint8_t is_encrypted = 0; | ||
| 1459 | char *info_path = NULL; | 1460 | char *info_path = NULL; |
| 1460 | if (cmd != CMD_CHANGEPW) { | 1461 | if (cmd != CMD_CHANGEPW) { |
| 1461 | /* backup directory must contain an Info.plist */ | 1462 | /* backup directory must contain an Info.plist */ |
| @@ -1466,10 +1467,43 @@ int main(int argc, char *argv[]) | |||
| 1466 | printf("ERROR: Backup directory \"%s\" is invalid. No Info.plist found for UDID %s.\n", backup_directory, source_udid); | 1467 | printf("ERROR: Backup directory \"%s\" is invalid. No Info.plist found for UDID %s.\n", backup_directory, source_udid); |
| 1467 | return -1; | 1468 | return -1; |
| 1468 | } | 1469 | } |
| 1470 | char* manifest_path = build_path(backup_directory, source_udid, "Manifest.plist", NULL); | ||
| 1471 | if (stat(manifest_path, &st) != 0) { | ||
| 1472 | free(info_path); | ||
| 1473 | } | ||
| 1474 | plist_t manifest_plist = NULL; | ||
| 1475 | plist_read_from_filename(&manifest_plist, manifest_path); | ||
| 1476 | if (!manifest_plist) { | ||
| 1477 | free(info_path); | ||
| 1478 | free(manifest_path); | ||
| 1479 | printf("ERROR: Backup directory \"%s\" is invalid. No Manifest.plist found for UDID %s.\n", backup_directory, source_udid); | ||
| 1480 | return -1; | ||
| 1481 | } | ||
| 1482 | node_tmp = plist_dict_get_item(manifest_plist, "IsEncrypted"); | ||
| 1483 | if (node_tmp && (plist_get_node_type(node_tmp) == PLIST_BOOLEAN)) { | ||
| 1484 | plist_get_bool_val(node_tmp, &is_encrypted); | ||
| 1485 | } | ||
| 1486 | plist_free(manifest_plist); | ||
| 1487 | free(manifest_path); | ||
| 1469 | } | 1488 | } |
| 1470 | PRINT_VERBOSE(1, "Backup directory is \"%s\"\n", backup_directory); | 1489 | PRINT_VERBOSE(1, "Backup directory is \"%s\"\n", backup_directory); |
| 1471 | } | 1490 | } |
| 1472 | 1491 | ||
| 1492 | if (is_encrypted) { | ||
| 1493 | PRINT_VERBOSE(1, "This is an encrypted backup.\n"); | ||
| 1494 | if (backup_password == NULL) { | ||
| 1495 | backup_password = ask_for_password("Enter backup password", 0); | ||
| 1496 | if (!backup_password || (strlen(backup_password) == 0)) { | ||
| 1497 | if (backup_password) { | ||
| 1498 | free(backup_password); | ||
| 1499 | } | ||
| 1500 | idevice_free(device); | ||
| 1501 | printf("ERROR: a backup password is required to restore an encrypted backup. Cannot continue.\n"); | ||
| 1502 | return -1; | ||
| 1503 | } | ||
| 1504 | } | ||
| 1505 | } | ||
| 1506 | |||
| 1473 | if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(device, &client, "idevicebackup")) { | 1507 | if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(device, &client, "idevicebackup")) { |
| 1474 | idevice_free(device); | 1508 | idevice_free(device); |
| 1475 | return -1; | 1509 | return -1; |
