summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/ideviceprovision.c65
1 files changed, 61 insertions, 4 deletions
diff --git a/tools/ideviceprovision.c b/tools/ideviceprovision.c
index 79293bc..26ec418 100644
--- a/tools/ideviceprovision.c
+++ b/tools/ideviceprovision.c
@@ -59,6 +59,7 @@ static void print_usage(int argc, char **argv)
59 printf(" \tfrom the device and stores it into the exisiting directory\n"); 59 printf(" \tfrom the device and stores it into the exisiting directory\n");
60 printf(" \tspecified by PATH. The file will be stored as UUID.mobileprovision.\n"); 60 printf(" \tspecified by PATH. The file will be stored as UUID.mobileprovision.\n");
61 printf(" remove UUID\tRemoves the provisioning profile identified by UUID.\n"); 61 printf(" remove UUID\tRemoves the provisioning profile identified by UUID.\n");
62 printf(" remove-all\tRemoves all installed provisioning profiles.\n");
62 printf(" dump FILE\tPrints detailed information about the provisioning profile\n"); 63 printf(" dump FILE\tPrints detailed information about the provisioning profile\n");
63 printf(" \tspecified by FILE.\n\n"); 64 printf(" \tspecified by FILE.\n\n");
64 printf(" The following OPTIONS are accepted:\n"); 65 printf(" The following OPTIONS are accepted:\n");
@@ -319,6 +320,11 @@ int main(int argc, char *argv[])
319 op = OP_REMOVE; 320 op = OP_REMOVE;
320 continue; 321 continue;
321 } 322 }
323 else if (!strcmp(argv[i], "remove-all")) {
324 i++;
325 op = OP_REMOVE;
326 continue;
327 }
322 else if (!strcmp(argv[i], "dump")) { 328 else if (!strcmp(argv[i], "dump")) {
323 i++; 329 i++;
324 if (!argv[i] || (strlen(argv[i]) < 1)) { 330 if (!argv[i] || (strlen(argv[i]) < 1)) {
@@ -546,14 +552,65 @@ int main(int argc, char *argv[])
546 fprintf(stderr, "Could not get installed profiles from device, status code: 0x%x\n", sc); 552 fprintf(stderr, "Could not get installed profiles from device, status code: 0x%x\n", sc);
547 res = -1; 553 res = -1;
548 } 554 }
555 plist_free(profiles);
549 } 556 }
550 break; 557 break;
551 case OP_REMOVE: 558 case OP_REMOVE:
552 if (misagent_remove(mis, param) == MISAGENT_E_SUCCESS) { 559 if (param) {
553 printf("Profile '%s' removed.\n", param); 560 /* remove specified provisioning profile */
561 if (misagent_remove(mis, param) == MISAGENT_E_SUCCESS) {
562 printf("Profile '%s' removed.\n", param);
563 } else {
564 int sc = misagent_get_status_code(mis);
565 fprintf(stderr, "Could not remove profile '%s', status code 0x%x\n", param, sc);
566 }
554 } else { 567 } else {
555 int sc = misagent_get_status_code(mis); 568 /* remove all provisioning profiles */
556 fprintf(stderr, "Could not remove profile '%s', status code 0x%x\n", param, sc); 569 plist_t profiles = NULL;
570 misagent_error_t merr;
571 if (product_version < 0x090300) {
572 merr = misagent_copy(mis, &profiles);
573 } else {
574 merr = misagent_copy_all(mis, &profiles);
575 }
576 if (merr == MISAGENT_E_SUCCESS) {
577 uint32_t j;
578 uint32_t num_removed = 0;
579 for (j = 0; j < plist_array_get_size(profiles); j++) {
580 char* p_name = NULL;
581 char* p_uuid = NULL;
582 plist_t profile = plist_array_get_item(profiles, j);
583 plist_t pl = profile_get_embedded_plist(profile);
584 if (pl && (plist_get_node_type(pl) == PLIST_DICT)) {
585 plist_t node;
586 node = plist_dict_get_item(pl, "Name");
587 if (node && (plist_get_node_type(node) == PLIST_STRING)) {
588 plist_get_string_val(node, &p_name);
589 }
590 node = plist_dict_get_item(pl, "UUID");
591 if (node && (plist_get_node_type(node) == PLIST_STRING)) {
592 plist_get_string_val(node, &p_uuid);
593 }
594 }
595 if (p_uuid) {
596 if (misagent_remove(mis, p_uuid) == MISAGENT_E_SUCCESS) {
597 printf("OK profile removed: %s - %s\n", p_uuid, (p_name) ? p_name : "(no name)");
598 num_removed++;
599 } else {
600 int sc = misagent_get_status_code(mis);
601 printf("FAIL profile not removed: %s - %s (status code 0x%x)\n", p_uuid, (p_name) ? p_name : "(no name)", sc);
602 }
603 }
604 free(p_name);
605 free(p_uuid);
606 }
607 printf("%d profiles removed.\n", num_removed);
608 } else {
609 int sc = misagent_get_status_code(mis);
610 fprintf(stderr, "Could not get installed profiles from device, status code: 0x%x\n", sc);
611 res = -1;
612 }
613 plist_free(profiles);
557 } 614 }
558 break; 615 break;
559 default: 616 default: