Commit graph

90 commits

Author SHA1 Message Date
Nick Kralevich
277626e59d am 844306bd: am cc4499b6: Merge "adb: use correct header file."
* commit '844306bd9cb3c8b3e514e5d91e9514556e8f95f4':
  adb: use correct header file.
2013-02-28 23:22:04 +00:00
Nick Kralevich
e2864bf727 adb: use correct header file.
Change-Id: I7a66ced762dc077247fd7c2714ae8850ffdcaeb9
2013-02-28 14:12:58 -08:00
Nick Kralevich
4c609e9683 Remove CAP_NET_RAW from adb
ping no longer needs CAP_NET_RAW. See:

* http://lwn.net/Articles/443051/
* https://android-review.googlesource.com/52090
* https://android-review.googlesource.com/52072

Eliminate the CAP_NET_RAW special case in adb

Change-Id: If9d32c5254291b123b06bededc94b64113f6b8f2
2013-02-27 13:15:02 -08:00
Benoit Goby
1531c966c1 Merge "adb: Fix secure adb when booting with usb attached" 2013-02-21 23:55:57 +00:00
Nick Kralevich
080427e4e2 adb: drop capability bounding set on user builds
run-as: don't require CAP_DAC_OVERRIDE.

Prevent an adb spawned application from acquiring capabilities
other than

* CAP_NET_RAW
* CAP_SETUID
* CAP_SETGID

The only privileged programs accessible on user builds are
* /system/bin/ping
* /system/bin/run-as

and the capabilities above are sufficient to cover those
two programs.

If the kernel doesn't support file capabilities, we ignore
a prctl(PR_CAPBSET_DROP) failure. In a future CL, this could
become a fatal error.

Change-Id: I45a56712bfda35b5ad9378dde9e04ab062fe691a
2013-02-15 21:22:19 -08:00
Nick Kralevich
b9c087031b am e149855a: am 523a2090: Merge "adb: Use 64 bit capabilities."
* commit 'e149855a816c98149a95725139ae66f193049ddd':
  adb: Use 64 bit capabilities.
2013-02-15 10:22:08 -08:00
Nick Kralevich
109f4e16cb adb: Use 64 bit capabilities.
Fix the following kernel warning:

