History log of /system/core/adb/shell_service.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
42afe2033fddc7c43ccfeb5f20defe992d0bc1a2 23-Jun-2016 Josh Gao <jmgao@google.com> adb: don't dup local socket fd.

SIGHUP handling depends on the local socket fd being fully closed in
order to trigger an event on its counterpart. Release the local socket
fd inside of Subprocess when returning it to ensure this.

Bug: http://b/29565233
Change-Id: I13b17bcddf0b396a5f4880f9e410fbbf24d9370d
/system/core/adb/shell_service.cpp
69d2f9819785775c86137f5ff3298cd46b14a516 23-Mar-2016 Josh Gao <jmgao@google.com> adb: fix fd double close, Subprocess lifetime issue.

This commit fixes two somewhat related issues in shell_service.

- The fd returned by StartSubprocess is owned by a unique_fd
contained in the Subprocess object, but also gets closed by the
caller. Resolve this by duping the returned file descriptor.

- A Subprocess object can be destroyed immediately after its initial
construction in StartSubprocess if we're sufficiently unlucky.
Split up the fork/exec and "start management thread" steps, so that
we can safely do everything we need to do on the Subprocess before
handing it over to the thread that'll eventually destroy it.

Also includes squashed patches from AOSP master that allow for use of
unique_fd inside adb.

Bug: http://b/29254462
Change-Id: Id9cf0b7e7a7293bee7176919edc758597691c636
(cherry picked from commit c0e6e40cc916747a0a22c2538874348cda0ef607)
(cherry picked from commit 54c72aaccc45edf4832cfdc5053d9ae6acc9bcdf)
(cherry picked from commit 2c5d1d7cd914ec8ebf76c8a59d0889ebf5b538cd)
(cherry picked from commit 2a7b86337f7b149887588e4df532272abe3e931c)
(cherry picked from commit 13ea01db451b3993d175110a3336a58482be883d)
(cherry picked from commit 344778da411ebb47966961f3a70ca0848425194f)
/system/core/adb/shell_service.cpp
a6d56611404f2e1c0c9f4ab7c8471af0e80b2026 06-Jun-2016 David Pursell <dpursell@google.com> adbd: properly close subprocess pipes on Ctrl+C.

When non-interactive sessions exit via Ctrl+C, adbd sends SIGHUP
to the child process to let it know to exit. However, adbd was not
closing the pipes to the child process, so if the subprocess ignored
SIGHUP and continued writing it could fill up the pipe and block
forever while adbd waits for it to exit.

This CL adds the necessary calls to close the subprocess pipe after
sending SIGHUP.

Bug: 28981563
Change-Id: I318e322e563241052648361172f4859c297837fb
(cherry picked from commit f2aa186c7b0792ef4d3e106e2a03be5c3c215118)
/system/core/adb/shell_service.cpp
8238dd84992988ecbaa8b8e2b5691d2cf2391e35 05-Mar-2016 Josh Gao <jmgao@google.com> adbd: fix spurious close of uninitialized fd.

forkpty only returns an fd on the master side; trying to keep track of
it on both sides is incorrect.

Bug: http://b/27504427
Change-Id: Ia4a454d8490c77738f9c3350a4236b3d99c8758b
(cherry picked from commit fcb063ce378419ad1511d3395d44701b4ebaceb0)
/system/core/adb/shell_service.cpp
a9eb38d6a539e2e994ddd14c1e5d1d8ff157d0c9 05-Mar-2016 Josh Gao <jmgao@google.com> adb: make ScopedFd universally accessible and useful.

Change-Id: I707ffbd10958e7449b4c95dff48638480c746939
(cherry picked from commit f0d3b4fc11b35ce295bd698555579ed242473e69)
/system/core/adb/shell_service.cpp
d9db09c3158d3da6aad34fbb926888ceafab3a55 12-Feb-2016 Josh Gao <jmgao@google.com> adb: make adb_thread_func_t return void, add adb_thread_exit.

Windows restricts the return value of threads to 32-bits, even on 64-bit
platforms. Since we don't actually return meaningful values from thread,
resolve this inconsistency with POSIX by making adb's thread abstraction
only take void functions.

Change-Id: I5c23b4432314f13bf16d606fd5e6b6b7b6ef98b5
(cherry picked from commit b5fea14e13bb6e41b36f374c954dc55faeef4627)
/system/core/adb/shell_service.cpp
4323507a7eecb2384a872086ab933948bd8cbe80 26-Jan-2016 Josh Gao <jmgao@google.com> adb: report subprocess creation errors to the client.

