summaryrefslogtreecommitdiffstats
path: root/adb
diff options
context:
space:
mode:
authorBenoit Goby <benoit@android.com>2013-02-21 23:55:57 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-02-21 23:55:57 +0000
commit1531c966c11a8e3fe5099d8018715560923ffc9f (patch)
tree3713818f066088ab955b53b41b4cec128984b391 /adb
parent747b0cf109eb67f38b0e854369a8282aca6e6b0c (diff)
parent045a4a9c3a317e60ab1078f5a689bf302ee2ab19 (diff)
downloadsystem_core-1531c966c11a8e3fe5099d8018715560923ffc9f.zip
system_core-1531c966c11a8e3fe5099d8018715560923ffc9f.tar.gz
system_core-1531c966c11a8e3fe5099d8018715560923ffc9f.tar.bz2
Merge "adb: Fix secure adb when booting with usb attached"
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 949e5ea..530a4c8 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)