diff options
| author | 2019-09-27 19:16:46 +0200 | |
|---|---|---|
| committer | 2019-09-27 19:16:46 +0200 | |
| commit | 1faa16c912dd5eb4e9305b25b13407de195ad103 (patch) | |
| tree | 3e7f2d452014a4aafa1cb1924f0e589c332e1527 /tools/idevicebackup2.c | |
| parent | 7e06820721be573b625921da86f736a89989d023 (diff) | |
| download | libimobiledevice-1faa16c912dd5eb4e9305b25b13407de195ad103.tar.gz libimobiledevice-1faa16c912dd5eb4e9305b25b13407de195ad103.tar.bz2 | |
idevicebackup2: Add passcode hint when enabling/disabling backup encryption or change the password
Diffstat (limited to 'tools/idevicebackup2.c')
| -rw-r--r-- | tools/idevicebackup2.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c index 1ac5d1a..3a4de67 100644 --- a/tools/idevicebackup2.c +++ b/tools/idevicebackup2.c | |||
| @@ -42,6 +42,7 @@ | |||
| 42 | #include <libimobiledevice/afc.h> | 42 | #include <libimobiledevice/afc.h> |
| 43 | #include <libimobiledevice/installation_proxy.h> | 43 | #include <libimobiledevice/installation_proxy.h> |
| 44 | #include <libimobiledevice/sbservices.h> | 44 | #include <libimobiledevice/sbservices.h> |
| 45 | #include <libimobiledevice/diagnostics_relay.h> | ||
| 45 | #include "common/utils.h" | 46 | #include "common/utils.h" |
| 46 | 47 | ||
| 47 | #include <endianness.h> | 48 | #include <endianness.h> |
| @@ -1433,6 +1434,8 @@ static void print_usage(int argc, char **argv) | |||
| 1433 | printf("Homepage: <" PACKAGE_URL ">\n"); | 1434 | printf("Homepage: <" PACKAGE_URL ">\n"); |
| 1434 | } | 1435 | } |
| 1435 | 1436 | ||
| 1437 | #define DEVICE_VERSION(maj, min, patch) (((maj & 0xFF) << 16) | ((min & 0xFF) << 8) | (patch & 0xFF)) | ||
| 1438 | |||
| 1436 | int main(int argc, char *argv[]) | 1439 | int main(int argc, char *argv[]) |
| 1437 | { | 1440 | { |
| 1438 | idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR; | 1441 | idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR; |
| @@ -1757,6 +1760,25 @@ int main(int argc, char *argv[]) | |||
| 1757 | node_tmp = NULL; | 1760 | node_tmp = NULL; |
| 1758 | } | 1761 | } |
| 1759 | 1762 | ||
| 1763 | /* get ProductVersion */ | ||
| 1764 | char *product_version = NULL; | ||
| 1765 | int device_version = 0; | ||
| 1766 | node_tmp = NULL; | ||
| 1767 | lockdownd_get_value(lockdown, NULL, "ProductVersion", &node_tmp); | ||
| 1768 | if (node_tmp) { | ||
| 1769 | if (plist_get_node_type(node_tmp) == PLIST_STRING) { | ||
| 1770 | plist_get_string_val(node_tmp, &product_version); | ||
| 1771 | } | ||
| 1772 | plist_free(node_tmp); | ||
| 1773 | node_tmp = NULL; | ||
| 1774 | } | ||
| 1775 | if (product_version) { | ||
| 1776 | int vers[3] = { 0, 0, 0 }; | ||
| 1777 | if (sscanf(product_version, "%d.%d.%d", &vers[0], &vers[1], &vers[2]) >= 2) { | ||
| 1778 | device_version = DEVICE_VERSION(vers[0], vers[1], vers[2]); | ||
| 1779 | } | ||
| 1780 | } | ||
| 1781 | |||
| 1760 | /* start notification_proxy */ | 1782 | /* start notification_proxy */ |
| 1761 | np_client_t np = NULL; | 1783 | np_client_t np = NULL; |
| 1762 | ldret = lockdownd_start_service(lockdown, NP_SERVICE_NAME, &service); | 1784 | ldret = lockdownd_start_service(lockdown, NP_SERVICE_NAME, &service); |
| @@ -2108,6 +2130,32 @@ checkpoint: | |||
| 2108 | } | 2130 | } |
| 2109 | if (newpw || backup_password) { | 2131 | if (newpw || backup_password) { |
| 2110 | mobilebackup2_send_message(mobilebackup2, "ChangePassword", opts); | 2132 | mobilebackup2_send_message(mobilebackup2, "ChangePassword", opts); |
| 2133 | uint8_t passcode_hint = 0; | ||
| 2134 | if (device_version >= DEVICE_VERSION(13,0,0)) { | ||
| 2135 | diagnostics_relay_client_t diag = NULL; | ||
| 2136 | if (diagnostics_relay_client_start_service(device, &diag, "idevicebackup2") == DIAGNOSTICS_RELAY_E_SUCCESS) { | ||
| 2137 | plist_t dict = NULL; | ||
| 2138 | plist_t keys = plist_new_array(); | ||
| 2139 | plist_array_append_item(keys, plist_new_string("PasswordConfigured")); | ||
| 2140 | if (diagnostics_relay_query_mobilegestalt(diag, keys, &dict) == DIAGNOSTICS_RELAY_E_SUCCESS) { | ||
| 2141 | plist_t node = plist_access_path(dict, 2, "MobileGestalt", "PasswordConfigured"); | ||
| 2142 | plist_get_bool_val(node, &passcode_hint); | ||
| 2143 | } | ||
| 2144 | plist_free(keys); | ||
| 2145 | plist_free(dict); | ||
| 2146 | diagnostics_relay_goodbye(diag); | ||
| 2147 | diagnostics_relay_client_free(diag); | ||
| 2148 | } | ||
| 2149 | } | ||
| 2150 | if (passcode_hint) { | ||
| 2151 | if (cmd_flags & CMD_FLAG_ENCRYPTION_CHANGEPW) { | ||
| 2152 | PRINT_VERBOSE(1, "Please confirm changing the backup password by entering the passcode on the device.\n"); | ||
| 2153 | } else if (cmd_flags & CMD_FLAG_ENCRYPTION_ENABLE) { | ||
| 2154 | PRINT_VERBOSE(1, "Please confirm enabling the backup encryption by entering the passcode on the device.\n"); | ||
| 2155 | } else if (cmd_flags & CMD_FLAG_ENCRYPTION_DISABLE) { | ||
| 2156 | PRINT_VERBOSE(1, "Please confirm disabling the backup encryption by entering the passcode on the device.\n"); | ||
| 2157 | } | ||
| 2158 | } | ||
| 2111 | /*if (cmd_flags & CMD_FLAG_ENCRYPTION_ENABLE) { | 2159 | /*if (cmd_flags & CMD_FLAG_ENCRYPTION_ENABLE) { |
| 2112 | int retr = 10; | 2160 | int retr = 10; |
| 2113 | while ((retr-- >= 0) && !backup_domain_changed) { | 2161 | while ((retr-- >= 0) && !backup_domain_changed) { |