Bug: http://b/26589627
Change-Id: I38e7a33ea8274f0eb47dc0ed87fcbca08a0ab22a
/system/core/adb/shell_service.cpp
a9352202dd52a404199fbdca160d9d2d0992cf63 29-Jan-2016 David Pursell <dpursell@google.com> Merge "adb: fix subprocess termination for legacy shell."
57dd5ae1e3004daec664263e24dc4dcf4475bb02 28-Jan-2016 David Pursell <dpursell@google.com> adb: fix subprocess termination for legacy shell.

http://r.android.com/166419 changed `adb shell` behavior to not
allocate a remote PTY for non-interactive commands, but adbd relied on
having a PTY to properly terminate the subprocess.

One impact of this is that when using older versions of adb or passing
the -x flag, `adb screenrecord` wasn't properly terminating and closing
out the video file.

This CL restores the old behavior for legacy shell connections: always
use a PTY, but put it in raw mode if the client is doing local PTY
input/output processing itself.

Bug: http://b/26742824
Change-Id: I9ee630c0ff0d2d6a0db367387af7123deea79676
/system/core/adb/shell_service.cpp
d61a25c17204b74b81558cb5d67c347f1e87fef1 11-Jan-2016 Rubin Xu <rubinxu@google.com> ADB security logging

Log adb shell, pull and push operations to the security log.

Bug: 22860162
Change-Id: I5d24e9d51040ae05a41d9fcb079e84351a217bd3
/system/core/adb/shell_service.cpp
b5028e46b0d97c84144f660b5e47f7fd4a716fe5 20-Jan-2016 Josh Gao <jmgao@google.com> adbd: use pty to determine whether a session is interactive.

Bug: http://b/26236990
Change-Id: I8baa4009a2fbe9a4c93f6ef5350ce61161b7237d
/system/core/adb/shell_service.cpp
c65fae9ef56163d17bcc86b6b6324be2b56b4aa5 20-Jan-2016 Josh Gao <jmgao@google.com> adbd: don't leave zombies when subprocess creation fails.

Bug: http://b/26660675
Change-Id: I8e65d51af73f409c30be47575f76bc6b0f227c54
/system/core/adb/shell_service.cpp
e03c988748d860527248d4aca01bb7903d3799aa 12-Dec-2015 Josh Gao <jmgao@google.com> adb: handle some edge cases with process environments.

Change-Id: I0c20e58e14ef756a8c45dd5ea85f7301157a3c8e
/system/core/adb/shell_service.cpp
9b3fd6721392b16dee00caeca9586070496471e1 11-Dec-2015 Josh Gao <jmgao@google.com> adb: don't use setenv after forking.

Previously, for `adb shell`, we were using setenv after forking to set
up the child's environment. This would occasionally deadlock in the
child, which would cause the main thread to deadlock waiting for the
child to complete. This patch constructs the environment before forking
and passes it to execle, eliminating the deadlock.

Bug: http://b/25847115
Change-Id: I720d472770564b1449819ddaab945a89844244a8
/system/core/adb/shell_service.cpp
b118762241da6676fce834728be4a10260ac28a1 10-Dec-2015 Nick Kralevich <nnk@google.com> Revert "adb: Make HOME=/data/local/tmp"

During early boot, we may be mounting and unmounting /data.
Having the home directory for adb shell commands, such as
"adb shell logcat", on the /data directory prevents unmounting.

This reverts commit 173eb396c7854a3b6c18d0d65865ad05c8b0e195.

Bug: 26132185
Change-Id: Ib7c2f9e696f52bf5bbb79223d90dd76791779587
/system/core/adb/shell_service.cpp
173eb396c7854a3b6c18d0d65865ad05c8b0e195 08-Dec-2015 Nick Kralevich <nnk@google.com> adb: Make HOME=/data/local/tmp

Make the home directory for adb shell be /data/local/tmp and
automatically change into that directory.

Change-Id: Ib5cc6e1ecdd31a37e986cf03836f7589ebd40868
/system/core/adb/shell_service.cpp
4f71319df011d796a60a43fc1bc68e16fbf7d321 05-Dec-2015 Elliott Hughes <enh@google.com> Track rename of base/ to android-base/.

Change-Id: Idf9444fece4aa89c93e15640de59a91f6e758ccf
/system/core/adb/shell_service.cpp
18ddf5c6a233bd56d20548fd834c0ecbf8216410 16-Nov-2015 Elliott Hughes <enh@google.com> Pass $TERM to the device.

