History log of /system/core/adb/adb_auth_host.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
a761231b96f0da85ff01a4a22fe3a04487c634d9 01-May-2017 Elliott Hughes <enh@google.com> Stop writing NUL bytes in adbkey.pub.

In N we moved some code from C to C++ without realizing that EVP_EncodedLength
includes space for a terminating NUL and EVP_EncodeBlock writes one. Because
our key reading code copes with the NUL, we never noticed.

Distinguish between the required space returned by EVP_EncodedLength and the
actual number of bytes (not including NUL) used return by EVP_EncodeBlock.

Bug: http://b/36187819
Test: hexdump of ~/.android/adbkey.pub

(cherry picked from commit 0b771b33fd934db9a7962ad704cdd38f72895c1a)

Change-Id: I6e16b8d48d097b4054417c1d1a225bf7ece985b9
/system/core/adb/adb_auth_host.cpp
fb9a7e5995d2e6c2c7f08080201d41fe0f6c4b53 19-Jan-2017 Josh Gao <jmgao@google.com> adb: check for and report inotify_init1 failure.

Bug: http://b/34396687
Test: mma
Change-Id: I55ea84db49017a6533ac54db5072e3e75ba30097
/system/core/adb/adb_auth_host.cpp
a27666b823b265eeab6cb0e9355fd4bcbc34c6e3 15-Dec-2016 Josh Gao <jmgao@google.com> adb: don't require adb keys to be named "*.adb_key".

Don't require the extension on explicit file paths passed on; only
check for it in monitored directories.

Bug: http://b/33638233
Test: ADB_TRACE=1 ADB_VENDOR_KEYS=$HOME/foo adb server nodaemon
Change-Id: I7387e0bbe0f2e16878bf22b05d5c6e8d0f9e5a92
/system/core/adb/adb_auth_host.cpp
06d61d4d96d28777f76578fb5d3c823168853166 06-Oct-2016 Josh Gao <jmgao@google.com> adb: rationalize types.

Use fixed length types for structs going over the wire, constify
arguments where possible, use char* instead of unsigned char* for
apacket data, and assorted other refactoring.

Bug: http://b/29273531
Test: python test_device.py with every combination of old/new adb and adbd
Change-Id: I0b6f818a32be5386985aa4519f542003cf427f9d
/system/core/adb/adb_auth_host.cpp
3bd2879d8e9bb0c0a1b8045e09f9cf87c2daeef3 06-Oct-2016 Josh Gao <jmgao@google.com> adb: split up adb_auth.cpp.

All of the functions in adb_auth.cpp were used in only one of
adb/adbd. Split up them up into adb_auth_host.cpp and adbd_auth.cpp
respectively.

Bug: http://b/29273531
Test: built and flashed bullhead, adb still works
Change-Id: Ib610c5157522634cc273511175152f1306cc52a7
/system/core/adb/adb_auth_host.cpp
7eaef8a494b1e8c6f015d8ca239865c6032facf3 06-Sep-2016 Pirama Arumuga Nainar <pirama@google.com> Use <condition_variable> and <mutex.h> from MinGW

New MinGW prebuilts update includes pthreads and C++11 threads support.
Use mutex.h and condition_variable provided by MinGW.

Test: Build AOSP with new MinGW prebuilts
Change-Id: Ia8f890f86652612df3fc2618c2bfbb450a5a2f52
/system/core/adb/adb_auth_host.cpp
e0b7502c7fb12b0ac03a5903562c74820975b833 31-Aug-2016 Josh Gao <jmgao@google.com> adb: add helper to get the ~/.android directory.

Extract the logic for creating ~/.android out of get_user_key_path into
its own function. Also, fall back to getpwuid_r when $HOME isn't
defined.

