summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjzhuan5 <jin.can.zhuang@intel.com>2013-05-24 17:40:15 -0400
committerBo Huang <bo.b.huang@intel.com>2014-05-05 17:20:00 +0800
commit1297d22bc99c26b2ad414faedd5bea73a16ecb90 (patch)
tree86bf4633234496e3d1a58445364ecbe080f77481
parent0607e104c2db2a3e115fd9b49ea85cbc03dbcd1f (diff)
downloadsystem_core-1297d22bc99c26b2ad414faedd5bea73a16ecb90.zip
system_core-1297d22bc99c26b2ad414faedd5bea73a16ecb90.tar.gz
system_core-1297d22bc99c26b2ad414faedd5bea73a16ecb90.tar.bz2
adbd: adb root should terminate adbd only if it's debuggable
adb root command will terminate adbd when closing the socket if current user id is not root. This works for userdebug build, as adb root causes re-enumeration. But for user build, adb root command won't cause re-enumeration, and if adbd is terminated and restarted, it will be in offline state, thus it won't send any thing to host. Change-Id: I81216a3b3da888cd9b236060cf745175f6d93c60 Author: jzhuan5 <jin.can.zhuang@intel.com> Signed-off-by: Bo Huang <bo.b.huang@intel.com>
-rw-r--r--adb/sockets.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/adb/sockets.c b/adb/sockets.c
index de14a22..faa9564 100644
--- a/adb/sockets.c
+++ b/adb/sockets.c
@@ -23,6 +23,10 @@
#include "sysdeps.h"
+#if !ADB_HOST
+#include <cutils/properties.h>
+#endif
+
#define TRACE_TAG TRACE_SOCKETS
#include "adb.h"
@@ -428,6 +432,9 @@ asocket *create_local_service_socket(const char *name)
{
asocket *s;
int fd;
+#if !ADB_HOST
+ char debug[PROPERTY_VALUE_MAX];
+#endif
#if !ADB_HOST
if (!strcmp(name,"jdwp")) {
@@ -444,7 +451,11 @@ asocket *create_local_service_socket(const char *name)
D("LS(%d): bound to '%s' via %d\n", s->id, name, fd);
#if !ADB_HOST
- if ((!strncmp(name, "root:", 5) && getuid() != 0)
+ if (!strncmp(name, "root:", 5))
+ property_get("ro.debuggable", debug, "");
+
+ if ((!strncmp(name, "root:", 5) && getuid() != 0
+ && strcmp(debug, "1") == 0)
|| !strncmp(name, "usb:", 4)
|| !strncmp(name, "tcpip:", 6)) {
D("LS(%d): enabling exit_on_close\n", s->id);