diff options
Diffstat (limited to 'tools/idevicebackup2.c')
| -rw-r--r-- | tools/idevicebackup2.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c index 8f094c8..a0e732d 100644 --- a/tools/idevicebackup2.c +++ b/tools/idevicebackup2.c | |||
| @@ -1258,14 +1258,15 @@ static void print_usage(int argc, char **argv) | |||
| 1258 | printf(" list\t\tlist files of last completed backup in CSV format\n"); | 1258 | printf(" list\t\tlist files of last completed backup in CSV format\n"); |
| 1259 | printf(" unback\tunpack a completed backup in DIRECTORY/_unback_/\n"); | 1259 | printf(" unback\tunpack a completed backup in DIRECTORY/_unback_/\n"); |
| 1260 | printf(" encryption on|off [PWD]\tenable or disable backup encryption\n"); | 1260 | printf(" encryption on|off [PWD]\tenable or disable backup encryption\n"); |
| 1261 | printf(" NOTE: if password is omitted it will be requested interactively\n"); | 1261 | printf(" NOTE: password will be requested in interactive mode if omitted\n"); |
| 1262 | printf(" changepw [OLD NEW] change backup password on target device\n"); | 1262 | printf(" changepw [OLD NEW] change backup password on target device\n"); |
| 1263 | printf(" NOTE: if no passwords are given the change will be performed interactively.\n"); | 1263 | printf(" NOTE: passwords will be requested in interactive mode if omitted\n"); |
| 1264 | printf("\n"); | 1264 | printf("\n"); |
| 1265 | printf("options:\n"); | 1265 | printf("options:\n"); |
| 1266 | printf(" -d, --debug\t\tenable communication debugging\n"); | 1266 | printf(" -d, --debug\t\tenable communication debugging\n"); |
| 1267 | printf(" -u, --udid UDID\ttarget specific device by its 40-digit device UDID\n"); | 1267 | printf(" -u, --udid UDID\ttarget specific device by its 40-digit device UDID\n"); |
| 1268 | printf(" -s, --source UDID\tuse backup data from device specified by UDID\n"); | 1268 | printf(" -s, --source UDID\tuse backup data from device specified by UDID\n"); |
| 1269 | printf(" -i, --interactive\trequest passwords interactively\n"); | ||
| 1269 | printf(" -h, --help\t\tprints usage information\n"); | 1270 | printf(" -h, --help\t\tprints usage information\n"); |
| 1270 | printf("\n"); | 1271 | printf("\n"); |
| 1271 | } | 1272 | } |
| @@ -1282,6 +1283,7 @@ int main(int argc, char *argv[]) | |||
| 1282 | int is_full_backup = 0; | 1283 | int is_full_backup = 0; |
| 1283 | int result_code = -1; | 1284 | int result_code = -1; |
| 1284 | char* backup_directory = NULL; | 1285 | char* backup_directory = NULL; |
| 1286 | int interactive_mode = 0; | ||
| 1285 | char* backup_password = NULL; | 1287 | char* backup_password = NULL; |
| 1286 | char* newpw = NULL; | 1288 | char* newpw = NULL; |
| 1287 | struct stat st; | 1289 | struct stat st; |
| @@ -1322,6 +1324,10 @@ int main(int argc, char *argv[]) | |||
| 1322 | source_udid = strdup(argv[i]); | 1324 | source_udid = strdup(argv[i]); |
| 1323 | continue; | 1325 | continue; |
| 1324 | } | 1326 | } |
| 1327 | else if (!strcmp(argv[i], "-i") || !strcmp(argv[i], "--interactive")) { | ||
| 1328 | interactive_mode = 1; | ||
| 1329 | continue; | ||
| 1330 | } | ||
| 1325 | else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { | 1331 | else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { |
| 1326 | print_usage(argc, argv); | 1332 | print_usage(argc, argv); |
| 1327 | return 0; | 1333 | return 0; |
| @@ -1484,7 +1490,12 @@ int main(int argc, char *argv[]) | |||
| 1484 | 1490 | ||
| 1485 | uint8_t is_encrypted = 0; | 1491 | uint8_t is_encrypted = 0; |
| 1486 | char *info_path = NULL; | 1492 | char *info_path = NULL; |
| 1487 | if (cmd != CMD_CHANGEPW) { | 1493 | if (cmd == CMD_CHANGEPW) { |
| 1494 | if (!interactive_mode && (!backup_password || !newpw)) { | ||
| 1495 | printf("ERROR: Can't get password input in non-interactive mode. Either pass password(s) on the command line, or enable interactive mode with -i or --interactive.\n"); | ||
| 1496 | return -1; | ||
| 1497 | } | ||
| 1498 | } else { | ||
| 1488 | /* backup directory must contain an Info.plist */ | 1499 | /* backup directory must contain an Info.plist */ |
| 1489 | info_path = build_path(backup_directory, source_udid, "Info.plist", NULL); | 1500 | info_path = build_path(backup_directory, source_udid, "Info.plist", NULL); |
| 1490 | if (cmd == CMD_RESTORE) { | 1501 | if (cmd == CMD_RESTORE) { |
| @@ -1518,7 +1529,9 @@ int main(int argc, char *argv[]) | |||
| 1518 | if (is_encrypted) { | 1529 | if (is_encrypted) { |
| 1519 | PRINT_VERBOSE(1, "This is an encrypted backup.\n"); | 1530 | PRINT_VERBOSE(1, "This is an encrypted backup.\n"); |
| 1520 | if (backup_password == NULL) { | 1531 | if (backup_password == NULL) { |
| 1521 | backup_password = ask_for_password("Enter backup password", 0); | 1532 | if (interactive_mode) { |
| 1533 | backup_password = ask_for_password("Enter backup password", 0); | ||
| 1534 | } | ||
| 1522 | if (!backup_password || (strlen(backup_password) == 0)) { | 1535 | if (!backup_password || (strlen(backup_password) == 0)) { |
| 1523 | if (backup_password) { | 1536 | if (backup_password) { |
| 1524 | free(backup_password); | 1537 | free(backup_password); |