Change-Id: I676a7c750cb364f89b544818ffda07903d14fb97
Test: ran adb with ~/.android missing
/system/core/adb/adb_auth_host.cpp
2e671202c38a9b17b0b034438a305e3067abb4ab 19-Aug-2016 Josh Gao <jmgao@google.com> adb: add support for vendor key directories.

Allow directories to be specified in ADB_VENDOR_KEYS. On Linux, monitor
this directory for new keys to be added.

Additionally, deduplicate keys by hashing their public key.

Bug: http://b/29273531
Bug: http://b/30927527
Change-Id: I8d3312b216b7f2c11900f2235f1f1b1d1c7aa767
Test: manually tested by adding a key to a directory, and verifying
that devices became authorized after replugging.
/system/core/adb/adb_auth_host.cpp
0aeb50500c76ea67d6f452907f5503d590e81a54 30-Jun-2016 Elliott Hughes <enh@google.com> 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
/system/core/adb/adb_auth_host.cpp
625faf019648255ba1133a67ad1fa844b6de79ec 22-Jun-2016 Elliott Hughes <enh@google.com> Address old review comments in adb_auth_host.cpp.

Comments from:
https://android-review.googlesource.com/#/c/212781/4/adb/adb_auth_host.cpp@107

Bug: http://b/28152031
Change-Id: I27d062f3eeb8db90f94b1b4f5d7204000a7ac73d
Test: manually removed ~/.android/adb* and checked they were recreated correctly.
/system/core/adb/adb_auth_host.cpp
e8b663fec3acfefbef6396a23c6f48d66e1f19fc 27-May-2016 Elliott Hughes <enh@google.com> Kill load_file.

Change-Id: I6c332f7d8e94d513605295b3d4d32c4e1cf878dc
/system/core/adb/adb_auth_host.cpp
dace01526996ee221796c4627a615d393eee205b 26-May-2016 Yurii Zubrytskyi <zyy@google.com> [adb] Followup CL to clean up adb_auth_host.cpp

Get rid of unused includes + replace a fixed-size buffer with an
std::string

(cherry-pick of 049ebb810f466d916ec9e73cdf28624b57a8c25d.)

Change-Id: I4f9927b900a79a012b5d52908b9d22ac3d2a401c
/system/core/adb/adb_auth_host.cpp
376b27532cba70545f63d7e5d32da876a636ac0d 26-May-2016 Yurii Zubrytskyi <zyy@google.com> [adb] Issue the "auth" emulator command before any other one

Emulator console now requires authentication; this means
'adb emu ...' commands silently fail because of it.
This CL adds an 'auth <token>' command to each user command,
making sure it won't be silently ignored.

(cherry-pick of a9e2b99a7fdd31bcd6d852c6db26fe592236a24f.)

Bug: https://code.google.com/p/android/issues/detail?id=211233
Change-Id: Id9ca4999fd2e6393cc88278eaf444243e13c0ec0
/system/core/adb/adb_auth_host.cpp
097b6bbc76231f4148c9dd28b6ea0c1189d40fc3 31-Mar-2016 Mattias Nissler <mnissler@google.com> Switch fs_mgr and adb to libcrypto_utils.

Update code and dependencies to use BoringSSL + libcrypto_utils
instead of mincrypt.

Change-Id: Ic75164bd50c84b81b6310e27a67d4b3c174984f9
/system/core/adb/adb_auth_host.cpp
5f787ed2b3b9f6cc02aa5923b95d77e2a5865438 27-Jan-2016 David Pursell <dpursell@google.com> base: add SystemErrorCodeToString() function.

Pulls the Windows error string generation out of adb into libbase so
that it can be used by fastboot as well. Also makes a Unix equivalent
that just wraps strerror() so that upcoming fastboot error reporting
code can be platform-independent.

The intent here is just to provide a portable way to report an error to
the user. More general cross-platform error handling is out of scope.

