summaryrefslogtreecommitdiffstats
path: root/adb
diff options
context:
space:
mode:
authorBenoit Goby <benoit@android.com>2013-01-15 19:59:14 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-02-02 01:19:06 +0000
commit045a4a9c3a317e60ab1078f5a689bf302ee2ab19 (patch)
tree4f95380b3155665885f758ba9efae0097a29add8 /adb
parent544d196e2269503136f73347e6d652b23bb87a0d (diff)
downloadsystem_core-045a4a9c3a317e60ab1078f5a689bf302ee2ab19.zip
system_core-045a4a9c3a317e60ab1078f5a689bf302ee2ab19.tar.gz
system_core-045a4a9c3a317e60ab1078f5a689bf302ee2ab19.tar.bz2
adb: Fix secure adb when booting with usb attached
When booting with usb attached, the secure adb authentication happens long before the framework is done booting, so adb can't notify the framework to install the public key. Change-Id: Id2af6cebece345022f56cb0c4b5af24e1d7a425c
Diffstat (limited to 'adb')
-rw-r--r--adb/adb.c2
-rw-r--r--adb/adb_auth.h2
-rw-r--r--adb/adb_auth_client.c30
3 files changed, 29 insertions, 5 deletions
diff --git a/adb/adb.c b/adb/adb.c
index c57a875..18983c4 100644
--- a/adb/adb.c
+++ b/adb/adb.c
@@ -326,7 +326,7 @@ static void send_connect(atransport *t)
send_packet(cp, t);
}
-static void send_auth_request(atransport *t)
+void send_auth_request(atransport *t)
{
D("Calling send_auth_request\n");
apacket *p;
diff --git a/adb/adb_auth.h b/adb/adb_auth.h
index 96f637b..b24c674 100644
--- a/adb/adb_auth.h
+++ b/adb/adb_auth.h
@@ -20,6 +20,8 @@
void adb_auth_init(void);
void adb_auth_verified(atransport *t);
+void send_auth_request(atransport *t);
+
/* AUTH packets first argument */
/* Request */
#define ADB_AUTH_TOKEN 1
diff --git a/adb/adb_auth_client.c b/adb/adb_auth_client.c
index a4ad18f..efc49eb 100644
--- a/adb/adb_auth_client.c
+++ b/adb/adb_auth_client.c
@@ -43,6 +43,10 @@ static char *key_paths[] = {
static fdevent listener_fde;
static int framework_fd = -1;
+static void usb_disconnected(void* unused, atransport* t);
+static struct adisconnect usb_disconnect = { usb_disconnected, 0, 0, 0 };
+static atransport* usb_transport;
+static bool needs_retry = false;
static void read_keys(const char *file, struct listnode *list)
{
@@ -155,21 +159,30 @@ int adb_auth_verify(void *token, void *sig, int siglen)
return ret;
}
+static void usb_disconnected(void* unused, atransport* t)
+{
+ D("USB disconnect");
+ remove_transport_disconnect(usb_transport, &usb_disconnect);
+ usb_transport = NULL;
+ needs_retry = false;
+}
+
static void adb_auth_event(int fd, unsigned events, void *data)
{
- atransport *t = data;
char response[2];
int ret;
if (events & FDE_READ) {
ret = unix_read(fd, response, sizeof(response));
if (ret < 0) {
- D("Disconnect");
- fdevent_remove(&t->auth_fde);
+ D("Framework disconnect");
+ if (usb_transport)
+ fdevent_remove(&usb_transport->auth_fde);
framework_fd = -1;
}
else if (ret == 2 && response[0] == 'O' && response[1] == 'K') {
- adb_auth_verified(t);
+ if (usb_transport)
+ adb_auth_verified(usb_transport);
}
}
}
@@ -179,8 +192,12 @@ void adb_auth_confirm_key(unsigned char *key, size_t len, atransport *t)
char msg[MAX_PAYLOAD];
int ret;
+ usb_transport = t;
+ add_transport_disconnect(t, &usb_disconnect);
+
if (framework_fd < 0) {
D("Client not connected\n");
+ needs_retry = true;
return;
}
@@ -221,6 +238,11 @@ static void adb_auth_listener(int fd, unsigned events, void *data)
}
framework_fd = s;
+
+ if (needs_retry) {
+ needs_retry = false;
+ send_auth_request(usb_transport);
+ }
}
void adb_auth_init(void)