Commit graph

1457 commits

Author SHA1 Message Date
Josh Gao
07db1196e7 adb: don't explode directories when pushing/pulling.
Previously, `adb pull /data/local/tmp` would spew all of the contents of
/data/local/tmp into the current directory. This patch makes push/pull
keep directories intact.

Bug: http://b/25394682
Change-Id: I2304ae9e61745a2b9536f58a6012640bf8ff422a
2015-11-11 14:01:45 -08:00
Josh Gao
12a2ae9a0c adb: improve error handling, comments.
This commit fixes two cases:
  `adb pull /data/local/tmp nonexistent/path` would succeed.
  `adb pull /data/local/tmp nonexistent/` would fail.

Change-Id: I60c39eb2816946686241af42cfa2ad5cdc63fb0e
2015-11-11 14:00:11 -08:00
Josh Gao
0bb1ce06ea Merge "adb: don't try to pull character or block devices." 2015-11-10 02:22:47 +00:00
Josh Gao
8d00a39eff adb: don't try to pull character or block devices.
Change-Id: I1a9e2c0097fe9c4017a9b338e812366c8e1154f0
2015-11-09 18:12:10 -08:00
Josh Gao
21abf5a7c1 adb: demote skipping a file from an error to a warning.
Change-Id: If6c88e8855369bd7feb570ac5310fc7f44994083
2015-11-09 17:47:56 -08:00
Elliott Hughes
79964cdf86 Merge "Fix adb shell escape handling." 2015-11-10 01:06:58 +00:00
Elliott Hughes
28416d6d33 Fix adb shell escape handling.
Start of input is, by definition, the start of a line. Give the states
names to make the error clearer. We should also swallow the escape
character until/unless it's proven not to have been part of an escape
sequence. Finally, implement an ssh(1)-like -e option so the user can
choose -- or, more importantly, disable -- escape character handling.

Change-Id: I28a91db47e15f3e7de96303c0b9a98d302b9c92e
2015-11-09 13:57:47 -08:00
Nick Kralevich
2d8f1d4c47 Merge "Enable hidepid=2 on /proc" 2015-11-09 20:05:22 +00:00
Spencer Low
363af568b8 adb/base: minor compiler portability improvements
I've been using these changes to compile with Visual Studio.

- GetFileBasename(): __FILE__ uses \ with Visual Studio.

- adb_trace.cpp: Apparently VS needs an ampersand before the function name.

- "expr1 ? : expr2" is a GCC extension.

- <algorithm> contains std::min().

- seekdir can't always be #define'd because some headers have members
  named seekdir.

- adb_utils.cpp: Not really a compiler issue, just a random fix:
  0x7F/DEL is not printable.

Change-Id: I0dfb634f1ba4ccbc0d1b9f71b00e838fbebb3b41
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-11-09 10:22:13 -08:00
Nick Kralevich
c39ba5ae32 Enable hidepid=2 on /proc
Add the following mount options to the /proc filesystem:

  hidepid=2,gid=3009

This change blocks /proc access unless you're in group 3009
(aka AID_READPROC).

Please see
  https://github.com/torvalds/linux/blob/master/Documentation/filesystems/proc.txt
for documentation on the hidepid option.

hidepid=2 is preferred over hidepid=1 since it leaks less information
and doesn't generate SELinux ptrace denials when trying to access
/proc without being in the proper group.

Add AID_READPROC to processes which need to access /proc entries for
other UIDs.

Bug: 23310674
Change-Id: I22bb55ff7b80ff722945e224845215196f09dafa
2015-11-09 09:08:46 -08:00
Elliott Hughes
79e1c7a7f8 AOSP master doesn't have "cmd".
Change-Id: I0f524b779a623a9e2db923fd9003b102460ae46f
2015-11-06 18:05:16 -08:00
Todd Kennedy
6fa848adba use new cmd command
Instead of using the pm command, 'adb install' and 'adb uninstall' will now
use the cmd command. Additionally, the APK will be streamed directly to
package installer instead of creating a temporary file.

(cherry-pick of d039800a4e008b52c532f901e3bb34b40877cf30.)
Change-Id: Ie7529afa5b039d29cc8183f36085ff4e66b3457a
2015-11-06 18:00:05 -08:00
Josh Gao
7fc45c3326 Merge "adb: pull empty directories." 2015-11-07 00:53:03 +00:00
Josh Gao
a837df8590 adb: remove superfluous checks.
Change-Id: I4d9ceb301b0d242b0bad9a0faa8e2a1824f36cca
2015-11-06 15:19:53 -08:00
Josh Gao
6580096c97 adb: pull empty directories.
Pushing empty directories is more troublesome, and probably either
requires changes to the server, or hacky `adb shell mkdir` stuff.