$ adb shell dmesg | grep adb
<6>[    7.813003] warning: `adbd' uses 32-bit capabilities (legacy support in use)

Change-Id: I3912302c5c577f1cb03f0c591834ab7b3a72ddf5
2013-02-15 09:33:13 -08:00
Benoit Goby
045a4a9c3a 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
2013-02-02 01:19:06 +00:00
Kenny Root
49f0f77693 am 282caf3b: am 260f3471: am f8afaebe: Merge "Windows adb: include stdint.h for uint8_t on MinGW-w64"
# By Ray Donnelly
# Via Android Git Automerger (2) and others
* commit '282caf3bd0dfd81b92ac74e0b3ea970d195fee7b':
  Windows adb: include stdint.h for uint8_t on MinGW-w64
2013-01-29 21:54:00 -08:00
Kenny Root
f8afaebec3 Merge "Windows adb: include stdint.h for uint8_t on MinGW-w64" 2013-01-30 05:44:17 +00:00
Benoit Goby
8e85644aa1 Merge "adb: Add "unauthorized" connection state" 2013-01-29 00:17:43 +00:00
David Turner
5bf8a4200c am 3dbcb6d6: am 98d07897: Merge "Windows adb: Make client stdout and stderr handles uninheritable"
* commit '3dbcb6d6c6befc406e4ce4e2b7aa9ad2635dfbb8':
  Windows adb: Make client stdout and stderr handles uninheritable
2013-01-21 02:56:36 -08:00
David Turner
98d0789772 Merge "Windows adb: Make client stdout and stderr handles uninheritable" 2013-01-21 10:16:54 +00:00
Benoit Goby
77e8e5851d adb: Add "unauthorized" connection state
Add a new connection state, so that devices, that require confirmation
to allow adb, appear as "unauthorized" in the adb devices lists.

Change-Id: Ib4264bc5736dedecf05bcf8e31896f4d7a91fad8
2013-01-15 17:21:13 -08:00
JP Abgrall
571c136768 adb: HACK: (linux only) allow temp mitigation for multithreaded issues
There are serious multithreading issues between the fdevent and transport
subsystems which both manipulate struct asocket and struct fde concurrently.
The prevalent symptom being around multiple socket closures which stomp
 on each other, typically causing:
   "glibc detected *** adb: double free or corruption ..."

This HACK allows forcing CPU affinity via an env var. E.g.:
  export ADB_CPU_AFFINITY_BUG6558362=0
which will cause ONLY the adb server and all its threads to be pegged
to CPU 0.

The result is visible in valgrind's helgrind: no *socket_close() related
data races. But tons of other races are still there.

Bug: 6558362
Change-Id: I0f112390a6a921c64b2a783297be9e99ce27fd56
2013-01-09 15:34:21 -08:00
Ray Donnelly
cbb9891049 Windows adb: include stdint.h for uint8_t on MinGW-w64
Change-Id: I84b8284bc034feb0acd313b0aad9e2fa5868854f
2013-01-08 23:11:49 +00:00
Ray Donnelly
267aa8b00e Windows adb: Make client stdout and stderr handles uninheritable
Change-Id: Ib0519a199c9504aad1d0ecc3757f4d162984bf22
2013-01-08 23:02:28 +00:00
Matt Gumbel
d7b3308511 Support adb client connect to remote server
ADB client: allow user to specify hostname and port number of remote
adb server.
ADB server: bind server to all network interfaces instead of just
localhost when user gives -a flag.

Primary use-case for this change is to support remote testing of USB
devices. HostA is running some test automation software which invokes adb
client. HostB has USB-only device attached and is running adb server. adb
client on HostA makes connection to adb server on HostB to talk to the
USB device.

Change-Id: I845cc8c00350b400317f8c18f813e6fd79bd5470
Signed-off-by: Dean Kwon <daex.i.kwon@intel.com>
Signed-off-by: Jim Bride <jim.bride@intel.com>
Signed-off-by: Matt Gumbel <matthew.k.gumbel@intel.com>
2013-01-04 11:00:38 -08:00
David 'Digit' Turner
0d82fbf04d adb: Improve ADB's forward redirection management.
This adds a few new options/modes to 'adb forward':

  adb forward --list
  adb forward --remove <local>
  adb forward --remove-all
  adb forward --no-rebind <local> <remote>

For more context, see http://code.google.com/p/android/issues/detail?id=39631

Note that this only affects the host adb client and server programs,
i.e. it's compatible with devices running older adbd versions.

Change-Id: I9cda3ba12b5a8560a2061620bc7f948e5c1e70f7
2012-11-26 21:37:08 +01:00
Jeff Sharkey
d6d4286a28 Bring back ADB_EXTERNAL_STORAGE.
Bug: 7119408
Change-Id: Ic9a23fb6adfb1db771e1e278179586bca69a5edd
2012-09-06 13:05:40 -07:00
Benoit Goby
d5fcafaf41 adb: Add public key authentification
Secure adb using a public key authentication, to allow USB debugging
only from authorized hosts.

When a device is connected to an unauthorized host, the adb daemon sends
the user public key to the device. A popup is shown to ask the user to
allow debugging once or permanantly from the host. The public key is
installed on the device in the later case. Other keys may be installed
at build time.

On the host, the user public/private key pair is automatically generated,
if it does not exist, when the adb daemon starts and is stored in
$HOME/.android/adb_key(.pub) or in $ANDROID_SDK_HOME on windows. If needed,
the ADB_KEYS_PATH env variable may be set to a :-separated (; under
Windows) list of private keys, e.g. company-wide or vendor keys.

On the device, vendors public keys are installed at build time in
/adb_keys. User-installed keys are stored in /data/misc/adb/adb_keys.

ADB Protocol change:
If the device needs to authenticate the host, it replies to CNXN
packets with an AUTH packet. The AUTH packet payload is a random token.
The host signs the token with one of its private keys and sends an AUTH(0)
packet. If the signature verification succeeds, the device replies with
a CNXN packet. Otherwise, it sends a new AUTH packet with a new token so
that the host can retry with another private key. Once the host has tried
all its keys, it can send an AUTH(1) packet with a public key as
payload. adbd then sends the public key to the framework (if it has been
started) for confirmation.

Change-Id: I4e84d7621da956f66ff657245901bdaefead8395
2012-08-23 00:20:06 -07:00
Jeff Sharkey
bfcd810b79 Iteration on multi-user external storage.
Define /storage as top-level concept, so that we enforce permissions
uniformly.  Moves external storage paths from headers to per-device
environment variables.  Added missing mount flags, and we no longer
have adb-specific external storage.

Bug: 6925012
Change-Id: Ic7ca953be2f552d3f0ec9e69f89fef751daa1b29
2012-08-22 14:28:37 -07:00
Benoit Goby
3fc95a9918 Revert "adb: Add public key authentification"
This reverts commit f4ed516643.
2012-08-20 23:04:11 -07:00
Benoit Goby
300d6d65d0 Merge "adb: Add public key authentification" into jb-mr1-dev 2012-08-20 20:28:51 -07:00
John Grossman
9367f4f973 Replace a segfault with a warning.
Just print a warning if ADB_EXTERNAL_STORAGE is not defined when ADB
runs instead of segfaulting.  If we really don't want to continue to
run, we can make this a fatal error instead.

Change-Id: Icfc5fb9e594b0a310029f1dca7e9476f27ceb7bc
2012-08-20 16:38:01 -07:00
Jeff Sharkey
5dd0f86fbf Migrate sdcard0 to shell-accessible location.
Also remove mount() from adb, since it can come online long before
data partition is ready.  Set EXTERNAL_STORAGE environment variable
to point to owner for backwards compatibility.

Bug: 7005701
Change-Id: I63444f6636624eb7ad89f053daa289663424639e
2012-08-20 13:11:11 -07:00
Benoit Goby
f4ed516643 adb: Add public key authentification
Secure adb using a public key authentication, to allow USB debugging
only from authorized hosts.

When a device is connected to an unauthorized host, the adb daemon sends
the user public key to the device. A popup is shown to ask the user to
allow debugging once or permanantly from the host. The public key is
installed on the device in the later case. Other keys may be installed
at build time.

On the host, the user public/private key pair is automatically generated,
if it does not exist, when the adb daemon starts and is stored in
$HOME/.android/adb_key(.pub) or in $ANDROID_SDK_HOME on windows. If needed,
the ADB_KEYS_PATH env variable may be set to a ;-separated list of private
keys, e.g. company-wide or vendor keys.

On the device, vendors public keys are installed at build time in
/adb_keys. User-installed keys are stored in /data/misc/adb/adb_keys.

ADB Protocol change:
If the device needs to authenticate the host, it replies to CNXN
packets with an AUTH packet. The AUTH packet payload is a random token.
The host signs the token with one of its private keys and sends an AUTH(0)
packet. If the signature verification succeeds, the device replies with
a CNXN packet. Otherwise, it sends a new AUTH packet with a new token so
that the host can retry with another private key. Once the host has tried
all its keys, it can send an AUTH(1) packet with a public key as
payload. adbd then sends the public key to the framework (if it has been
started) for confirmation.

Change-Id: Idce931a7bfe4ce878428eaa47838e5184ac6073f
2012-08-16 21:36:26 -07:00
Jeff Sharkey
885342a0f2 Multi-user external storage support.
Remount rootfs as recursively shared, so that mount changes are
propagated into child namespaces.  Mount external storage for access
from adb.

Clean multi-user dependencies for use in Dalvik.  Also define
external storage paths.

Bug: 6925012
Change-Id: I375de581a63f4f36667894c56a34a9dd45361e8f
2012-08-15 21:10:07 -07:00
Mike J. Chen
1dd55c53af Allow adb to listen both on usb and tcp.
(cherry picked from commit ae868a4045 in master)

Change-Id: I980c7c5e8affbc8627d17b1d9303b002adcdb29a
Signed-off-by: Mike J. Chen <mjchen@google.com>

Conflicts:

	adb/adb.c
2012-08-09 11:43:52 -07:00
Benoit Goby
c29569c5d3 Merge "FunctionFS: initial implementation" 2012-06-06 15:51:07 -07:00
Scott Anderson
845f106a93 am 1b7a7e81: adb: Use bionic\'s strtok_r() for Windows
* commit '1b7a7e81195ff06a7482f81cb92b094bb3481cb1':
  adb: Use bionic's strtok_r() for Windows
2012-06-05 18:17:37 -07:00
Scott Anderson
1b7a7e8119 adb: Use bionic's strtok_r() for Windows
A recent change use strtok_r which broke the Windows build.
Clear this potential landmine by adding adb_strtok_r to sysdeps.h
in the typical fashion.  For Windows, the actual implementation
in sysdeps_win32.c was copied from bionic/libc/string/strtok.c.

Change-Id: Ibb71555bc429f7058c07c3d39e0b62859c79635c
Signed-off-by: Scott Anderson <saa@android.com>
2012-06-05 17:54:27 -07:00
Scott Anderson
0e9e13eb46 am 2ca3e6b3: adb: Generalizing -s to take qualifiers.
* commit '2ca3e6b35f79136418ebc32fef57580698dbd045':
  adb: Generalizing -s to take qualifiers.
2012-06-05 16:21:04 -07:00
Scott Anderson
3fef581bc7 am e82c2db0: adb: Transmit key properties in banner of connect message
* commit 'e82c2db05cae70a0490a1f84b7211ef42c329671':
  adb: Transmit key properties in banner of connect message
2012-06-05 16:21:03 -07:00
Scott Anderson
2ca3e6b35f adb: Generalizing -s to take qualifiers.
Prior to this change, -s could take either a serial number or a
device path (e.g. "-s 01498B1F02015015" or "-s usb:1-4.2").  This
change extends -s to also allow product, model or device names
(e.g. "-s product:mysid").  These new qualifiers will only be
available on devices that are running an adb daemon that provides
properties in the connect message per Change-Id:
    I09200decde4facb8fc9b4056fdae910155f2bcb9

The product, model and device are derived from the
ro.product.name, ro.product.model and ro.product.device
properties respectively.  They are prefixed with "product:",
"model:" or "device:" as appropriate.  In addition, any
non-alphanumerics in the model are changed to underscores.

If the -s parameter matches multiple devices, the result will be
the same as when multiple devices are connected but no -d, -e or
-s option is specified.  In general, this means the user will get
"error: more than one device".  However for get-state,
get-devpath and get-serialno, they will get "unknown".

The format of "devices -l" was changed to list all of the
qualifiers that are available.  The following example output
(with the last digits of the serial numbers replaced with X's) is
with a Galaxy Prime with an older adb daemon and another Galaxy
Prime and Galaxy S both with the enhanced adb daemons:

List of devices attached
016B75D60A0060XX       device usb:2-5 product:mysid model:Galaxy_Nexus device:toro
3731B535FAC200XX       device usb:1-4.2 product:soju model:Nexus_S device:crespo
01498B1F020150XX       device usb:1-4.1

Note that the serial number and state are now column oriented
instead of tab delimited.  After the serial number and state, all
qualifiers are listed with each preceded by a space.  The output
of the original devices command (without -l) is unchanged.

Change-Id: Iceeb2789874effc25a630d514a375d6f1889dc56
Signed-off-by: Scott Anderson <saa@android.com>
2012-06-05 11:13:40 -07:00
Scott Anderson
e82c2db05c adb: Transmit key properties in banner of connect message
protocol.txt says that the connect message should have three
fields:

        <systemtype>:<serialno>:<banner>

In reality, what is transmitted is simply:

        <systemtype>::

The serialno is obtained via other means so doesn't really need
to be a part of the connect message.  This change puts the
ro.product.name, ro.product.model and ro.product.device
properties in the <banner> for devices.  Each property is
terminated by a semicolon (;) with the key and value separated by
an equals sign (=).  Example message:

device::ro.product.name=<prd>;ro.product.model=<mdl>;ro.product.device=<dev>;

Making this change will enable the device list to provide more
information to the user and to give the potential for being able
to select which device to talk to with the -s option.

Change-Id: I09200decde4facb8fc9b4056fdae910155f2bcb9
Signed-off-by: Scott Anderson <saa@android.com>
2012-06-05 11:04:55 -07:00
Scott Anderson
a1020825fb am c7993af6: adb: Fix compiler warning
* commit 'c7993af64baec271a238646bc20aaa846866c4a9':
  adb: Fix compiler warning
2012-06-01 11:06:17 -07:00
Andrzej Pietrasiewicz
fd96db17b7 FunctionFS: initial implementation
This is the second version of a patch which demonstrates the possibility
of using adbd (Android Debug Bridge daemon) with a generic FunctionFS gadget
instead of a custom adb usb gadget in the Linux kernel. It contains changes
introduced after Benoit's review - thank you Benoit.

The patch adds a new usb access layer to adbd using FunctionFS. The former
usb access method is still available. The method is chosen at runtime
depending if /dev/usb-ffs/adb/ep0 or /dev/android_adb is accessible.

How to use on the target device:

$ insmod g_ffs.ko idVendor=<vendor ID> iSerialNumber=<some string>
$ mount -t functionfs adb /dev/usb-ffs/adb -o uid=2000,gid=2000
$ ./adbd

This patch requires a patch to bionic which adds <linux/usb_functionfs.h>
which is an exact copy of the relevant file in the linux kernel.

Change-Id: I4b42eb267ffa50fca7a5fba46f388a2f083e8b2d
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
[benoit@android.com: detect at runtime if functionfs is mounted
or fallback using f_adb]
Signed-off-by: Benoit Goby <benoit@android.com>
2012-05-31 15:00:41 -07:00
Scott Anderson
c7993af64b adb: Fix compiler warning
system/core/adb/adb.c: In function 'connect_device':
system/core/adb/adb.c:1001: warning: comparison between signed and unsigned integer expressions

Change-Id: I206f85395e1d7ad8d6ef130a26c95dcf0f498696
Signed-off-by: Scott Anderson <saa@android.com>
2012-05-31 11:29:49 -07:00
Scott Anderson
76e47e0ec8 am 9526a788: Merge "adb: Add ability to specify device path" into ics-aah
* commit '9526a788a6bd528e14622404e8750bdcc147d15a':
  adb: Add ability to specify device path
2012-05-01 19:33:41 -07:00
Scott Anderson
e109d266c1 adb: Add ability to specify device path
For manufacturing and testing, there is a need to talk to
whatever device is connected to a given port on the host.  This
change modifies adb's "-s" option to take either a serial
number or a device path.  The device paths of the connected
devices can be listed using "adb devices -l" whose output
will resemble:

    List of devices attached
    016B75D60A00600D	usb:2-5	device
    3031D0B2E71D00EC	usb:1-4.3	device

The second column lists the device paths.  If the -l option is
not given, the output from "adb devices" will be the same as
it used to be (i.e. the paths will not be printed).

The device path can also be obtained with the get-devpath
command:

    $adb -s 3031D0B2E71D00EC get-devpath
    usb:1-4.3

Note that the format of the device paths are platform dependent.
The example above is from Linux.  On OS-X, the paths will be
"usb:" followed by hex digits.  For other platforms, the device
paths will be printed as "????????????" and the -s option will
not be able to select a device until someone implements the
underlying functionality.

Change-Id: I057d5d9f8c5bb72eddf5b8088aae110763f809d7
Signed-off-by: Scott Anderson <saa@android.com>
2012-04-20 11:21:14 -07:00
Nick Kralevich
eb68fa8153 adb: set umask to 000
Init is going to be modified to set the umask to 077.
This will impact adb, as "adb install" and "adb sync"
assume that files will be world-readable / writable.

Keep adb's umask at 000 for now.

Bug: 3272072
Change-Id: I75978e8dd7bbdf4dbe7c9a691ef516235f207da2
2012-04-02 14:10:56 -07:00
Dianne Hackborn
50458cf76e Add AID_SDCARD_R.
Change-Id: I47f650e415e06c0b69790ffefea7f208c910ebd7
2012-03-08 14:30:32 -08:00
Vladimir Chtchetkine
28781b0a52 Enables ADBD tracing in the emulator.
When running inside the emulator, guest's adbd can connect to 'adb-debug' qemud
service that can display adb trace messages on condition that emulator has been
started with '-debug adb' option.

This CL enables that functionality in ADB code.

Change-Id: I59b4a76d3c887ad28b8aa8e2a01dfa814e75faa1
2012-02-27 10:41:53 -08:00
Nick Kralevich
5890fe3314 Don't allow adb to run as root in user builds.
Change-Id: I4fbd7beb7f76c68fead1a89b745f0dfb931b4597
2012-01-19 15:06:14 -08:00
Nick Kralevich
bd9206bc73 Move permission checking code to it's own function.
Change-Id: Ibe46ca3043791f3b3815080f9e23ac307b1f5900
2012-01-19 15:02:41 -08:00
Doug Zongker
447f061da1 add "adb sideload" and sideload connection state
Recovery will soon support a minimal implementation of adbd which will
do nothing but accept downloads from the "adb sideload" command and
install them.  This is the client side command (mostly resurrected out
of the old circa-2007 "adb recover" command) and the new connection
state.

Change-Id: I4f67b63f1b3b38d28c285d1278d46782679762a2
2012-01-10 10:09:07 -08:00
Joe Onorato
ae868a4045 Allow adb to listen both on usb and tcp.
Change-Id: I98db594241631fa17e39686727392afc8b3124bc
2011-12-07 17:50:28 -08:00
JP Abgrall
61b90bd211 adb: grant it AID_NET_BW_STATS for full /proc/net/xt_qtaguid/stats
Normally only bandwidth stats for the uid reading .../stats is returned.
With the extra group, adb shell will be able to read stats from
all UIDs.
This is to be used to offer data usage profiling to developers.

Change-Id: If3d2941ce5aa4dbb1a23947b97b893149ba224f7
2011-11-09 10:30:08 -08:00
Kenny Root
9ff99f6536 Merge "Default to secure mode" 2011-08-05 10:16:21 -07:00