Bug: http://b/26236380
Change-Id: I5a784a844775949562d069bb41dcb0ebd13a32bc
/system/core/adb/adb_auth_host.cpp
4f71319df011d796a60a43fc1bc68e16fbf7d321 05-Dec-2015 Elliott Hughes <enh@google.com> Track rename of base/ to android-base/.

Change-Id: Idf9444fece4aa89c93e15640de59a91f6e758ccf
/system/core/adb/adb_auth_host.cpp
d21dc825bbecad6ce480c5e5c574cc77eadcd779 13-Nov-2015 Spencer Low <CompareAndSwap@gmail.com> adb: win32: remove widen()/narrow() in favor of UTF8ToWide()/WideToUTF8()

Now that we have a more standardized API (also available in Chromium),
switch to it. Another benefit is real error handling instead of just
killing the process on invalid Unicode.

Make UTF8ToWide()/WideToUTF8() set errno to EILSEQ on bad input. This is
the same error code that wcsrtombs(3) uses.

Update the unittest to check for EILSEQ.

Change-Id: Ie92acf74d37adaea116cf610c1bf8cd433741e16
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
/system/core/adb/adb_auth_host.cpp
65fe2516b402ed8903f2ce39a86fa0bdc2b263a6 08-Oct-2015 Elliott Hughes <enh@google.com> Use const auto&/auto&& in adb.

Change-Id: I74a7e511302e15e207906f572d181634e0ed5604
/system/core/adb/adb_auth_host.cpp
aed3c61c4437ebb05eadfb3bf85d6962c30b9935 23-Sep-2015 Yabin Cui <yabinc@google.com> Adb: use VLOG() to replace D() for verbose logging.

As there are too many D(), we can keep both VLOG() and D() now, and get
rid of D() gradually.

Change-Id: I2f1cb70bcab3e82c99fed939341d03f6b2216076
/system/core/adb/adb_auth_host.cpp
7a3f8d6691b3fbd8014a98de8455dbcfcc9629e4 03-Sep-2015 Yabin Cui <yabinc@google.com> adb: clean up debug tracing a little.

Always use LOG() for debug tracing.
Remove useless D_lock. I believe it is useless to lock just before and after fprintf.

I verified the log output both on host and on device. The output looks fine to me.

Change-Id: I96ccfe408ff56864361551afe9ad464d197ae104
/system/core/adb/adb_auth_host.cpp
8df90321769c670b546a7ff0e7a14f2d7a79cc25 03-Aug-2015 Spencer Low <CompareAndSwap@gmail.com> adb: win32: call SystemErrorCodeToString() from more places

Improve some error messages, or trace output.

Change-Id: Ib09fac33a296f090d37f125cad7556fc5b5e928e
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
/system/core/adb/adb_auth_host.cpp
cf4ff64f2d3cdc4ffa2f06e594d18a965f591a82 11-May-2015 Spencer Low <CompareAndSwap@gmail.com> adb: win32: Unicode path names, env vars, some console support

Initial support for Unicode file/dir names. Unicode paths can be passed
on the command line, directory enumeration can enumerate Unicode paths,
Unicode paths are used for file access, and Unicode paths can be output
on the console correctly.

Also Unicode environment variable access.

Initial support for Unicode output from adb shell (which uses
adb_fwrite()). This is partial because the corner case of an
adb_fwrite() call with an incomplete UTF-8 multi-byte sequence does not
output correctly, but this should be uncommon, is better than what we
had before (*always* incorrect UTF-8 multi-byte sequences) and can be
fixed in the future.

Calls to Windows APIs with char strings were changed to pass wchar_t
strings to the FooW() variants.

For more details, see the giant comment in sysdeps_win32.cpp.

https://code.google.com/p/android/issues/detail?id=8185

Change-Id: I7ebf6713bb635638b986ccee97b354428837c9c5
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
/system/core/adb/adb_auth_host.cpp
3d2904cdf2371e26c0465184436bd063979a5d97 13-Jul-2015 Tamas Berghammer <tberghammer@google.com> Increase size of the the adb packets sent over the wire

