diff options
Diffstat (limited to 'tools/idevicepair.c')
-rw-r--r-- | tools/idevicepair.c | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/tools/idevicepair.c b/tools/idevicepair.c index d634d5f..91ed49b 100644 --- a/tools/idevicepair.c +++ b/tools/idevicepair.c @@ -38,7 +38,8 @@ static void print_usage(int argc, char **argv) printf("\n%s - Manage pairings with devices and this host.\n\n", (name ? name + 1: argv[0])); printf("Usage: %s [OPTIONS] COMMAND\n\n", (name ? name + 1: argv[0])); printf(" Where COMMAND is one of:\n"); - printf(" hostid print the host id of this computer\n"); + printf(" systembuid print the system buid of this computer\n"); + printf(" hostid print the host id for target device\n"); printf(" pair pair device with this computer\n"); printf(" validate validate if device is paired with this computer\n"); printf(" unpair unpair device with this computer\n"); @@ -99,7 +100,7 @@ int main(int argc, char **argv) char *type = NULL; char *cmd; typedef enum { - OP_NONE = 0, OP_PAIR, OP_VALIDATE, OP_UNPAIR, OP_LIST, OP_HOSTID + OP_NONE = 0, OP_PAIR, OP_VALIDATE, OP_UNPAIR, OP_LIST, OP_HOSTID, OP_SYSTEMBUID } op_t; op_t op = OP_NONE; @@ -123,20 +124,22 @@ int main(int argc, char **argv) op = OP_LIST; } else if (!strcmp(cmd, "hostid")) { op = OP_HOSTID; + } else if (!strcmp(cmd, "systembuid")) { + op = OP_SYSTEMBUID; } else { printf("ERROR: Invalid command '%s' specified\n", cmd); print_usage(argc, argv); exit(EXIT_FAILURE); } - if (op == OP_HOSTID) { - char *hostid = NULL; - userpref_get_host_id(&hostid); + if (op == OP_SYSTEMBUID) { + char *systembuid = NULL; + userpref_get_system_buid(&systembuid); - printf("%s\n", hostid); + printf("%s\n", systembuid); - if (hostid) - free(hostid); + if (systembuid) + free(systembuid); return EXIT_SUCCESS; } @@ -173,6 +176,25 @@ int main(int argc, char **argv) } } + ret = idevice_get_udid(device, &udid); + if (ret != IDEVICE_E_SUCCESS) { + printf("ERROR: Could not get device udid, error code %d\n", ret); + result = EXIT_FAILURE; + goto leave; + } + + if (op == OP_HOSTID) { + char *hostid = NULL; + userpref_device_record_get_host_id(udid, &hostid); + + printf("%s\n", hostid); + + if (hostid) + free(hostid); + + return EXIT_SUCCESS; + } + lerr = lockdownd_client_new(device, &client, "idevicepair"); if (lerr != LOCKDOWN_E_SUCCESS) { idevice_free(device); @@ -196,13 +218,6 @@ int main(int argc, char **argv) } } - ret = idevice_get_udid(device, &udid); - if (ret != IDEVICE_E_SUCCESS) { - printf("ERROR: Could not get device udid, error code %d\n", ret); - result = EXIT_FAILURE; - goto leave; - } - switch(op) { default: case OP_PAIR: @@ -238,8 +253,8 @@ int main(int argc, char **argv) case OP_UNPAIR: lerr = lockdownd_unpair(client, NULL); if (lerr == LOCKDOWN_E_SUCCESS) { - /* also remove local device public key */ - userpref_remove_device_public_key(udid); + /* also remove local device record */ + userpref_remove_device_record(udid); printf("SUCCESS: Unpaired with device %s\n", udid); } else { result = EXIT_FAILURE; |