From 45dd28e6a1ce8bcd42cc7d547c223b05ffebff9b Mon Sep 17 00:00:00 2001 From: Rick Mark Date: Thu, 7 May 2020 09:42:23 -0700 Subject: Do not perform preflight on T2 devices --- src/device.c | 2 +- src/main.c | 16 ++++++++++++---- src/preflight.c | 10 +++++++++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/device.c b/src/device.c index 6858cf5..64e4e8d 100644 --- a/src/device.c +++ b/src/device.c @@ -690,7 +690,7 @@ static void device_tcp_input(struct mux_device *dev, struct tcphdr *th, unsigned return; } conn->state = CONN_CONNECTED; - usbmuxd_log(LL_DEBUG, "Client connected to device %d (%d->%d)", dev->id, sport, dport); + usbmuxd_log(LL_INFO, "Client connected to device %d (%d->%d)", dev->id, sport, dport); if(client_notify_connect(conn->client, RESULT_OK) < 0) { conn->client = NULL; connection_teardown(conn); diff --git a/src/main.c b/src/main.c index aede710..7c22092 100644 --- a/src/main.c +++ b/src/main.c @@ -53,10 +53,13 @@ static const char *socket_path = "/var/run/usbmuxd"; static const char *lockfile = "/var/run/usbmuxd.pid"; +// Global state used in other files int should_exit; int should_discover; int use_logfile = 0; +int no_preflight = 0; +// Global state for main.c static int verbose = 0; static int foreground = 0; static int drop_privileges = 0; @@ -151,7 +154,7 @@ static void set_signal_handlers(void) sigaddset(&set, SIGUSR1); sigaddset(&set, SIGUSR2); sigprocmask(SIG_SETMASK, &set, NULL); - + memset(&sa, 0, sizeof(struct sigaction)); sa.sa_handler = handle_signal; sigaction(SIGINT, &sa, NULL); @@ -368,6 +371,7 @@ static void usage() printf(" \tStarting another instance will trigger discovery instead.\n"); printf(" -z, --enable-exit\tEnable \"--exit\" request from other instances and exit\n"); printf(" \tautomatically if no device is attached.\n"); + printf(" -p, --no-preflight\tDisable lockdownd preflight on new device.\n"); #ifdef HAVE_UDEV printf(" -u, --udev\t\tRun in udev operation mode (implies -n and -z).\n"); #endif @@ -392,6 +396,7 @@ static void parse_opts(int argc, char **argv) {"user", required_argument, NULL, 'U'}, {"disable-hotplug", no_argument, NULL, 'n'}, {"enable-exit", no_argument, NULL, 'z'}, + {"no-preflight", no_argument, NULL, 'p'}, #ifdef HAVE_UDEV {"udev", no_argument, NULL, 'u'}, #endif @@ -407,11 +412,11 @@ static void parse_opts(int argc, char **argv) int c; #ifdef HAVE_SYSTEMD - const char* opts_spec = "hfvVuU:xXsnzl:"; + const char* opts_spec = "hfvVuU:xXsnzl:p"; #elif HAVE_UDEV - const char* opts_spec = "hfvVuU:xXnzl:"; + const char* opts_spec = "hfvVuU:xXnzl:p"; #else - const char* opts_spec = "hfvVU:xXnzl:"; + const char* opts_spec = "hfvVU:xXnzl:p"; #endif while (1) { @@ -437,6 +442,9 @@ static void parse_opts(int argc, char **argv) drop_privileges = 1; drop_user = optarg; break; + case 'p': + no_preflight = 1; + break; #ifdef HAVE_UDEV case 'u': opt_disable_hotplug = 1; diff --git a/src/preflight.c b/src/preflight.c index c7cfa50..820f3fc 100644 --- a/src/preflight.c +++ b/src/preflight.c @@ -41,6 +41,9 @@ #include "client.h" #include "conf.h" #include "log.h" +#include "usb.h" + +extern int no_preflight; #ifdef HAVE_LIBIMOBILEDEVICE #ifndef HAVE_ENUM_IDEVICE_CONNECTION_TYPE @@ -270,7 +273,7 @@ retry: "com.apple.mobile.lockdown.request_pair", "com.apple.mobile.lockdown.request_host_buid", NULL - }; + }; np_observe_notifications(np, spec); /* TODO send notification to user's desktop */ @@ -353,6 +356,11 @@ void preflight_device_remove_cb(void *data) void preflight_worker_device_add(struct device_info* info) { + if (info->pid == PID_APPLE_T2_COPROCESSOR || no_preflight == 1) { + client_device_add(info); + return; + } + #ifdef HAVE_LIBIMOBILEDEVICE struct device_info *infocopy = (struct device_info*)malloc(sizeof(struct device_info)); -- cgit v1.1-32-gdbae