The reason behing this change is to increase the adb push/pull speed
with reduceing the number of packets sent between the host and the
device because the communication is heavily bound by packet latency.

The change maintains two way compatibility in the communication
protocol with negotiating a packet size between the target and the
host with the CONNECT packets.

After this change the push/pull speeds improved significantly
(measured from Linux-x86_64 with 100MB of data):

| Old push | Old pull || New push | New pull |
-----------------------------------------------------------
Hammerhead | 4.6 MB/s | 3.9 MB/s || 13.1 MB/s | 16.5 MB/s |
-----------------------------------------------------------
Volantis | 6.0 MB/s | 6.2 MS/s || 25.9 MB/s | 29.0 MB/s |
-----------------------------------------------------------
Fugu | 6.0 MB/s | 5.1 MB/s || 27.9 MB/s | 33.2 MB/s |
-----------------------------------------------------------

Change-Id: Id9625de31266e43394289e325c7e7e473379c5d8
/system/core/adb/adb_auth_host.cpp
8d8126a705dd3c5734a0894f88c2c758784bd469 21-Jul-2015 Spencer Low <CompareAndSwap@gmail.com> adb: logging: newlines, thread ids, error code overwriting

Add missing \n to uses of legacy D() macro. This should make the legacy
logging easier to read (and harder to miss important stuff).

On POSIX, use gettid() from libcutils instead of pthread_self() so that
the output shows a more reasonable number instead of a pointer value.
This should be ok since libbase's logging already uses gettid().

Win32:

Don't let the Win32 last error get overwritten by API calls after the
original error'ing API. When encountering an unknown error, log the
specific error code.

Change-Id: Ib8f72754efa7ba895d2f1cd914251fec2a1d894c
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
/system/core/adb/adb_auth_host.cpp
286bb6ddbd52584af0c6c76fbe0498f3dea4b944 09-Jul-2015 Dan Albert <danalbert@google.com> Revert "Turn on -Wformat-nonliteral."

One of my build aliases doesn't play nice with USE_MINGW=1, so my build lied to me. Will revert until I fix it up.

This reverts commit 459df8f3a14d4c614f0211049800cf7cad6d30ad.

Change-Id: I7905c5ae5ee85fb2d228ce63d81c79f140998c18
/system/core/adb/adb_auth_host.cpp
459df8f3a14d4c614f0211049800cf7cad6d30ad 08-Jul-2015 Dan Albert <danalbert@google.com> Turn on -Wformat-nonliteral.

Apparently there are two classes of this warning in clang.
-Wformat-security is only emitted for cases of
`func(nonliteral_fmt_string)` (no args), and -Wformat-nonliteral is
emitted for cases *with* arguments. For whatever reason, the latter
isn't included in -Wextra and must be manually enabled.

To make this more easily portable to Windows, move the existing
gnu_printf/__printf__ decision into base/macros.h as ATTRIBUTE_FORMAT.

Change-Id: I3b0990e1d1f0a2e9c13b32f5cd60478946cb5fc6
/system/core/adb/adb_auth_host.cpp
6ac5d7dc56a016718d2a26803435505e983e5d80 23-May-2015 Spencer Low <CompareAndSwap@gmail.com> adb: fix adb_close() vs. unix_close() usage

Document the differences between adb_*() and unix_*() in the function
prototypes in sysdeps.h. See the file for the details (CR/LF
translation, well-known file descriptors, etc.).

Fix adb_read(), adb_write(), and adb_close() calls that should really be
unix_read(), unix_write(), and unix_close(). Note that this should have
no impact on unix because on unix, unix_read/unix_write/unix_close are
macros that map to adb_read/adb_write/adb_close.

Improve sysdeps_win32.cpp file descriptor diagnostic logging to output
the name of the function that was passed a bad file descriptor.

