summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2024-11-15 00:18:05 +0100
committerGravatar Nikias Bassen2024-11-15 00:18:05 +0100
commitba829e6f1a62bdad7866572d1e2cff1836ced742 (patch)
tree5c4b23e376c90a664fe7089998e0a3e3c19a2552 /tools
parent5aebbc0c694d1048712505195c32a17c3091d417 (diff)
downloadlibimobiledevice-ba829e6f1a62bdad7866572d1e2cff1836ced742.tar.gz
libimobiledevice-ba829e6f1a62bdad7866572d1e2cff1836ced742.tar.bz2
tools: Add --insecure option to idevicenotificationproxy tool
Diffstat (limited to 'tools')
-rw-r--r--tools/idevicenotificationproxy.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/tools/idevicenotificationproxy.c b/tools/idevicenotificationproxy.c
index d1e25c1..00da916 100644
--- a/tools/idevicenotificationproxy.c
+++ b/tools/idevicenotificationproxy.c
@@ -2,7 +2,8 @@
2 * idevicenotificationproxy.c 2 * idevicenotificationproxy.c
3 * Simple client for the notification_proxy service 3 * Simple client for the notification_proxy service
4 * 4 *
5 * Copyright (c) 2009-2015 Martin Szulecki All Rights Reserved. 5 * Copyright (c) 2018-2024 Nikias Bassen, All Rights Reserved.
6 * Copyright (c) 2009-2015 Martin Szulecki, All Rights Reserved.
6 * 7 *
7 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
@@ -75,6 +76,7 @@ static void print_usage(int argc, char **argv, int is_error)
75 "\n" 76 "\n"
76 "The following OPTIONS are accepted:\n" 77 "The following OPTIONS are accepted:\n"
77 " -u, --udid UDID target specific device by UDID\n" 78 " -u, --udid UDID target specific device by UDID\n"
79 " -i, --insecure use insecure notification proxy (non-paired device)\n"
78 " -n, --network connect to network device\n" 80 " -n, --network connect to network device\n"
79 " -d, --debug enable communication debugging\n" 81 " -d, --debug enable communication debugging\n"
80 " -h, --help prints usage information\n" 82 " -h, --help prints usage information\n"
@@ -102,6 +104,7 @@ int main(int argc, char *argv[])
102 int i = 0; 104 int i = 0;
103 const char* udid = NULL; 105 const char* udid = NULL;
104 int use_network = 0; 106 int use_network = 0;
107 int insecure = 0;
105 int cmd = CMD_NONE; 108 int cmd = CMD_NONE;
106 char* cmd_arg = NULL; 109 char* cmd_arg = NULL;
107 110
@@ -114,6 +117,7 @@ int main(int argc, char *argv[])
114 { "debug", no_argument, NULL, 'd' }, 117 { "debug", no_argument, NULL, 'd' },
115 { "help", no_argument, NULL, 'h' }, 118 { "help", no_argument, NULL, 'h' },
116 { "udid", required_argument, NULL, 'u' }, 119 { "udid", required_argument, NULL, 'u' },
120 { "insecure", no_argument, NULL, 'i' },
117 { "network", no_argument, NULL, 'n' }, 121 { "network", no_argument, NULL, 'n' },
118 { "version", no_argument, NULL, 'v' }, 122 { "version", no_argument, NULL, 'v' },
119 { NULL, 0, NULL, 0} 123 { NULL, 0, NULL, 0}
@@ -127,7 +131,7 @@ int main(int argc, char *argv[])
127#endif 131#endif
128 132
129 /* parse cmdline args */ 133 /* parse cmdline args */
130 while ((c = getopt_long(argc, argv, "dhu:nv", longopts, NULL)) != -1) { 134 while ((c = getopt_long(argc, argv, "dhu:inv", longopts, NULL)) != -1) {
131 switch (c) { 135 switch (c) {
132 case 'd': 136 case 'd':
133 idevice_set_debug_level(1); 137 idevice_set_debug_level(1);
@@ -143,6 +147,9 @@ int main(int argc, char *argv[])
143 case 'n': 147 case 'n':
144 use_network = 1; 148 use_network = 1;
145 break; 149 break;
150 case 'i':
151 insecure = 1;
152 break;
146 case 'h': 153 case 'h':
147 print_usage(argc, argv, 0); 154 print_usage(argc, argv, 0);
148 return 0; 155 return 0;
@@ -214,12 +221,17 @@ int main(int argc, char *argv[])
214 goto cleanup; 221 goto cleanup;
215 } 222 }
216 223
217 if (LOCKDOWN_E_SUCCESS != (ret = lockdownd_client_new_with_handshake(device, &client, TOOL_NAME))) { 224 if (insecure) {
218 fprintf(stderr, "ERROR: Could not connect to lockdownd, error code %d\n", ret); 225 ret = lockdownd_client_new(device, &client, TOOL_NAME);
226 } else {
227 ret = lockdownd_client_new_with_handshake(device, &client, TOOL_NAME);
228 }
229 if (LOCKDOWN_E_SUCCESS != ret) {
230 fprintf(stderr, "ERROR: Could not connect to lockdownd: %s (%d)\n", lockdownd_strerror(ret), ret);
219 goto cleanup; 231 goto cleanup;
220 } 232 }
221 233
222 ret = lockdownd_start_service(client, NP_SERVICE_NAME, &service); 234 ret = lockdownd_start_service(client, (insecure) ? "com.apple.mobile.insecure_notification_proxy" : NP_SERVICE_NAME, &service);
223 235
224 lockdownd_client_free(client); 236 lockdownd_client_free(client);
225 237