Bug: http://b/25395071
Change-Id: I4db6a993429a56e5c5ca994752418503b6f5d7c4
2015-11-06 15:04:24 -08:00
Josh Gao
f00db9d8b8 Merge "adb: add basename_lock to mutex_list.h." 2015-11-06 20:43:49 +00:00
Josh Gao
250107e9f7 adb: add basename_lock to mutex_list.h.
Fixes crash on Windows.

Change-Id: Ic87d8ff30a2e824b6012e7e94b8d83442e17d000
2015-11-06 12:19:23 -08:00
Josh Gao
cd7c1ed700 adb: make local_build_list match remote_build_list.
local_build_list previously was returning an int, 0 on success and -1 on
failure, while remote_build_list was returning a bool, true on success
and false on failure.

Change-Id: Iced6c4142e2f843048d81c4e133d6b6dc75a35dd
2015-11-04 17:46:11 -08:00
Josh Gao
d97315731f adb: C++ify more of the push/pull functions.
Change-Id: Ie82d51ecadf5c94f3b138f5b13a17c3b46c61899
2015-11-04 17:46:11 -08:00
Josh Gao
11d18f1491 Merge changes I70c94c4b,Ifd8769ed
* changes:
  adb: make mkdirs/secure_mkdirs do what they say.
  adb: remove use of mkdirs from `adb backup`.
2015-11-05 01:45:22 +00:00
Josh Gao
45b6fc878a adb: make mkdirs/secure_mkdirs do what they say.
Previously, mkdirs/secure_mkdirs wouldn't create a directory at the
specified path, only the ones above it.

Bug: http://b/25459942
Change-Id: I70c94c4b44d90723cb4a063657fc40e5bcb3b10e
2015-11-04 14:51:23 -08:00
Josh Gao
09c5bbf0fb adb: remove use of mkdirs from adb backup.
`adb backup -f nonexistent/directories/foo <pkg>` shouldn't create the
directory structure if they don't already exist.

Change-Id: Ifd8769ed7ee5e733a6635751ad09b714ab58ea4b
2015-11-04 14:35:43 -08:00
Josh Gao
77cdfbd50c Merge "adb: make adb_basename match the POSIX behavior." 2015-11-04 22:26:32 +00:00
Josh Gao
787f3442cc adb: make adb_basename match the POSIX behavior.
Previously, adb_basename was behaving according to the GNU, POSIX-incompatible
basename, despite POSIX adb_dirname existing alongside it. This patch changes
adb_basename to pass through to the POSIX basename.

Bug: http://b/25456821
Change-Id: I62a4865cccf3b9cdbc112e3e53ff475aa4a23bd9
2015-11-04 14:21:35 -08:00
Elliott Hughes
0fbf9618bb Fix Mac adb build.
The Mac doesn't have <termio.h>, and it looks like the canonical place for
struct winsize is <sys/ioctl.h> anyway.

  system/core/adb/commandline.cpp:44:10: fatal error: 'termio.h' file not found
  #include <termio.h>

Bug: http://b/19734542
Change-Id: I3bfbf58cdb9b582f3b7e2c9ef0977613001cd3ac
2015-11-04 13:07:47 -08:00
Elliott Hughes
1358e2869c Merge "adb shell SIGWINCH support." 2015-11-04 20:46:56 +00:00
Joon :ee
c288d48513 Fix adb GCC build (for google3).
Allow adb to build using gcc by explicitly using global scope for the
type for pollfd. An alternative would be to rename the pollfd field to
different, but I did not have a better name in mind.

Change-Id: I7925df1dca7e1acc5a289256f228e5fc3755e86e
2015-11-04 10:50:16 -08:00
Elliott Hughes
c15b17f1ac adb shell SIGWINCH support.
Bug: http://b/19734542
Change-Id: Ic9404a132cb9c42cb6a378bcd4b3dea9188d0a44
2015-11-04 10:45:11 -08:00
Josh Gao
fc7c3b682b adb: rename 'flag' to something less meaningless.
Change-Id: I7f7644a0a6f9a7d48508ddaad2e6a51266ae8ee6
2015-11-03 14:46:31 -08:00
Josh Gao
19d9454ee3 Merge "adb: C++ify local_build_list and remote_build_list." 2015-11-03 21:21:50 +00:00
Elliott Hughes
aff48cbb3f Merge "adb: fix adb reverse --no-rebind help text"
am: 4f23917299

* commit '4f2391729951ead5f0d15862bd19213962438776':
  adb: fix adb reverse --no-rebind help text
2015-11-03 02:44:13 +00:00
Elliott Hughes
4f23917299 Merge "adb: fix adb reverse --no-rebind help text" 2015-11-03 02:40:52 +00:00
Josh Gao
58ee99e454 Merge "adb: allow multiple args to push/pull."
am: fe54c96ab2