Unfortunately, this isn't backwards-compatible with the current shell
protocol because we made unknown shell: arguments errors. We could try
to commit the change to make them just warnings first, but how would
we know when everyone was running adbd with that change? Bumping the
protocol version doesn't help because that only affects the code running
on the host. And although we could add another feature to the reported
features, since shell_v2 is still in development, that doesn't seem
worthwhile.

Bug: http://b/25601436
Change-Id: I12b81aa656cd25b91d14ef691dcbd2b7dab49535
/system/core/adb/shell_service.cpp
c15b17f1acfcdbda8602ab135371f7b7238b4b39 03-Nov-2015 Elliott Hughes <enh@google.com> adb shell SIGWINCH support.

Bug: http://b/19734542
Change-Id: Ic9404a132cb9c42cb6a378bcd4b3dea9188d0a44
/system/core/adb/shell_service.cpp
fbe4332e373208637dd928edf06a0da6cba92feb 02-Nov-2015 Elliott Hughes <enh@google.com> 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
/system/core/adb/shell_service.cpp
1ed57f0dc333c0bc0800e222c569cca8a71deb89 07-Oct-2015 David Pursell <dpursell@google.com> adb: non-interactive shell stdin.

Non-interactive `adb shell` previously only read from the remote shell,
but we want it to write as well so interactive and non-interactive
shells can both send data. With this CL, we can now do:
$ echo foo | adb shell cat
foo

This is primarily usable with newer devices that support the shell_v2
features. Older devices will receive stdin but the shell will still
hang after all input has been sent, requiring user Ctrl+C. This seems
better than closing communication altogether which could potentially
miss an unpredictable amount of return data by closing too early.

Known issue: non-interactive stdin to a PTY shell isn't reliable.
However I don't think this is a common case as ssh doesn't seem to
handle it properly either. Examples:
* echo 'echo foo' | adb shell
* echo 'foo' | adb shell -t cat

Bug: http://b/24565284
Change-Id: I5b017fd12d8478765bb6e8400ea76d535c24ce42
/system/core/adb/shell_service.cpp
6dfef255b8fa77e3b5c0a69b7f276ea8e25e22cd 07-Oct-2015 Yabin Cui <yabinc@google.com> adb: keep file flags in fdevent_install.

Bug: 24615098
Change-Id: Ia791ecbe612f09aca3bbd5787513f121fae54da5
/system/core/adb/shell_service.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/shell_service.cpp
544e795fbb8a750f67796d7d0cad898f3f5f711c 15-Sep-2015 David Pursell <dpursell@google.com> adb: Kill subprocess when the client exits.

When the client exits (e.g. with Ctrl+C) the subprocess should be
notified as well so it can cleanup if needed.

Bug: http://b/23825725
Change-Id: Idb771710b293e0a9f7bebc9e2814b3a816e2c50e
/system/core/adb/shell_service.cpp
0955c66b226db7a7f34613f834f7b0a145fd407d 31-Aug-2015 David Pursell <dpursell@google.com> adb: implement shell protocol.

Adds functionality for handling stdin/stdout/stderr streams and exit
codes using the shell protocol.

This CL just contains implementation for adbd which will not yet be
enabled. Once we have the ability to query transport features from the
adb client, another CL will add the implementation for the client side
and update the feature list to turn this on.

Note: this CL must be submitted together with a minadbd CL to update
the service_to_fd() function signature.

Bug: http://b/23030641

Change-Id: Ibed55e9c1946d8a35190696163ff63e8fb880238
/system/core/adb/shell_service.cpp
a932058504ee20d28f1a5b3c17c377543e4eb281 29-Aug-2015 David Pursell <dpursell@google.com> adb: refactor subprocess code.

Refactor shell_service.cpp to remove dependencies on service.cpp and
combine some common logic between PTY and raw subprocesses.

This will make it easier to add additional common code paths for
the upcoming shell protocol.

Change-Id: I497d30dd388de61b6e68d9086dce38f33dd92876
/system/core/adb/shell_service.cpp
80f67029e002a97dd4f752881d820b3161f729f1 29-Aug-2015 David Pursell <dpursell@google.com> adb: move shell service to a separate file.

Upcoming changes to the shell will require significant additions to
the subprocess code, and it will be cleaner if it's in a separate file.

The only functional change here is a new debug tag specifically for
the shell service. Everything else has been copied exactly as-is in
order to make it easier to determine what's changing in upcoming CLs.

Change-Id: I13bd4294059051ee10e0d0c6a06affd8eca62967
/system/core/adb/shell_service.cpp