summaryrefslogtreecommitdiffstats
path: root/tools/idevicepair.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/idevicepair.c')
-rw-r--r--tools/idevicepair.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/tools/idevicepair.c b/tools/idevicepair.c
index 9eebc5c..d810365 100644
--- a/tools/idevicepair.c
+++ b/tools/idevicepair.c
@@ -28,7 +28,7 @@
28#include <libimobiledevice/libimobiledevice.h> 28#include <libimobiledevice/libimobiledevice.h>
29#include <libimobiledevice/lockdown.h> 29#include <libimobiledevice/lockdown.h>
30 30
31static char *uuid = NULL; 31static char *udid = NULL;
32 32
33static void print_usage(int argc, char **argv) 33static void print_usage(int argc, char **argv)
34{ 34{
@@ -45,7 +45,7 @@ static void print_usage(int argc, char **argv)
45 printf(" list list devices paired with this computer\n\n"); 45 printf(" list list devices paired with this computer\n\n");
46 printf(" The following OPTIONS are accepted:\n"); 46 printf(" The following OPTIONS are accepted:\n");
47 printf(" -d, --debug enable communication debugging\n"); 47 printf(" -d, --debug enable communication debugging\n");
48 printf(" -u, --uuid UUID target specific device by its 40-digit device UUID\n"); 48 printf(" -u, --udid UDID target specific device by its 40-digit device UDID\n");
49 printf(" -h, --help prints usage information\n"); 49 printf(" -h, --help prints usage information\n");
50 printf("\n"); 50 printf("\n");
51} 51}
@@ -54,7 +54,7 @@ static void parse_opts(int argc, char **argv)
54{ 54{
55 static struct option longopts[] = { 55 static struct option longopts[] = {
56 {"help", 0, NULL, 'h'}, 56 {"help", 0, NULL, 'h'},
57 {"uuid", 1, NULL, 'u'}, 57 {"udid", 1, NULL, 'u'},
58 {"debug", 0, NULL, 'd'}, 58 {"debug", 0, NULL, 'd'},
59 {NULL, 0, NULL, 0} 59 {NULL, 0, NULL, 0}
60 }; 60 };
@@ -72,11 +72,11 @@ static void parse_opts(int argc, char **argv)
72 exit(EXIT_SUCCESS); 72 exit(EXIT_SUCCESS);
73 case 'u': 73 case 'u':
74 if (strlen(optarg) != 40) { 74 if (strlen(optarg) != 40) {
75 printf("%s: invalid UUID specified (length != 40)\n", argv[0]); 75 printf("%s: invalid UDID specified (length != 40)\n", argv[0]);
76 print_usage(argc, argv); 76 print_usage(argc, argv);
77 exit(2); 77 exit(2);
78 } 78 }
79 uuid = strdup(optarg); 79 udid = strdup(optarg);
80 break; 80 break;
81 case 'd': 81 case 'd':
82 idevice_set_debug_level(1); 82 idevice_set_debug_level(1);
@@ -143,26 +143,26 @@ int main(int argc, char **argv)
143 143
144 if (op == OP_LIST) { 144 if (op == OP_LIST) {
145 unsigned int i; 145 unsigned int i;
146 char **uuids = NULL; 146 char **udids = NULL;
147 unsigned int count = 0; 147 unsigned int count = 0;
148 userpref_get_paired_uuids(&uuids, &count); 148 userpref_get_paired_udids(&udids, &count);
149 for (i = 0; i < count; i++) { 149 for (i = 0; i < count; i++) {
150 printf("%s\n", uuids[i]); 150 printf("%s\n", udids[i]);
151 free(uuids[i]); 151 free(udids[i]);
152 } 152 }
153 if (uuids) 153 if (udids)
154 free(uuids); 154 free(udids);
155 if (uuid) 155 if (udid)
156 free(uuid); 156 free(udid);
157 return EXIT_SUCCESS; 157 return EXIT_SUCCESS;
158 } 158 }
159 159
160 if (uuid) { 160 if (udid) {
161 ret = idevice_new(&phone, uuid); 161 ret = idevice_new(&phone, udid);
162 free(uuid); 162 free(udid);
163 uuid = NULL; 163 udid = NULL;
164 if (ret != IDEVICE_E_SUCCESS) { 164 if (ret != IDEVICE_E_SUCCESS) {
165 printf("No device found with uuid %s, is it plugged in?\n", uuid); 165 printf("No device found with udid %s, is it plugged in?\n", udid);
166 return EXIT_FAILURE; 166 return EXIT_FAILURE;
167 } 167 }
168 } else { 168 } else {
@@ -196,9 +196,9 @@ int main(int argc, char **argv)
196 } 196 }
197 } 197 }
198 198
199 ret = idevice_get_uuid(phone, &uuid); 199 ret = idevice_get_udid(phone, &udid);
200 if (ret != IDEVICE_E_SUCCESS) { 200 if (ret != IDEVICE_E_SUCCESS) {
201 printf("ERROR: Could not get device uuid, error code %d\n", ret); 201 printf("ERROR: Could not get device udid, error code %d\n", ret);
202 result = EXIT_FAILURE; 202 result = EXIT_FAILURE;
203 goto leave; 203 goto leave;
204 } 204 }
@@ -208,13 +208,13 @@ int main(int argc, char **argv)
208 case OP_PAIR: 208 case OP_PAIR:
209 lerr = lockdownd_pair(client, NULL); 209 lerr = lockdownd_pair(client, NULL);
210 if (lerr == LOCKDOWN_E_SUCCESS) { 210 if (lerr == LOCKDOWN_E_SUCCESS) {
211 printf("SUCCESS: Paired with device %s\n", uuid); 211 printf("SUCCESS: Paired with device %s\n", udid);
212 } else { 212 } else {
213 result = EXIT_FAILURE; 213 result = EXIT_FAILURE;
214 if (lerr == LOCKDOWN_E_PASSWORD_PROTECTED) { 214 if (lerr == LOCKDOWN_E_PASSWORD_PROTECTED) {
215 printf("ERROR: Could not pair with the device because a passcode is set. Please enter the passcode on the device and retry.\n"); 215 printf("ERROR: Could not pair with the device because a passcode is set. Please enter the passcode on the device and retry.\n");
216 } else { 216 } else {
217 printf("ERROR: Pairing with device %s failed with unhandled error code %d\n", uuid, lerr); 217 printf("ERROR: Pairing with device %s failed with unhandled error code %d\n", udid, lerr);
218 } 218 }
219 } 219 }
220 break; 220 break;
@@ -222,13 +222,13 @@ int main(int argc, char **argv)
222 case OP_VALIDATE: 222 case OP_VALIDATE:
223 lerr = lockdownd_validate_pair(client, NULL); 223 lerr = lockdownd_validate_pair(client, NULL);
224 if (lerr == LOCKDOWN_E_SUCCESS) { 224 if (lerr == LOCKDOWN_E_SUCCESS) {
225 printf("SUCCESS: Validated pairing with device %s\n", uuid); 225 printf("SUCCESS: Validated pairing with device %s\n", udid);
226 } else { 226 } else {
227 result = EXIT_FAILURE; 227 result = EXIT_FAILURE;
228 if (lerr == LOCKDOWN_E_PASSWORD_PROTECTED) { 228 if (lerr == LOCKDOWN_E_PASSWORD_PROTECTED) {
229 printf("ERROR: Could not validate with the device because a passcode is set. Please enter the passcode on the device and retry.\n"); 229 printf("ERROR: Could not validate with the device because a passcode is set. Please enter the passcode on the device and retry.\n");
230 } else if (lerr == LOCKDOWN_E_INVALID_HOST_ID) { 230 } else if (lerr == LOCKDOWN_E_INVALID_HOST_ID) {
231 printf("ERROR: Device %s is not paired with this host\n", uuid); 231 printf("ERROR: Device %s is not paired with this host\n", udid);
232 } else { 232 } else {
233 printf("ERROR: Pairing failed with unhandled error code %d\n", lerr); 233 printf("ERROR: Pairing failed with unhandled error code %d\n", lerr);
234 } 234 }
@@ -239,14 +239,14 @@ int main(int argc, char **argv)
239 lerr = lockdownd_unpair(client, NULL); 239 lerr = lockdownd_unpair(client, NULL);
240 if (lerr == LOCKDOWN_E_SUCCESS) { 240 if (lerr == LOCKDOWN_E_SUCCESS) {
241 /* also remove local device public key */ 241 /* also remove local device public key */
242 userpref_remove_device_public_key(uuid); 242 userpref_remove_device_public_key(udid);
243 printf("SUCCESS: Unpaired with device %s\n", uuid); 243 printf("SUCCESS: Unpaired with device %s\n", udid);
244 } else { 244 } else {
245 result = EXIT_FAILURE; 245 result = EXIT_FAILURE;
246 if (lerr == LOCKDOWN_E_INVALID_HOST_ID) { 246 if (lerr == LOCKDOWN_E_INVALID_HOST_ID) {
247 printf("ERROR: Device %s is not paired with this host\n", uuid); 247 printf("ERROR: Device %s is not paired with this host\n", udid);
248 } else { 248 } else {
249 printf("ERROR: Unpairing with device %s failed with unhandled error code %d\n", uuid, lerr); 249 printf("ERROR: Unpairing with device %s failed with unhandled error code %d\n", udid, lerr);
250 } 250 }
251 } 251 }
252 break; 252 break;
@@ -255,8 +255,8 @@ int main(int argc, char **argv)
255leave: 255leave:
256 lockdownd_client_free(client); 256 lockdownd_client_free(client);
257 idevice_free(phone); 257 idevice_free(phone);
258 if (uuid) { 258 if (udid) {
259 free(uuid); 259 free(udid);
260 } 260 }
261 return result; 261 return result;
262} 262}