Change-Id: I0a1d9c28772656c80bcc303ef8b61fccf4cd637c
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
/system/core/adb/adb_auth_host.cpp
ac3f7d9a78f9024563cc47f62206c6e3475778dd 20-May-2015 Spencer Low <CompareAndSwap@gmail.com> adb / libbase: clean up NOGDI and evil ERROR macro

Instead of defining and undefining NOGDI:

1. Always #include "base/logging.h" after #include <windows.h>.
Unfortunately, I could not find an easy way to give the user a
warning/error if they include in the wrong order.

2. base/logging.h does #undef ERROR to undefine the evil ERROR macro
that is from another era and probably a bad idea to begin with.

Change-Id: I995d89620611e849af9d7ec47eb55fc0512377f2
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
/system/core/adb/adb_auth_host.cpp
9b9603148b0a42ee9b4fc2df76bfde31ba29c311 08-May-2015 Spencer Low <CompareAndSwap@gmail.com> adb: win32: fix key files reading/writing

The issue is that adb uses fopen() with "e" (presumably to open the file
with O_CLOEXEC), but that flag causes MSVCRT.DLL to return an error. So
when adb_auth_host.cpp goes to read or write the adbkey files, it fails.

The quick fix is to not use the "e" option on adb host code since it
isn't necessary there, compared to adbd.

An alternative fix would be to have a fopen() wrapper on Windows that
filters out the "e" option.

Change-Id: I7d8ba2847dab0ed558ffe156e79093251eb253c9
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
/system/core/adb/adb_auth_host.cpp
142ec75cf882bf023853f0321cd559377daccc60 07-May-2015 Spencer Low <CompareAndSwap@gmail.com> adb: win32: fix adb emu command

The adb emu command was never working because the socket connection to
the emulator was closed without reading all of the data that the
emulator sent. On Windows, this caused the emulator's recv() call to
error-out, so it never got the command that was sent.

Before settling on this fix, I also experimented changing the arguments
to the socket shutdown() call and that didn't seem to help. I also tried
removing the call to shutdown() and that didn't help. So that should
rule out shutdown() as the problem. One experiment that helped was
delaying before calling adb_close(), but that is of course fragile and
doesn't address the real issue, which is not closing the socket until
the commands have been read.

https://code.google.com/p/android/issues/detail?id=21021

Change-Id: I8fa4d740a2faa2c9922ec50792e16564a94f6eed
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
/system/core/adb/adb_auth_host.cpp
8d5fa6da44d56511b3e173bc463cbc65ff221b4a 25-Apr-2015 Elliott Hughes <enh@google.com> Remove strtok from adb.

Also fix android::base::Split to behave like Java, Python, and google3.

Change-Id: Ifbffd4e92950a79e7aea5d153c95fe0980648417
/system/core/adb/adb_auth_host.cpp
3313426fad9eaaf53017cdbde889ebcec91358ec 19-Mar-2015 Dan Albert <danalbert@google.com> File header cleanup.

* sysdeps.h should always be included first.
* TRACE_TAG needs to be defined before anything is included.
* Some files were missing copyright headers.
* Save precious bytes on my SSD by removing useless whitespace.

Change-Id: I88980e6e00b5be1093806cf286740d9e4a033b94
/system/core/adb/adb_auth_host.cpp
bac3474a8256cb32a29e8d46f78cad95a5502692 26-Feb-2015 Dan Albert <danalbert@google.com> Move adb to C++.

I keep trying to clean things up and needing std::strings. Might as
well just do this now.

usb_linux_client.c is going to stay as C because GCC isn't smart
enough to deal with the designated initializers it uses (though for
some reason it is in C mode).

The Darwin files are staying as C because I don't have a way to test
that they build.

The Windows files are staying as C because while I can actually build
for them, it's slow and painful.

Change-Id: I75367d29205a9049d34460032b3bb36384f43941
/system/core/adb/adb_auth_host.cpp