Clean up key handling in adb.
This includes the locking we need to be able to re-load the keys at runtime.
We should rename "adb_auth_client.cpp" to "adb_auth_adbd.cpp" or
"adbd_auth.cpp" in a later change.
Change-Id: I9e1d5b6b7d0497d6f6e5d9c4fb660118cdff05a8
Test: "adb devices" works against a non-AOSP device with $ADB_VENDOR_KEYS set, says "unauthorized" without.
Bug: http://b/29273531
diff --git a/adb/client/main.cpp b/adb/client/main.cpp
index d2ca44e..e160169 100644
--- a/adb/client/main.cpp
+++ b/adb/client/main.cpp
@@ -110,7 +110,6 @@
usb_init();
local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT);
- adb_auth_init();
std::string error;
std::string local_name = android::base::StringPrintf("tcp:%d", server_port);
@@ -118,11 +117,14 @@
fatal("could not install *smartsocket* listener: %s", error.c_str());
}
- // Inform our parent that we are up and running.
if (is_daemon) {
close_stdin();
setup_daemon_logging();
+ }
+ adb_auth_init();
+
+ if (is_daemon) {
#if !defined(_WIN32)
// Start a new session for the daemon. Do this here instead of after the fork so
// that a ctrl-c between the "starting server" and "done starting server" messages
@@ -132,6 +134,8 @@
}
#endif
+ // Inform our parent that we are up and running.
+
// Any error output written to stderr now goes to adb.log. We could
// keep around a copy of the stderr fd and use that to write any errors
// encountered by the following code, but that is probably overkill.