* commit 'fe54c96ab28a59a87c0c26ac4e6664826b4644ea':
  adb: allow multiple args to push/pull.
2015-11-03 02:27:39 +00:00
Josh Gao
fe54c96ab2 Merge "adb: allow multiple args to push/pull." 2015-11-03 02:22:08 +00:00
Spencer Low
587ea20f83 adb: fix adb reverse --no-rebind help text
There was a typo in the option.

Change-Id: I5c074a883a7b384663ed65cd8de0d891dc2b6606
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-11-02 17:34:49 -08:00
Josh Gao
9ea31c7285 Merge "adb: add SyncConnection::Printf."
am: e9af735de3

* commit 'e9af735de36eade81adc490635ee0076bdb6c79e':
  adb: add SyncConnection::Printf.
2015-11-03 01:33:54 +00:00
Josh Gao
cda6a2bd3e adb: C++ify local_build_list and remote_build_list.
Change-Id: I71586488869c4827c5bd7294faa7c0f433bb9fbc
2015-11-02 17:24:04 -08:00
Josh Gao
983c41c353 adb: add SyncConnection::Printf.
Replaces `sc.Print(android::base::StringPrintf(...)` with one call
to sc.Printf.

Change-Id: Ib7c98103dbca0b6a951f8e5a0f860ec6eacf6772
2015-11-02 17:21:43 -08:00
David Pursell
34e0d64719 Merge "adb: create unix_isatty() function."
am: d9ff9873df

* commit 'd9ff9873df4ef68c105bc84d8dbe098feaaa6c50':
  adb: create unix_isatty() function.
2015-11-03 00:48:56 +00:00
David Pursell
c5b8ad88ce adb: create unix_isatty() function.
Our Windows code has several different ways it checks whether an FD is
a console or not, some of which aren't exactly correct as they may
treat character devices (e.g. NUL) as consoles.

This CL disallows using the builtin isatty() function and provides
unix_isatty() instead which correctly checks these corner cases.

Change-Id: I6d551c745dae691c7eb3446b585265d62c1e62fa
2015-11-02 16:44:34 -08:00
Elliott Hughes
5b51ac7a59 Merge "Set HOME, LOGNAME, SHELL, and USER from adbd."
am: 36d7af4cf6

* commit '36d7af4cf635816ecbcb9bd300f4c9d60cb012d4':
  Set HOME, LOGNAME, SHELL, and USER from adbd.
2015-11-02 22:09:09 +00:00
Elliott Hughes
36d7af4cf6 Merge "Set HOME, LOGNAME, SHELL, and USER from adbd." 2015-11-02 22:05:07 +00:00
Elliott Hughes
fbe4332e37 Set HOME, LOGNAME, SHELL, and USER from adbd.
Previously we've set these from /system/etc/mkshrc, which caused a behavioral
difference between interactive and non-interactive shells.

Bug: http://b/19635681
Change-Id: I4608c42dd3de821046220fdb1770ab3216b5d5eb
2015-11-02 13:53:39 -08:00
Yabin Cui
7782bbdef3 Merge "adb: run reverse_service() in main thread."
am: 1060739bfe

* commit '1060739bfe26a6c0eb74e10a40787ed1d781e296':
  adb: run reverse_service() in main thread.
2015-11-02 21:39:18 +00:00
Yabin Cui
1060739bfe Merge "adb: run reverse_service() in main thread." 2015-11-02 21:34:39 +00:00
Josh Gao
05786779f3 adb: allow multiple args to push/pull.
Bug: http://b/25324823
Change-Id: I369dd97adbe1d08e18e84af776ce8b1d61251835
2015-11-02 12:48:24 -08:00
Josh Gao
dcaf6932fd Merge "adb: use correct _WIN32 macro."
am: 5c75b529f6

* commit '5c75b529f684b388c91c7e7d0b2c7fece376ac1d':
  adb: use correct _WIN32 macro.
2015-11-02 18:59:01 +00:00
Yabin Cui
fbfa84045d adb: run reverse_service() in main thread.
reverse_service() calls handle_forward_request(), which calls
functions in fdevent.cpp. fdevent functions is only supposed
to be called in the main thread.
Add check in fdevent.cpp to make sure all operations come from
main thread.

Bug: 25355808
Change-Id: Iceb9273f3056acc0713eaafe086ac950ca80ff4f
2015-11-02 10:39:09 -08:00
Josh Gao
4a1397264b adb: use correct _WIN32 macro.
Change-Id: I5af7957162ae7f8472a5a262434eaba84e64325a
2015-10-30 18:39:20 -07:00
Elliott Hughes
edb78620fb Merge "adb: fix adb client running out of sockets on Windows"
am: 1e2382a027

* commit '1e2382a0277eb36fb57a3a54202945556dfd234b':
  adb: fix adb client running out of sockets on Windows
2015-10-30 23:33:26 +00:00